Commit 0752354f authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent ae2aaa682e06
......@@ -223,7 +223,7 @@ def authorize_push_to_branch!(branch)
present user_project.repository.commit(result[:result]),
with: Entities::Commit
else
render_api_error!(result[:message], 400)
error!(result.slice(:message, :error_code), 400, header)
end
end
......@@ -257,7 +257,7 @@ def authorize_push_to_branch!(branch)
present user_project.repository.commit(result[:result]),
with: Entities::Commit
else
render_api_error!(result[:message], 400)
error!(result.slice(:message, :error_code), 400, header)
end
end
......
.dast-auto-deploy:
image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v0.4.0"
image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v0.6.0"
dast_environment_deploy:
extends: .dast-auto-deploy
......
.auto-deploy:
image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v0.4.0"
image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v0.6.0"
review:
extends: .auto-deploy
......
......@@ -3,7 +3,12 @@
module Gitlab
module Cluster
class PumaWorkerKillerInitializer
def self.start(puma_options, puma_per_worker_max_memory_mb: 850, puma_master_max_memory_mb: 550)
def self.start(
puma_options,
puma_per_worker_max_memory_mb: 850,
puma_master_max_memory_mb: 550,
additional_puma_dev_max_memory_mb: 200
)
require 'puma_worker_killer'
PumaWorkerKiller.config do |config|
......@@ -14,7 +19,11 @@ def self.start(puma_options, puma_per_worker_max_memory_mb: 850, puma_master_max
# The Puma Worker Killer checks the total RAM used by both the master
# and worker processes.
# https://github.com/schneems/puma_worker_killer/blob/v0.1.0/lib/puma_worker_killer/puma_memory.rb#L57
config.ram = puma_master_max_memory_mb + (worker_count * puma_per_worker_max_memory_mb)
#
# Additional memory is added when running in `development`
config.ram = puma_master_max_memory_mb +
(worker_count * puma_per_worker_max_memory_mb) +
(Rails.env.development? ? (1 + worker_count) * additional_puma_dev_max_memory_mb : 0)
config.frequency = 20 # seconds
......
......@@ -25,9 +25,18 @@ class Repository
InvalidRef = Class.new(StandardError)
GitError = Class.new(StandardError)
DeleteBranchError = Class.new(StandardError)
CreateTreeError = Class.new(StandardError)
TagExistsError = Class.new(StandardError)
ChecksumError = Class.new(StandardError)
class CreateTreeError < StandardError
attr_reader :error_code
def initialize(error_code)
super(self.class.name)
# The value coming from Gitaly is an uppercase String (e.g., "EMPTY")
@error_code = error_code.downcase.to_sym
end
end
# Directory name of repo
attr_reader :name
......
......@@ -447,7 +447,7 @@ def handle_cherry_pick_or_revert_response(response)
elsif response.commit_error.presence
raise Gitlab::Git::CommitError, response.commit_error
elsif response.create_tree_error.presence
raise Gitlab::Git::Repository::CreateTreeError, response.create_tree_error
raise Gitlab::Git::Repository::CreateTreeError, response.create_tree_error_code
end
Gitlab::Git::OperationService::BranchUpdate.from_gitaly(response.branch_update)
......
......@@ -3,7 +3,7 @@
module Gitlab
module Kubernetes
module Helm
HELM_VERSION = '2.15.1'
HELM_VERSION = '2.16.1'
KUBECTL_VERSION = '1.13.12'
NAMESPACE = 'gitlab-managed-apps'
SERVICE_ACCOUNT = 'tiller'
......
......@@ -227,16 +227,17 @@ def post_create_gcp
describe 'security' do
before do
allow_any_instance_of(described_class)
.to receive(:token_in_session).and_return('token')
allow_any_instance_of(described_class)
.to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s)
allow_any_instance_of(GoogleApi::CloudPlatform::Client)
.to receive(:projects_zones_clusters_create) do
OpenStruct.new(
self_link: 'projects/gcp-project-12345/zones/us-central1-a/operations/ope-123',
status: 'RUNNING'
)
allow_next_instance_of(described_class) do |instance|
allow(instance).to receive(:token_in_session).and_return('token')
allow(instance).to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s)
end
allow_next_instance_of(GoogleApi::CloudPlatform::Client) do |instance|
allow(instance).to receive(:projects_zones_clusters_create) do
OpenStruct.new(
self_link: 'projects/gcp-project-12345/zones/us-central1-a/operations/ope-123',
status: 'RUNNING'
)
end
end
allow(WaitForClusterCreationWorker).to receive(:perform_in).and_return(nil)
......@@ -467,7 +468,9 @@ def get_cluster_status
end
it 'invokes schedule_status_update on each application' do
expect_any_instance_of(Clusters::Applications::Ingress).to receive(:schedule_status_update)
expect_next_instance_of(Clusters::Applications::Ingress) do |instance|
expect(instance).to receive(:schedule_status_update)
end
get_cluster_status
end
......
......@@ -13,7 +13,9 @@
let(:user) { create(:omniauth_user, provider: 'ldapmain', extern_uid: 'uid=myuser,ou=people,dc=example,dc=com') }
it 'repairs ldap blocks' do
expect_any_instance_of(RepairLdapBlockedUserService).to receive(:execute)
expect_next_instance_of(RepairLdapBlockedUserService) do |instance|
expect(instance).to receive(:execute)
end
put :update, params: { user_id: user.username, id: user.ldap_identity.id, identity: { provider: 'twitter' } }
end
......@@ -23,7 +25,9 @@
let(:user) { create(:omniauth_user, provider: 'ldapmain', extern_uid: 'uid=myuser,ou=people,dc=example,dc=com') }
it 'repairs ldap blocks' do
expect_any_instance_of(RepairLdapBlockedUserService).to receive(:execute)
expect_next_instance_of(RepairLdapBlockedUserService) do |instance|
expect(instance).to receive(:execute)
end
delete :destroy, params: { user_id: user.username, id: user.ldap_identity.id }
end
......
......@@ -39,7 +39,9 @@
describe '#mark_as_ham' do
before do
allow_any_instance_of(AkismetService).to receive(:submit_ham).and_return(true)
allow_next_instance_of(AkismetService) do |instance|
allow(instance).to receive(:submit_ham).and_return(true)
end
end
it 'submits the log as ham' do
post :mark_as_ham, params: { id: first_spam.id }
......
......@@ -20,8 +20,9 @@ def assign_session_token
describe "GET callback" do
it "updates access token" do
allow_any_instance_of(Gitlab::GitlabImport::Client)
.to receive(:get_token).and_return(token)
allow_next_instance_of(Gitlab::GitlabImport::Client) do |instance|
allow(instance).to receive(:get_token).and_return(token)
end
stub_omniauth_provider('gitlab')
get :callback
......
......@@ -104,7 +104,9 @@
end
it "sends notifications if all discussions are resolved" do
expect_any_instance_of(MergeRequests::ResolvedDiscussionNotificationService).to receive(:execute).with(merge_request)
expect_next_instance_of(MergeRequests::ResolvedDiscussionNotificationService) do |instance|
expect(instance).to receive(:execute).with(merge_request)
end
post :resolve, params: request_params
end
......@@ -122,8 +124,10 @@
end
it "renders discussion with serializer" do
expect_any_instance_of(DiscussionSerializer).to receive(:represent)
.with(instance_of(Discussion), { context: instance_of(described_class), render_truncated_diff_lines: true })
expect_next_instance_of(DiscussionSerializer) do |instance|
expect(instance).to receive(:represent)
.with(instance_of(Discussion), { context: instance_of(described_class), render_truncated_diff_lines: true })
end
post :resolve, params: request_params
end
......@@ -193,8 +197,10 @@
end
it "renders discussion with serializer" do
expect_any_instance_of(DiscussionSerializer).to receive(:represent)
.with(instance_of(Discussion), { context: instance_of(described_class), render_truncated_diff_lines: true })
expect_next_instance_of(DiscussionSerializer) do |instance|
expect(instance).to receive(:represent)
.with(instance_of(Discussion), { context: instance_of(described_class), render_truncated_diff_lines: true })
end
delete :unresolve, params: request_params
end
......
......@@ -13,8 +13,9 @@
describe 'GET #new' do
before do
allow_any_instance_of(MattermostSlashCommandsService)
.to receive(:list_teams).and_return([])
allow_next_instance_of(MattermostSlashCommandsService) do |instance|
allow(instance).to receive(:list_teams).and_return([])
end
end
it 'accepts the request' do
......@@ -42,7 +43,9 @@
context 'no request can be made to mattermost' do
it 'shows the error' do
allow_any_instance_of(MattermostSlashCommandsService).to receive(:configure).and_return([false, "error message"])
allow_next_instance_of(MattermostSlashCommandsService) do |instance|
allow(instance).to receive(:configure).and_return([false, "error message"])
end
expect(subject).to redirect_to(new_project_mattermost_url(project))
end
......@@ -50,7 +53,9 @@
context 'the request is succesull' do
before do
allow_any_instance_of(Mattermost::Command).to receive(:create).and_return('token')
allow_next_instance_of(Mattermost::Command) do |instance|
allow(instance).to receive(:create).and_return('token')
end
end
it 'redirects to the new page' do
......
......@@ -85,7 +85,9 @@
describe 'GET diffs' do
context 'when merge request cannot be created' do
it 'does not assign diffs var' do
allow_any_instance_of(MergeRequest).to receive(:can_be_created).and_return(false)
allow_next_instance_of(MergeRequest) do |instance|
allow(instance).to receive(:can_be_created).and_return(false)
end
get :diffs, params: get_diff_params.merge(format: 'json')
......
......@@ -86,7 +86,9 @@ def go(extra_params = {})
end
it 'serializes merge request diff collection' do
expect_any_instance_of(DiffsSerializer).to receive(:represent).with(an_instance_of(Gitlab::Diff::FileCollection::MergeRequestDiff), an_instance_of(Hash))
expect_next_instance_of(DiffsSerializer) do |instance|
expect(instance).to receive(:represent).with(an_instance_of(Gitlab::Diff::FileCollection::MergeRequestDiff), an_instance_of(Hash))
end
go
end
......@@ -98,7 +100,9 @@ def go(extra_params = {})
end
it 'serializes merge request diff collection' do
expect_any_instance_of(DiffsSerializer).to receive(:represent).with(an_instance_of(Gitlab::Diff::FileCollection::MergeRequestDiff), an_instance_of(Hash))
expect_next_instance_of(DiffsSerializer) do |instance|
expect(instance).to receive(:represent).with(an_instance_of(Gitlab::Diff::FileCollection::MergeRequestDiff), an_instance_of(Hash))
end
go
end
......
......@@ -785,7 +785,9 @@ def create!
end
it "sends notifications if all discussions are resolved" do
expect_any_instance_of(MergeRequests::ResolvedDiscussionNotificationService).to receive(:execute).with(merge_request)
expect_next_instance_of(MergeRequests::ResolvedDiscussionNotificationService) do |instance|
expect(instance).to receive(:execute).with(merge_request)
end
post :resolve, params: request_params
end
......
......@@ -45,7 +45,9 @@
end
it 'adds user to members' do
expect_any_instance_of(Members::CreateService).to receive(:execute).and_return(status: :success)
expect_next_instance_of(Members::CreateService) do |instance|
expect(instance).to receive(:execute).and_return(status: :success)
end
post :create, params: {
namespace_id: project.namespace,
......@@ -59,7 +61,9 @@
end
it 'adds no user to members' do
expect_any_instance_of(Members::CreateService).to receive(:execute).and_return(status: :failure, message: 'Message')
expect_next_instance_of(Members::CreateService) do |instance|
expect(instance).to receive(:execute).and_return(status: :failure, message: 'Message')
end
post :create, params: {
namespace_id: project.namespace,
......
......@@ -85,7 +85,9 @@
end
it 'calls prometheus adapter service' do
expect_any_instance_of(::Prometheus::AdapterService).to receive(:prometheus_adapter)
expect_next_instance_of(::Prometheus::AdapterService) do |instance|
expect(instance).to receive(:prometheus_adapter)
end
subject.__send__(:prometheus_adapter)
end
......
......@@ -125,7 +125,9 @@
context 'when run_auto_devops_pipeline is true' do
before do
expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(true)
expect_next_instance_of(Projects::UpdateService) do |instance|
expect(instance).to receive(:run_auto_devops_pipeline?).and_return(true)
end
end
context 'when the project repository is empty' do
......@@ -159,7 +161,9 @@
context 'when run_auto_devops_pipeline is not true' do
before do
expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(false)
expect_next_instance_of(Projects::UpdateService) do |instance|
expect(instance).to receive(:run_auto_devops_pipeline?).and_return(false)
end
end
it 'does not queue a CreatePipelineWorker' do
......
......@@ -92,7 +92,9 @@ def create_snippet(project, snippet_params = {}, additional_params = {})
context 'when the snippet is spam' do
before do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
allow_next_instance_of(AkismetService) do |instance|
allow(instance).to receive(:spam?).and_return(true)
end
end
context 'when the snippet is private' do
......@@ -170,7 +172,9 @@ def update_snippet(snippet_params = {}, additional_params = {})
context 'when the snippet is spam' do
before do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
allow_next_instance_of(AkismetService) do |instance|
allow(instance).to receive(:spam?).and_return(true)
end
end
context 'when the snippet is private' do
......@@ -278,7 +282,9 @@ def update_snippet(snippet_params = {}, additional_params = {})
let(:snippet) { create(:project_snippet, :private, project: project, author: user) }
before do
allow_any_instance_of(AkismetService).to receive_messages(submit_spam: true)
allow_next_instance_of(AkismetService) do |instance|
allow(instance).to receive_messages(submit_spam: true)
end
stub_application_setting(akismet_enabled: true)
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment