-
Notifications
You must be signed in to change notification settings - Fork 727
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
Fix transport certificates reconciliation #2740
Conversation
Commit 174e09b introduced a regression by using the generic secret reconciler when we first create the transport certs secret. This secret reconciliation is rather special, since it ensures the secret exists (before Pods are created), but does not care about its data (since we don't have Pods IPs yet). If an existing secret has some data already, we must make sure we don't clear it. Which is what the generic reconciler would do. This commit basically restores the code as it existed before the refactoring in 174e09b, and adds a unit test to catch the regression.
@@ -120,7 +122,7 @@ func ReconcileTransportCertificatesSecrets( | |||
func ensureTransportCertificatesSecretExists( | |||
c k8s.Client, | |||
es esv1.Elasticsearch, | |||
) (corev1.Secret, error) { | |||
) (*corev1.Secret, 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.
I'm not very fond of returning pointers when not required (it introduces doubt: should we check for nil
?), but for the sake of "just fixing the regression" I re-introduced the code as it was before 174e09b.
@@ -104,7 +106,7 @@ func ReconcileTransportCertificatesSecrets( | |||
} | |||
|
|||
if !reflect.DeepEqual(secret, currentTransportCertificatesSecret) { | |||
if err := c.Update(&secret); err != nil { | |||
if err := c.Update(secret); err != 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.
I think this is the place where we could potentially benefit from the generic secret reconciler, but it requires a bit more work. I'll open a follow-up issue.
Jenkins test this please |
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.
Good catch, completely forgot and missed the logic behind this Secret when I did the review 🤦♂
Jenkins test this please |
Commit 174e09b introduced a regression
by using the generic secret reconciler when we first create the
transport certs secret.
This secret reconciliation is rather special, since it ensures the
secret exists (before Pods are created), but does not care about its
data (since we don't have Pods IPs yet).
If an existing secret has some data already, we must make sure we don't
clear it. Which is what the generic reconciler would do.
This commit basically restores the code as it existed before the
refactoring in 174e09b, and adds a unit
test to catch the regression.