Skip to content
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

Merged
merged 1 commit into from
Mar 20, 2020

Conversation

sebgl
Copy link
Contributor

@sebgl sebgl commented Mar 20, 2020

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.

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.
@sebgl sebgl added >bug Something isn't working v1.1.0 labels Mar 20, 2020
@@ -120,7 +122,7 @@ func ReconcileTransportCertificatesSecrets(
func ensureTransportCertificatesSecretExists(
c k8s.Client,
es esv1.Elasticsearch,
) (corev1.Secret, error) {
) (*corev1.Secret, error) {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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.

@sebgl
Copy link
Contributor Author

sebgl commented Mar 20, 2020

Jenkins test this please

Copy link
Contributor

@barkbay barkbay left a 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 🤦‍♂

@sebgl
Copy link
Contributor Author

sebgl commented Mar 20, 2020

Jenkins test this please

@sebgl sebgl merged commit cb77028 into elastic:master Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug Something isn't working v1.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants