Skip to content

Lock app when creating service bindings#4577

Merged
philippthun merged 1 commit into
cloudfoundry:mainfrom
sap-contributions:lock-app-when-creating-service-bindings
Oct 6, 2025
Merged

Lock app when creating service bindings#4577
philippthun merged 1 commit into
cloudfoundry:mainfrom
sap-contributions:lock-app-when-creating-service-bindings

Conversation

@philippthun
Copy link
Copy Markdown
Member

@philippthun philippthun commented Sep 25, 2025

A FOR UPDATE lock on the app instance together with checks implemented in Ruby ensure the same behavior as two unique constraints on database level, which need to be removed to support multiple bindings between an app and a service instance.

The two checks are:

  • the number of bindings from an app to a service instance is below the configured limit
  • no other binding (to another service instance) for this app has the same name

The validate_app_guid_name_uniqueness! method has been moved after the validation of already existing bindings - this simplifies its implementation.

Method incomplete_deletion! raises a different (more precise) error when multiple bindings are active.

Some unused methods have been removed.

A test in spec/request/service_credential_bindings_spec.rb was not executed (it inside before).

Tests in spec/unit/actions/service_credential_binding_app_create_spec.rb have been reworked for consistence. Some unneeded (redundant) tests have been removed.

  • 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 branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

A "FOR UPDATE" lock on the app instance together with checks implemented
in Ruby ensure the same behavior as two unique constraints on database
level, which need to be removed to support multiple bindings between an
app and a service instance.

The two checks are:
- the number of bindings from an app to a service instance is below the
  configured limit
- no other binding (to another service instance) for this app has the
  same name

The validate_app_guid_name_uniqueness! method has been moved after the
validation of already existing bindings - this simplifies its
implementation.

Method incomplete_deletion! raises a different (more precise) error when
multiple bindings are active.

Some unused methods have been removed.

A test in spec/request/service_credential_bindings_spec.rb was not
executed ('it' inside 'before').

Tests in spec/unit/actions/service_credential_binding_app_create_spec.rb
have been reworked for consistence. Some unneeded (redundant) tests have
been removed.
@philippthun philippthun force-pushed the lock-app-when-creating-service-bindings branch from 7f1b316 to 046be38 Compare September 29, 2025 09:31
@philippthun philippthun marked this pull request as ready for review September 29, 2025 11:17
@philippthun philippthun merged commit cf40b64 into cloudfoundry:main Oct 6, 2025
18 of 23 checks passed
ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request Oct 6, 2025
Changes in cloud_controller_ng:

- Ignore extra fields in BbsAppsClient test
    PR: cloudfoundry/cloud_controller_ng#4594
    Author: Philipp Thun <philipp.thun@sap.com>

- Lock app when creating service bindings
    PR: cloudfoundry/cloud_controller_ng#4577
    Author: Philipp Thun <philipp.thun@sap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants