-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
K8SPSMDB-1236 Check for custom users name uniqueness #1813
base: main
Are you sure you want to change the base?
Conversation
api "github.com/percona/percona-server-mongodb-operator/pkg/apis/psmdb/v1" | ||
"github.com/percona/percona-server-mongodb-operator/pkg/psmdb/mongo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[goimports-reviser] reported by reviewdog 🐶
api "github.com/percona/percona-server-mongodb-operator/pkg/apis/psmdb/v1" | |
"github.com/percona/percona-server-mongodb-operator/pkg/psmdb/mongo" |
"github.com/percona/percona-server-mongodb-operator/pkg/psmdb/mongo" | ||
"github.com/pkg/errors" | ||
"github.com/stretchr/testify/assert" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[goimports-reviser] reported by reviewdog 🐶
) | |
api "github.com/percona/percona-server-mongodb-operator/pkg/apis/psmdb/v1" | |
"github.com/percona/percona-server-mongodb-operator/pkg/psmdb/mongo" | |
) |
log := logf.FromContext(ctx) | ||
|
||
if sysUserNames == nil || uniqueUserNames == nil { | ||
log.Error(nil, "sys or unique usernames are nil") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need these logs for errors? don't the error we return will be logged as reconciler error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error logs that we see here are only added because they existed also in the existing implementation. More specifically, we used to do something like this
if _, ok := sysUserNames[user.Name]; ok {
log.Error(nil, "creating user with reserved user name is forbidden", "user", user.Name)
continue
}
but now we do this:
err := validateUser(ctx, &user, systemUserNames, uniqueUserNames)
if err != nil {
continue
}
So the answer is that the errors returned are not logged.
We can either keep the implementation as is, or we can add more details to the errors retuned and log a single time when we handle the validateUser
error. Maybe the latter is more clean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit: 12fe253 |
CHANGE DESCRIPTION
Problem:
With this PR, we are improving the user creation flow and we validate on creation time that the users created will be unique in terms of name.
Cause:
Short explanation of the root cause of the issue if applicable.
Solution:
Short explanation of the solution we are providing with this PR.
CHECKLIST
Jira
Needs Doc
) and QA (Needs QA
)?Tests
compare/*-oc.yml
)?Config/Logging/Testability