K8SPSMDB-1387 certmanager --enable-certificate-owner-ref option causes no startup of any mongodb clusters#1850
Conversation
e219161 to
227c0fe
Compare
egegunes
left a comment
There was a problem hiding this comment.
few comments.
also I wonder if we need to set this flag while deploying cert-manager in our tests
pkg/psmdb/tls/certmanager.go
Outdated
| return "", errors.Wrap(err, "set controller reference") | ||
| switch errors.Cause(err).(type) { | ||
| case *controllerutil.AlreadyOwnedError: | ||
| fmt.Sprintf("%s", err) |
There was a problem hiding this comment.
should we return error here?
pkg/psmdb/tls/certmanager.go
Outdated
| return errors.Wrap(err, "set controller reference") | ||
| switch errors.Cause(err).(type) { | ||
| case *controllerutil.AlreadyOwnedError: | ||
| fmt.Sprintf("%s", err) |
There was a problem hiding this comment.
should we return error here?
pkg/psmdb/tls/certmanager.go
Outdated
| } | ||
| if err = controllerutil.SetControllerReference(cr, secret, c.scheme); err != nil { | ||
| return errors.Wrap(err, "set controller reference") | ||
| switch errors.Cause(err).(type) { |
There was a problem hiding this comment.
@gkech wdyt of this errors.Cause maybe we should check with errors.Is?
There was a problem hiding this comment.
yes it is better @egegunes
@Demch1k let's use errors.Is and also, let's drop switch since it is not needed, so the following for all cases.
if err = controllerutil.SetControllerReference(cr, secret, c.scheme); err != nil {
if errors.Is(err, &controllerutil.AlreadyOwnedError{}) {
return errors.Wrap(err, "set owner reference")
}
return errors.Wrap(err, "set controller reference")
}
|
seems like we will need to take this over, i'm moving this to next release |
To fix the issue, we only need to modify the `WaitForCert` method by adding a check to see if the secret has a controller reference to a certificate
|
@pooknull Could you approve this PR? |
|
|
commit: 164edc2 |
|
@Demch1k Thank you for your contribution. |
CHANGE DESCRIPTION
https://perconadev.atlassian.net/browse/K8SPSMDB-1387
Problem:
We have enabled --enable-certificate-owner-ref for certmanager and after that mongodb operator can not startup any mongodb clusters.
Cause:
Mongodb operator return error when can't update owner references for certificates recources. But with --enable-certificate-owner-ref certmanager do it by itselfs.
Solution:
Catch error connected with already exists owner ref and jus print it out
CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability