Sync other way around
This commit is contained in:
parent
2e023799e1
commit
c0a840c3ed
|
|
@ -413,17 +413,13 @@ func (c *Cluster) syncSecrets() error {
|
||||||
} else if secretUsername == c.systemUsers[constants.ReplicationUserKeyName].Name {
|
} else if secretUsername == c.systemUsers[constants.ReplicationUserKeyName].Name {
|
||||||
secretUsername = constants.ReplicationUserKeyName
|
secretUsername = constants.ReplicationUserKeyName
|
||||||
userMap = c.systemUsers
|
userMap = c.systemUsers
|
||||||
} else if secretUsername == c.systemUsers[constants.ConnectionPoolUserKeyName].Name {
|
|
||||||
secretUsername = constants.ConnectionPoolUserKeyName
|
|
||||||
userMap = c.systemUsers
|
|
||||||
} else {
|
} else {
|
||||||
userMap = c.pgUsers
|
userMap = c.pgUsers
|
||||||
}
|
}
|
||||||
pwdUser := userMap[secretUsername]
|
pwdUser := userMap[secretUsername]
|
||||||
// if this secret belongs to the infrastructure role and the password has changed - replace it in the secret
|
// if this secret belongs to the infrastructure role and the password has changed - replace it in the secret
|
||||||
if pwdUser.Password != string(secret.Data["password"]) &&
|
if pwdUser.Password != string(secret.Data["password"]) &&
|
||||||
(pwdUser.Origin == spec.RoleOriginInfrastructure ||
|
pwdUser.Origin == spec.RoleOriginInfrastructure {
|
||||||
pwdUser.Origin == spec.RoleConnectionPool) {
|
|
||||||
|
|
||||||
c.logger.Debugf("updating the secret %q from the infrastructure roles", secretSpec.Name)
|
c.logger.Debugf("updating the secret %q from the infrastructure roles", secretSpec.Name)
|
||||||
if _, err = c.KubeClient.Secrets(secretSpec.Namespace).Update(secretSpec); err != nil {
|
if _, err = c.KubeClient.Secrets(secretSpec.Namespace).Update(secretSpec); err != nil {
|
||||||
|
|
@ -472,7 +468,10 @@ func (c *Cluster) syncRoles() (err error) {
|
||||||
if c.needConnectionPool() {
|
if c.needConnectionPool() {
|
||||||
connPoolUser := c.systemUsers[constants.ConnectionPoolUserKeyName]
|
connPoolUser := c.systemUsers[constants.ConnectionPoolUserKeyName]
|
||||||
userNames = append(userNames, connPoolUser.Name)
|
userNames = append(userNames, connPoolUser.Name)
|
||||||
c.pgUsers[connPoolUser.Name] = connPoolUser
|
|
||||||
|
if _, exists := c.pgUsers[constants.ConnectionPoolUserKeyName]; !exists {
|
||||||
|
c.pgUsers[connPoolUser.Name] = connPoolUser
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dbUsers, err = c.readPgUsersFromDatabase(userNames)
|
dbUsers, err = c.readPgUsersFromDatabase(userNames)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue