google/sql: naming collision for `SQLDatabase` if multiple applications in the same namespace have defined the same database name
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.
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.
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.
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.
Duplikat av https://github.com/nais/naiserator/issues/421
Fixed in 37414e071338a13f3b7d045837703a5e3f1fca7e and others.