Commit 53e2987b authored by Pirate Praveen's avatar Pirate Praveen

Replace KubeException with Kubeclient::HttpError (kubeclient 3.0)

parent 0b246d57
...@@ -134,7 +134,7 @@ module Clusters ...@@ -134,7 +134,7 @@ module Clusters
kubeclient = build_kubeclient! kubeclient = build_kubeclient!
kubeclient.get_pods(namespace: actual_namespace).as_json kubeclient.get_pods(namespace: actual_namespace).as_json
rescue KubeException => err rescue Kubeclient::HttpError => err
raise err unless err.error_code == 404 raise err unless err.error_code == 404
[] []
......
...@@ -197,7 +197,7 @@ class KubernetesService < DeploymentService ...@@ -197,7 +197,7 @@ class KubernetesService < DeploymentService
kubeclient = build_kubeclient! kubeclient = build_kubeclient!
kubeclient.get_pods(namespace: actual_namespace).as_json kubeclient.get_pods(namespace: actual_namespace).as_json
rescue KubeException => err rescue Kubeclient::HttpError => err
raise err unless err.error_code == 404 raise err unless err.error_code == 404
[] []
......
...@@ -32,7 +32,7 @@ module Ci ...@@ -32,7 +32,7 @@ module Ci
kubeclient = build_kubeclient! kubeclient = build_kubeclient!
kubeclient.get_secrets.as_json kubeclient.get_secrets.as_json
rescue KubeException => err rescue Kubeclient::HttpError => err
raise err unless err.error_code == 404 raise err unless err.error_code == 404
[] []
......
...@@ -12,7 +12,7 @@ module Clusters ...@@ -12,7 +12,7 @@ module Clusters
else else
check_timeout check_timeout
end end
rescue KubeException => ke rescue Kubeclient::HttpError => ke
app.make_errored!("Kubernetes error: #{ke.message}") unless app.errored? app.make_errored!("Kubernetes error: #{ke.message}") unless app.errored?
end end
......
...@@ -10,7 +10,7 @@ module Clusters ...@@ -10,7 +10,7 @@ module Clusters
ClusterWaitForAppInstallationWorker.perform_in( ClusterWaitForAppInstallationWorker.perform_in(
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id) ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
rescue KubeException => ke rescue Kubeclient::HttpError => ke
app.make_errored!("Kubernetes error: #{ke.message}") app.make_errored!("Kubernetes error: #{ke.message}")
rescue StandardError rescue StandardError
app.make_errored!("Can't start installation process") app.make_errored!("Can't start installation process")
......
...@@ -10,7 +10,7 @@ module Gitlab ...@@ -10,7 +10,7 @@ module Gitlab
def exists? def exists?
@client.get_namespace(name) @client.get_namespace(name)
rescue ::KubeException => ke rescue ::Kubeclient::HttpError => ke
raise ke unless ke.error_code == 404 raise ke unless ke.error_code == 404
false false
......
...@@ -9,7 +9,7 @@ describe Gitlab::Kubernetes::Namespace do ...@@ -9,7 +9,7 @@ describe Gitlab::Kubernetes::Namespace do
describe '#exists?' do describe '#exists?' do
context 'when namespace do not exits' do context 'when namespace do not exits' do
let(:exception) { ::KubeException.new(404, "namespace #{name} not found", nil) } let(:exception) { ::Kubeclient::HttpError.new(404, "namespace #{name} not found", nil) }
it 'returns false' do it 'returns false' do
expect(client).to receive(:get_namespace).with(name).once.and_raise(exception) expect(client).to receive(:get_namespace).with(name).once.and_raise(exception)
......
...@@ -252,7 +252,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching ...@@ -252,7 +252,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
stub_kubeclient_pods(status: 500) stub_kubeclient_pods(status: 500)
end end
it { expect { subject }.to raise_error(KubeException) } it { expect { subject }.to raise_error(Kubeclient::HttpError) }
end end
context 'when kubernetes responds with 404s' do context 'when kubernetes responds with 404s' do
......
...@@ -370,7 +370,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do ...@@ -370,7 +370,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
stub_kubeclient_pods(status: 500) stub_kubeclient_pods(status: 500)
end end
it { expect { subject }.to raise_error(KubeException) } it { expect { subject }.to raise_error(Kubeclient::HttpError) }
end end
context 'when kubernetes responds with 404s' do context 'when kubernetes responds with 404s' do
......
...@@ -34,7 +34,7 @@ describe Clusters::Applications::InstallService do ...@@ -34,7 +34,7 @@ describe Clusters::Applications::InstallService do
context 'when k8s cluster communication fails' do context 'when k8s cluster communication fails' do
before do before do
error = KubeException.new(500, 'system failure', nil) error = Kubeclient::HttpError.new(500, 'system failure', nil)
expect(helm_client).to receive(:install).with(install_command).and_raise(error) expect(helm_client).to receive(:install).with(install_command).and_raise(error)
end 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