-
Notifications
You must be signed in to change notification settings - Fork 718
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
Use cert rotate parameter #2541
Changes from all commits
e2fca99
25deaf9
f170bb5
1b9c4da
67b7108
96165ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,8 @@ func Reconcile( | |
d driver.Interface, | ||
kb kbv1.Kibana, | ||
services []corev1.Service, | ||
rotation certificates.RotationParams, | ||
caRotation certificates.RotationParams, | ||
certRotation certificates.RotationParams, | ||
) *reconciler.Results { | ||
span, _ := apm.StartSpan(ctx, "reconcile_certs", tracing.SpanTypeApp) | ||
defer span.End() | ||
|
@@ -48,15 +49,15 @@ func Reconcile( | |
&kb, | ||
labels, | ||
certificates.HTTPCAType, | ||
rotation, | ||
caRotation, | ||
) | ||
if err != nil { | ||
return results.WithError(err) | ||
} | ||
|
||
// handle CA expiry via requeue | ||
results.WithResult(reconcile.Result{ | ||
RequeueAfter: certificates.ShouldRotateIn(time.Now(), httpCa.Cert.NotAfter, rotation.RotateBefore), | ||
RequeueAfter: certificates.ShouldRotateIn(time.Now(), httpCa.Cert.NotAfter, caRotation.RotateBefore), | ||
}) | ||
|
||
// discover and maybe reconcile for the http certificates to use | ||
|
@@ -68,11 +69,20 @@ func Reconcile( | |
kb.Spec.HTTP.TLS, | ||
labels, | ||
services, | ||
rotation, // todo correct rotation | ||
certRotation, | ||
) | ||
if err != nil { | ||
return results.WithError(err) | ||
} | ||
|
||
primaryCert, err := certificates.GetPrimaryCertificate(httpCertificates.CertPem()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a bit unfortunate that we have to parse the PEM again that we just parsed and or encoded in the reconcile function. But I guess changing this would be a larger refactoring of our certificate generation logic, so happy to track this in a follow up task. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I wasn't very happy about it, but the needs of both of them are discrete enough (one needs to construct the whole chain, the other just needs the expiration date of one cert) that I couldn't think of a better way to fix it without a larger scale change. One option might be for |
||
if err != nil { | ||
return results.WithError(err) | ||
} | ||
results.WithResult(reconcile.Result{ | ||
RequeueAfter: certificates.ShouldRotateIn(time.Now(), primaryCert.NotAfter, certRotation.RotateBefore), | ||
}) | ||
|
||
// reconcile http public cert secret | ||
results.WithError(http.ReconcileHTTPCertsPublicSecret(d.K8sClient(), d.Scheme(), &kb, name.KBNamer, httpCertificates)) | ||
return &results | ||
|
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.
Should we also make that call for the other certs?
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 am not sure I follow your comment here @sebgl. Do you mean we should requeue within the validity period of the individual certificates and not just before the CA expires?
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.
Yeah I mean also requeueing after we reconcile HTTP certificates below. Since we have
caRotation
andcertRotation
that can be different, it would make sense to make sure we requeue before any of these are reached? Maybe I'm missing something here.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.
Should we not requeue on the minimum of the two?
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.
Yes! That's why I thought we would call
results.WithResult ()
twice (one for CA, one for cert 10 lines below), and then we let the results aggregation do its job of picking the most appropriate requeue?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.
SGTM (I always forget that we already pick the shortest requeue in the aggregation)