Skip to content

Commit 58bab07

Browse files
authored
fix searching for users with namespace in name (zalando#1569)
* fix searching for users with namespace in name and improve e2e test * remove reformatting username to query
1 parent b1fab70 commit 58bab07

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

e2e/tests/test_e2e.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -588,47 +588,40 @@ def verify_role():
588588
raise
589589

590590
@timeout_decorator.timeout(TEST_TIMEOUT_SEC)
591-
def test_zz_cross_namespace_secrets(self):
591+
def test_cross_namespace_secrets(self):
592592
'''
593593
Test secrets in different namespace
594594
'''
595-
app_namespace = "appspace"
596-
597-
v1_appnamespace = client.V1Namespace(metadata=client.V1ObjectMeta(name=app_namespace))
598-
self.k8s.api.core_v1.create_namespace(v1_appnamespace)
599-
self.k8s.wait_for_namespace_creation(app_namespace)
595+
k8s = self.k8s
600596

597+
# enable secret creation in separate namespace
601598
patch_cross_namespace_secret = {
602599
"data": {
603600
"enable_cross_namespace_secret": "true"
604601
}
605602
}
606603
self.k8s.update_config(patch_cross_namespace_secret,
607604
step="cross namespace secrets enabled")
605+
self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"},
606+
"Operator does not get in sync")
608607

608+
# create secret in test namespace
609609
self.k8s.api.custom_objects_api.patch_namespaced_custom_object(
610610
'acid.zalan.do', 'v1', 'default',
611611
'postgresqls', 'acid-minimal-cluster',
612612
{
613613
'spec': {
614614
'users':{
615-
'appspace.db_user': [],
615+
'test.db_user': [],
616616
}
617617
}
618618
})
619-
620-
self.eventuallyEqual(lambda: self.k8s.count_secrets_with_label("cluster-name=acid-minimal-cluster,application=spilo", app_namespace),
619+
620+
self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"},
621+
"Operator does not get in sync")
622+
self.eventuallyEqual(lambda: self.k8s.count_secrets_with_label("cluster-name=acid-minimal-cluster,application=spilo", self.test_namespace),
621623
1, "Secret not created for user in namespace")
622624

623-
#reset the flag
624-
unpatch_cross_namespace_secret = {
625-
"data": {
626-
"enable_cross_namespace_secret": "false",
627-
}
628-
}
629-
self.k8s.update_config(unpatch_cross_namespace_secret, step="disable cross namespace secrets")
630-
631-
632625
@timeout_decorator.timeout(TEST_TIMEOUT_SEC)
633626
def test_lazy_spilo_upgrade(self):
634627
'''

pkg/cluster/sync.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ func (c *Cluster) syncStatefulSet() error {
386386
return fmt.Errorf("could not set cluster-wide PostgreSQL configuration options: %v", err)
387387
}
388388

389-
390389
if instancesRestartRequired {
391390
c.logger.Debugln("restarting Postgres server within pods")
392391
c.eventRecorder.Event(c.GetReference(), v1.EventTypeNormal, "Update", "restarting Postgres server within pods")
@@ -623,11 +622,6 @@ func (c *Cluster) syncRoles() (err error) {
623622
// create list of database roles to query
624623
for _, u := range c.pgUsers {
625624
pgRole := u.Name
626-
if u.Namespace != c.Namespace && u.Namespace != "" {
627-
// to avoid the conflict of having multiple users of same name
628-
// but each in different namespace.
629-
pgRole = fmt.Sprintf("%s.%s", u.Name, u.Namespace)
630-
}
631625
userNames = append(userNames, pgRole)
632626
// add team member role name with rename suffix in case we need to rename it back
633627
if u.Origin == spec.RoleOriginTeamsAPI && c.OpConfig.EnableTeamMemberDeprecation {

0 commit comments

Comments
 (0)