-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
add controller to regenerate service serving certs #12050
add controller to regenerate service serving certs #12050
Conversation
Also, there should probably be a card on the platform board. |
[test] |
// Run begins watching and syncing. | ||
func (sc *ServiceServingCertUpdateController) Run(workers int, stopCh <-chan struct{}) { | ||
defer utilruntime.HandleCrash() | ||
defer glog.Infof("Shutting down service signing cert update controller") |
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 also have the "Starting" message?
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.
Sure
// syncedPollPeriod controls how often you look at the status of your sync funcs | ||
const syncedPollPeriod = 100 * time.Millisecond | ||
|
||
func waitForCacheSync(stopCh <-chan struct{}, cacheSyncs ...informerSynced) bool { |
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.
you mean this one is in kube right?
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
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.
@ncdc fyi, to be removed after 1.5 rebase
@php-coder or @enj PTAL |
@deads2k will create a card |
@@ -41,6 +41,8 @@ const ( | |||
// ServiceNameAnnotation is an annotation on a secret that indicates which service created it, by Name to allow reverse lookups on services | |||
// for comparison against UIDs | |||
ServiceNameAnnotation = "service.alpha.openshift.io/originating-service-name" | |||
// ServingCertExpiryAnnotation is an annotation that holds the expiry time of the certificate | |||
ServingCertExpiryAnnotation = "service.alpha.openshift.io/expiry" |
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 the annotation mention certificate-expiry or certificate-expiration-days ?
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.
Not days, but I could call it certificate-expiry
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.
Can you also document the format that is supported as a value?
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.
Overall this looks good, but although there's a integration tests for the flow I still would like to see a unit test for the controller.
// syncedPollPeriod controls how often you look at the status of your sync funcs | ||
const syncedPollPeriod = 100 * time.Millisecond | ||
|
||
func waitForCacheSync(stopCh <-chan struct{}, cacheSyncs ...informerSynced) bool { |
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.
@ncdc fyi, to be removed after 1.5 rebase
} | ||
|
||
func (sc *ServiceServingCertUpdateController) runWorker() { | ||
for sc.processNextWorkItem() { |
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 must admit I dislike this new form, but that doesn't matter here 😉 I find the body here being much more readable than almost empty for-loop with almost empty method calling another method.
return true | ||
} | ||
|
||
if expiry.Add(sc.minTimeLeftForCert).After(time.Now()) { |
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.
Is this a correct calculation?
As far I understand certificate requires regeneration if now > (expiration date - 1h)
IOW we'll update certificate if it expires in next hour. But here we're adding 1 hour instead of subtracting it. What I'm missing here?
Also: why 1 hour if we're checking each 20 minutes?
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.
Is this a correct calculation?
As far I understand certificate requires regeneration if now > (expiration date - 1h) IOW we'll update certificate if it expires in next hour. But here we're adding 1 hour instead of subtracting it. What I'm missing here?
Also: why 1 hour if we're checking each 20 minutes?
heh, backwards. I'll add @soltysh unit test and catch it. :)
The 1 hour is a place holder for something more reasonable driven off a "real" expiry time. I suspect we'll have an upper bound too to eliminate all long lived tokens.
ca *crypto.CA | ||
publicCert string | ||
dnsSuffix string | ||
minTimeLeftForCert time.Duration |
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.
This deserves its own comment
ff2658e
to
75e1bd8
Compare
comments addressed. |
75e1bd8
to
663a5ef
Compare
Evaluated for origin test up to 663a5ef |
continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11785/) (Base Commit: 7ec2f67) |
I'm betting on a flake. Any other comments? |
LGTM |
[merge] |
Flake #11024. re-[merge] |
Evaluated for origin merge up to 663a5ef |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11858/) (Base Commit: ff5bd5a) (Image: devenv-rhel7_5456) |
Adds a controller to update service serving certs when they are about to expire.
@mfojtik for review distribution