Skip to content

Commit d35a876

Browse files
committed
Remove db migration and config parameter
To ensure users cannot run create multiple service bindings during the bosh deployment (when old and new code is running) we need to first introduce the new validation logic so that we can safely remove the unique constraints in the next capi release.
1 parent 2210e7b commit d35a876

File tree

7 files changed

+17
-149
lines changed

7 files changed

+17
-149
lines changed

app/actions/service_credential_binding_app_create.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ def event_repository
109109
end
110110

111111
def max_bindings_per_app_service_instance
112-
VCAP::CloudController::Config.config.get(:max_service_credential_bindings_per_app_service_instance)
112+
1
113+
# NOTE: This is hard-coded to 1 for now to preserve the old uniqueness behavior.
114+
# TODO: Once the DB migration that drops the unique constraints for service bindings has been released,
115+
# this should be switched to read from config:
116+
# VCAP::CloudController::Config.config.get(:max_service_credential_bindings_per_app_service_instance)
117+
# TODO: Also remove skips in related specs.
113118
end
114119

115120
def app_is_required!

db/migrations/20250731071027_allow_multiple_service_bindings.rb

Lines changed: 0 additions & 67 deletions
This file was deleted.

lib/cloud_controller/config_schemas/api_schema.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,6 @@ class ApiSchema < VCAP::Config
409409
optional(:query_raise_on_mismatch) => bool
410410
},
411411

412-
max_service_credential_bindings_per_app_service_instance: Integer,
413-
414412
max_labels_per_resource: Integer,
415413
max_annotations_per_resource: Integer,
416414

lib/cloud_controller/config_schemas/worker_schema.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ class WorkerSchema < VCAP::Config
219219
route_services_enabled: bool,
220220

221221
max_manifest_service_binding_poll_duration_in_seconds: Integer,
222-
max_service_credential_bindings_per_app_service_instance: Integer,
223222

224223
max_labels_per_resource: Integer,
225224
max_annotations_per_resource: Integer,

spec/migrations/20250731071027_allow_multiple_service_bindings_spec.rb

Lines changed: 0 additions & 69 deletions
This file was deleted.

spec/request/service_credential_bindings_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,8 +1276,6 @@ def check_filtered_bindings(*bindings)
12761276

12771277
context 'when only one binding per app and service instance is allowed' do
12781278
before do
1279-
TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1)
1280-
12811279
it 'returns 422 when the binding already exists' do
12821280
api_call.call admin_headers
12831281
expect(last_response.status).to eq(201).or eq(202)

spec/unit/actions/service_credential_binding_app_create_spec.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ module V3
6969
context 'when a binding already exists' do
7070
let!(:binding) { ServiceBinding.make(service_instance:, app:) }
7171

72-
before { TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1) }
72+
# TODO: Once the unique constraints to allow multiple bindings are removed, this needs to be set to 1
73+
# before { TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1) }
7374

7475
context 'when no last binding operation exists' do
7576
it 'raises an error' do
@@ -160,7 +161,8 @@ module V3
160161
end
161162
let(:service_instance2) { ManagedServiceInstance.make(**si_details) }
162163

163-
before { TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1) }
164+
# TODO: Once the unique constraints to allow multiple bindings are removed, this needs to be set to 1
165+
# before { TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1) }
164166

165167
it 'raises an error when the binding name already exists' do
166168
# First request, should succeed
@@ -186,7 +188,8 @@ module V3
186188
)
187189
end
188190

189-
before { TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1) }
191+
# TODO: Once the unique constraints to allow multiple bindings are removed, this needs to be set to 1
192+
# before { TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1) }
190193

191194
it 'raises an error when the app is already bound to the service instance' do
192195
# First request, should succeed
@@ -211,7 +214,8 @@ module V3
211214
let(:binding_1) { ServiceBinding.make(service_instance: service_instance, app: app, name: nil) }
212215

213216
before do
214-
TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1)
217+
# TODO: Once the unique constraints to allow multiple bindings are removed, this needs to be set to 1
218+
# TestConfig.override(max_service_credential_bindings_per_app_service_instance: 1)
215219
binding_1.save_with_attributes_and_new_operation({}, { type: 'create', state: 'succeeded' })
216220
end
217221

@@ -230,10 +234,10 @@ module V3
230234
end
231235

232236
context 'when multiple bindings are allowed' do
233-
let!(:binding_1) { ServiceBinding.make(service_instance:, app:, name:) }
234-
let!(:binding_2) { ServiceBinding.make(service_instance:, app:, name:) }
235-
236237
before do
238+
skip 'this test can be enabled when the service bindings unique constraints are removed and max_bindings_per_app_service_instance can be configured'
239+
binding_1 = ServiceBinding.make(service_instance:, app:, name:)
240+
binding_2 = ServiceBinding.make(service_instance:, app:, name:)
237241
binding_1.save_with_attributes_and_new_operation({}, { type: 'create', state: 'succeeded' })
238242
binding_2.save_with_attributes_and_new_operation({}, { type: 'create', state: 'succeeded' })
239243
end

0 commit comments

Comments
 (0)