Skip to content

Creating a named service binding results in error #4175

@danail-branekov

Description

@danail-branekov

What happened

  • cf create service sample-service sample-plan myinstance
  • cf bind service myapp myinstance
  • cf bind service myapp myinstance --binding-name mybinding

The last command returns an unexpected error saying that binding with such guid already exists

The same thing happens when I try to create two service keys for the same instance:

  • cf create-service-key myinstance mykey-1
  • cf create-service-key myinstance mykey-2

The second command fails

What was supposed to happen

No error should have occurred. According to cf docs it is possible to create named bindings as well as multiple service keys for the same service instance

Dev Notes

  • The error occurs because we are not taking the binding display name into account when validating the binding creation. This means that we can only ever create a single service binding (no matter if type is "app" or "key")
  • This is how bining uniqueness is established right now:
    func (b CFServiceBinding) UniqueName() string {
    return fmt.Sprintf("sb::%s::%s::%s", b.Spec.AppRef.Name, b.Spec.Service.Namespace, b.Spec.Service.Name)
    }
  • The correct thing to do is to also take the binding name into account
  • We should also introduce a migration that would fix uniqueness contstraints for existing bindings from older deployments

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

Status

✅ Done

Relationships

None yet

Development

No branches or pull requests

Issue actions