-
Notifications
You must be signed in to change notification settings - Fork 510
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
CLOUDP-130486 fix operator crash due to empty modes array #1116
CLOUDP-130486 fix operator crash due to empty modes array #1116
Conversation
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.
Waiting for the author to address the comments mentioned in the inline review.
@slaskawi Hi, we were wondering what is the final desired behavior of handling this case? Falling back to default makes sense, but we were wondering if this validation function is the correct place to defaulting? Seems |
0cf8664
to
28cb3e0
Compare
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 code LGTM. However it would be great to make the warning message a bit more verbose and a bit more descriptive.
The other bits are fine.
@hoyhbx Yes, precisely! |
Integrated, thanks @hoyhbx |
What problem does this PR solve?
This PR closes closes #1055.
When
spec.security.modes
field is set to an empty array, the operator crashes. Upon inspection of the operator error log, we find that the crash happens when the operator isValidating MongoDB.Spec
as it results in a index out of range [0] with length 0 runtime error.It seems that when setting the
autoAuthMechanism
the operator tries to assign the first authentication mode at the 0th index of the Modes array. Since the array is empty, the index is out of range.What changes were made?
During validation of the
authModeSpec
, in addition to checking for duplicates, we can include an additional check as part ofvalidateAuthModeSpec
in controllers/validation/validation.go:Code changes
Tests
This is a simple fix and we suppose no test above is needed.
Side effects
Related changes
All Submissions:
closes #XXXX
in your comment to auto-close the issue that your PR fixes (if such).