Commit e10e443a authored by Rémy Coutable's avatar Rémy Coutable Committed by Albert Salim

Don't try to delete non-existing K8s resources

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent d99352f7
......@@ -123,6 +123,16 @@ RSpec.describe Tooling::KubernetesClient do
it_behaves_like 'a kubectl command to delete resources by older than given creation time'
end
context 'with no resources found' do
let(:resource_names) { [] }
it 'does not call #delete_by_exact_names' do
expect(subject).not_to receive(:delete_by_exact_names)
subject.cleanup_by_created_at(resource_type: resource_type, created_before: two_days_ago)
end
end
end
describe '#raw_resource_names' do
......
......@@ -22,6 +22,8 @@ module Tooling
def cleanup_by_created_at(resource_type:, created_before:, wait: true)
resource_names = resource_names_created_before(resource_type: resource_type, created_before: created_before)
return if resource_names.empty?
delete_by_exact_names(resource_type: resource_type, resource_names: resource_names, wait: wait)
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