Skip to content

Commit c2d496a

Browse files
committed
Ignore ResourceExists errors from bbs_apps_client
- This is a re-implementation of 133486e - This error can be raised by BBS when there is a race condition between the CC syncer and CC API when creating an LRP for a process - Since we want to desire a process anyway, it already existing (with the correct version) is likely not an error case. Thus, we can behave idempotently. - Improvements from previous implementation: - No longer ignores other types of APIErrors in desire_app_handler.rb - No longer coupled to the exact error message coming from BBS
1 parent 81be7c7 commit c2d496a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/cloud_controller/diego/bbs_apps_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def desire_app(process)
1616
logger.info('desire.app.response', process_guid: lrp.process_guid, error: response.error)
1717

1818
runner_invalid_request!(response.error.message) if response.error&.type == ::Diego::Bbs::ErrorTypes::InvalidRequest
19-
return response if response.error&.type == ::Diego::Bbs::ErrorTypes::ResourceConflict
19+
return response if [::Diego::Bbs::ErrorTypes::ResourceConflict, ::Diego::Bbs::ErrorTypes::ResourceExists].include?(response.error&.type)
2020

2121
response
2222
end

spec/unit/lib/cloud_controller/diego/bbs_apps_client_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ module VCAP::CloudController::Diego
5151
end
5252
end
5353

54+
context 'when the bbs response contains a resource exists error' do
55+
let(:lifecycle_error) { ::Diego::Bbs::Models::Error.new(type: ::Diego::Bbs::Models::Error::Type::ResourceExists) }
56+
57+
it 'does not raise error' do
58+
expect { client.desire_app(process) }.not_to raise_error
59+
end
60+
end
61+
5462
context 'when the bbs response contains an invalid request error' do
5563
let(:lifecycle_error) { ::Diego::Bbs::Models::Error.new(type: ::Diego::Bbs::Models::Error::Type::InvalidRequest, message: 'bad request') }
5664

0 commit comments

Comments
 (0)