Skip creation of OwnerReference if user is in a different namespace (#2912)

Instead of doing a string compare on the username, check the actual namespace of the user to determine if an owner reference can be created.
This commit is contained in:
Morten Lied Johansen 2025-09-17 15:57:36 +02:00 committed by GitHub
parent fa4bc21538
commit ad7e590916
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -1928,7 +1928,7 @@ func (c *Cluster) generateSingleUserSecret(pgUser spec.PgUser) *v1.Secret {
// if secret lives in another namespace we cannot set ownerReferences
var ownerReferences []metav1.OwnerReference
if c.Config.OpConfig.EnableCrossNamespaceSecret && strings.Contains(username, ".") {
if c.Config.OpConfig.EnableCrossNamespaceSecret && c.Postgresql.ObjectMeta.Namespace != pgUser.Namespace {
ownerReferences = nil
} else {
ownerReferences = c.ownerReferences()