Merge branch 'fix-error-handling-bugs-in-kubernetes-integration' into 'master'
Fix error handling bugs in kubernetes integration See merge request gitlab-org/gitlab-ce!22922
This commit is contained in:
commit
f69f7a6702
4 changed files with 20 additions and 3 deletions
|
@ -16,8 +16,6 @@ module Clusters
|
|||
configure_kubernetes_token
|
||||
|
||||
kubernetes_namespace.save!
|
||||
rescue ::Kubeclient::HttpError => err
|
||||
raise err unless err.error_code = 404
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -17,6 +17,6 @@ class ClusterPlatformConfigureWorker
|
|||
end
|
||||
|
||||
rescue ::Kubeclient::HttpError => err
|
||||
Rails.logger.error "Failed to create/update Kubernetes Namespace. id: #{kubernetes_namespace.id} message: #{err.message}"
|
||||
Rails.logger.error "Failed to create/update Kubernetes namespace for cluster_id: #{cluster_id} with error: #{err.message}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix error handling bugs in kubernetes integration
|
||||
merge_request: 22922
|
||||
author:
|
||||
type: fixed
|
|
@ -30,4 +30,18 @@ describe ClusterPlatformConfigureWorker, '#execute' do
|
|||
described_class.new.perform(123)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when kubeclient raises error' do
|
||||
let(:cluster) { create(:cluster, :project) }
|
||||
|
||||
it 'rescues and logs the error' do
|
||||
allow_any_instance_of(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService).to receive(:execute).and_raise(::Kubeclient::HttpError.new(500, 'something baaaad happened', ''))
|
||||
|
||||
expect(Rails.logger)
|
||||
.to receive(:error)
|
||||
.with("Failed to create/update Kubernetes namespace for cluster_id: #{cluster.id} with error: something baaaad happened")
|
||||
|
||||
described_class.new.perform(cluster.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue