CLOUDP-130487 fixed operator crash in face of incomplete TLS config #1115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
When TLS is enabled with an incomplete configuration (i.e. none of
caConfigMapRef
andcaCertificateSecretRef
is specified), the operator crashes. Upon inspection of the operator error log, we find that the crash happens when the operator isEnsuring TLS is correctly configured
as it results in a segmentation fault due to a nil pointer reference.It seems that this null pointer exception occurs while ensuring that the CA cert is configured during TLS config validation when the following condition is checked:
Since
Spec.Security.TLS.CaCertificateSecret
is set to nil,mdb.TLSConfigMapNamespacedName
is called:However,
Spec.Security.TLS.CaConfigMap
is also nil, so when theName
field is accessed a runtime error occurs as a nil pointer is dereferenced.What changes were made and how does it work?
Currently, there is no validation for TLS spec:
I think we can include the following condition in the above code along with the function definition 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).