naiserator icon indicating copy to clipboard operation
naiserator copied to clipboard

google/sql: naming collision for `SQLDatabase` if multiple applications in the same namespace have defined the same database name

Open tronghn opened this issue 2 years ago • 3 comments

An Application must specify the database name by specifying .spec.gcp.sqlInstances[].databases[].name:

https://github.com/nais/liberator/blob/c3d6aeb3b6d36e7642898b0035e931d0d6e5e70f/pkg/apis/nais.io/v1/naiserator_types.go#L495-L499

If two or more separate Applications in the same namespace inadvertently specify the same name for the database, naiserator will only create a SQLDatabase resource for the first Application that is deployed:

https://github.com/nais/naiserator/blob/fb0a723fc63e9b468fd283a85080f31dda5c1361/pkg/resourcecreator/google/sql/instance.go#L267-L270

We could probably solve this by using a combination of the SQL instance and SQL database name as the .metadata.name and then set the database name in the .spec.resourceID field. See also https://cloud.google.com/config-connector/docs/reference/resource-docs/sql/sqldatabase#custom_resource_definition_properties.

tronghn avatar Aug 01 '23 13:08 tronghn

tl;dr collisions happen rarely because we don't support multiple db's per app (even though the spec might hint that we do).

e.g. app A and B sets db name to foo - will result in the second app not getting any db.

kimtore avatar Mar 13 '24 13:03 kimtore

The multiple sqlinstances non-feature is being removed with the work on sqeletor. Closing this since the mechanism that generetas the issue is going away.

Reasonable-Solutions avatar Apr 15 '24 08:04 Reasonable-Solutions

No, not quite. This issue is adjacent to the initiative for sqeletor, but not directly solved by it. I've attempted to clarify the description above.

tronghn avatar Apr 17 '24 07:04 tronghn

Duplikat av https://github.com/nais/naiserator/issues/421

Kyrremann avatar May 28 '24 13:05 Kyrremann

Fixed in 37414e071338a13f3b7d045837703a5e3f1fca7e and others.

kimtore avatar May 30 '24 08:05 kimtore