Skip to content

Commit e98439e

Browse files
RafiaSabihFxKu
andauthored
Add log messages for usernames (zalando#1692)
* add log messages for usernames * document behavior better in logs Co-authored-by: Felix Kunde <[email protected]>
1 parent f9150aa commit e98439e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

docs/user.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,18 @@ other roles.
141141

142142
To define the secrets for the users in a different namespace than that of the
143143
cluster, one can set `enable_cross_namespace_secret` and declare the namespace
144-
for the secrets in the manifest in the following manner,
144+
for the secrets in the manifest in the following manner (note, that it has to
145+
be reflected in the `database` section, too),
145146

146147
```yaml
147148
spec:
148149
users:
149-
#users with secret in dfferent namespace
150-
appspace.db_user:
150+
# users with secret in different namespace
151+
appspace.db_user:
151152
- createdb
153+
databases:
154+
# namespace notation is part of user name
155+
app_db: appspace.db_user
152156
```
153157
154158
Here, anything before the first dot is considered the namespace and the text after
@@ -554,7 +558,8 @@ schema creation. This means they are currently not set when `defaultUsers`
554558
For all LOGIN roles the operator will create K8s secrets in the namespace
555559
specified in `secretNamespace`, if `enable_cross_namespace_secret` is set to
556560
`true` in the config. Otherwise, they are created in the same namespace like
557-
the Postgres cluster.
561+
the Postgres cluster. Unlike roles specified with `namespace.username` under
562+
`users`, the namespace will not be part of the role name here.
558563

559564
```yaml
560565
spec:

pkg/cluster/cluster.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,7 @@ func (c *Cluster) initRobotUsers() error {
11761176
if strings.Contains(username, ".") {
11771177
splits := strings.Split(username, ".")
11781178
namespace = splits[0]
1179+
c.logger.Warningf("enable_cross_namespace_secret is set. Database role name contains the respective namespace i.e. %s is the created user", username)
11791180
}
11801181
}
11811182

0 commit comments

Comments
 (0)