You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move service binding uniquness validation into ccng (#4521)
* Move service binding uniqueness validation into ccng
Allows operators to set the number of allowed service bindings via parameter `max_service_credential_bindings_per_app_service_instance`. (currently hard coded to 1)
This will be set to 1 in capi-release to not change the current behavior.
If set to >1 developers can create multiple bindings for the same app and service instance.
This is useful e.g. for rotating the binding credentials without pushing the app again. Restart/restage is sufficient to put the latest binding into the app.
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.
Further details can be found in RFC-0040:
https://github.com/cloudfoundry/community/blob/main/toc/rfc/rfc-0040-service-binding-rotation.md
* Allow only one binding for v2 API
* fix test issues
* Remove db migration and config parameter
e.
* skip tests which require unique constraint removal
* remove config parameter
* Lock service instance to prevent concurrent binding creation
raiseUnprocessableCreate.new("The binding name is invalid. App binding names must be unique. The app already has a binding with name '#{message.name}'.")
49
-
elsife.message.include?('service_instance_guid and app_guid unique')
50
-
raiseUnprocessableCreate.new('The app is already bound to the service instance.')
raiseUnprocessableCreate.new('No app was specified')
92
125
end
@@ -95,6 +128,27 @@ def not_supported!
95
128
raiseUnimplemented.new('Cannot create credential bindings for managed service instances')
96
129
end
97
130
131
+
defbinding_in_progress!(binding_guid)
132
+
raiseUnprocessableCreate.new("There is already a binding in progress for this service instance and app (binding guid: #{binding_guid})")
133
+
end
134
+
135
+
deftoo_many_bindings!
136
+
raiseUnprocessableCreate.new(
137
+
"The app has too many bindings to this service instance (limit: #{max_bindings_per_app_service_instance}). Consider deleting existing/orphaned bindings."
138
+
)
139
+
end
140
+
141
+
defname_cannot_be_changed!
142
+
raiseUnprocessableCreate.new('The binding name cannot be changed for the same app and service instance')
143
+
end
144
+
145
+
defname_uniqueness_violation!(name)
146
+
msg='The binding name is invalid. Binding names must be unique for a given service instance and app.'
147
+
msg += " The app already has a binding with name '#{name}'."unlessname.nil? || name.empty?
148
+
149
+
raiseUnprocessableCreate.new(msg)
150
+
end
151
+
98
152
defalready_bound!
99
153
raiseUnprocessableCreate.new('The app is already bound to the service instance')
validates_unique%i[app_guidservice_instance_guid],message: Sequel.lit('The app is already bound to the service.')
58
-
validates_unique%i[app_guidname],message: Sequel.lit("The binding name is invalid. App binding names must be unique. The app already has a binding with name '#{name}'.")
raiseIncompatibleBindings.new("Bindings exceed the maximum allowed bytesize of #{MAX_ALLOWED_BYTESIZE}: #{total_bytesize}")iftotal_bytesize > MAX_ALLOWED_BYTESIZE
0 commit comments