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

add controller to regenerate service serving certs #12050

Merged
merged 1 commit into from
Dec 1, 2016

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Nov 28, 2016

Adds a controller to update service serving certs when they are about to expire.

@mfojtik for review distribution

@deads2k
Copy link
Contributor Author

deads2k commented Nov 28, 2016

Also, there should probably be a card on the platform board.

@deads2k
Copy link
Contributor Author

deads2k commented Nov 28, 2016

[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")
Copy link
Contributor

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?

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor

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

@mfojtik
Copy link
Contributor

mfojtik commented Nov 28, 2016

@php-coder or @enj PTAL

@mfojtik
Copy link
Contributor

mfojtik commented Nov 28, 2016

@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"
Copy link
Contributor

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 ?

Copy link
Contributor Author

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

Copy link
Contributor

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?

@mfojtik
Copy link
Contributor

mfojtik commented Nov 29, 2016

@soltysh soltysh assigned soltysh and unassigned mfojtik Nov 29, 2016
Copy link
Contributor

@soltysh soltysh left a 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 {
Copy link
Contributor

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

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

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?

Copy link
Contributor Author

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

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

@deads2k deads2k force-pushed the serving-cert-01-refresh branch from ff2658e to 75e1bd8 Compare November 29, 2016 17:55
@deads2k
Copy link
Contributor Author

deads2k commented Nov 29, 2016

comments addressed.

@deads2k deads2k force-pushed the serving-cert-01-refresh branch from 75e1bd8 to 663a5ef Compare November 29, 2016 20:05
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 663a5ef

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11785/) (Base Commit: 7ec2f67)

@deads2k
Copy link
Contributor Author

deads2k commented Nov 30, 2016

I'm betting on a flake. Any other comments?

@0xmichalis
Copy link
Contributor

LGTM

@deads2k
Copy link
Contributor Author

deads2k commented Nov 30, 2016

[merge]

@soltysh
Copy link
Contributor

soltysh commented Dec 1, 2016

Flake #11024.

re-[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 663a5ef

@openshift-bot
Copy link
Contributor

openshift-bot commented Dec 1, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11858/) (Base Commit: ff5bd5a) (Image: devenv-rhel7_5456)

@openshift-bot openshift-bot merged commit 3bab31d into openshift:master Dec 1, 2016
@deads2k deads2k deleted the serving-cert-01-refresh branch February 3, 2017 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants