Prevent deadlocks when updating managed service instances #2970
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
A service instance was in state "update in progress" but the broker did not receive any request. Retrying the update was not possible (
CF-AsyncServiceInstanceOperationInProgress
).Root cause
Updating the operation (see [1]) and creating the background job ([2]) is done independently. When the latter fails (e.g. database temporarily not available), the so called
UpdaterLock
([3]) is not cleared.Solution
Introduce similar methods as for
ServiceBrokerUpdate
([4]):update_broker_needed?
update_sync
enqueue_update
.Ensure that operation (lock) and delayed job are handled consistently, i.e. when the creation of the job fails, the operation will be set to "failed". This is achieved by moving the creation of the delayed job into the
ServiceInstanceUpdateManaged
action (methodenqueue_update
):[1]
cloud_controller_ng/app/controllers/v3/service_instances_controller.rb
Line 292 in 05f6cd8
[2]
cloud_controller_ng/app/controllers/v3/service_instances_controller.rb
Line 301 in 05f6cd8
[3] https://github.com/cloudfoundry/cloud_controller_ng/blob/main/app/actions/services/locks/updater_lock.rb
[4] https://github.com/cloudfoundry/cloud_controller_ng/blob/main/app/actions/v3/service_broker_update.rb
I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
main
branchI have run all the unit tests using
bundle exec rake
I have run CF Acceptance Tests