Skip to content

Commit

Permalink
Tests pass
Browse files Browse the repository at this point in the history
Signed-off-by: James Sturtevant <[email protected]>
  • Loading branch information
jsturtevant committed Mar 14, 2024
1 parent 9edfe5f commit 2dd1e8a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
16 changes: 8 additions & 8 deletions admission-webhook/cert_reloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (cr *CertReloader) GetCertificateFunc() func(*tls.ClientHelloInfo) (*tls.Ce
}

func watchCertFiles(certLoader CertLoader) {
logrus.Infof("Starting certificate watcher on path %v and %v", certLoader.CertPath(), certLoader.KeyPath())
watcher, err := fsnotify.NewWatcher()
if err != nil {
logrus.Errorf("error creating watcher: %v", err)
Expand All @@ -69,16 +70,15 @@ func watchCertFiles(certLoader CertLoader) {
select {
case event, ok := <-watcher.Events:
if !ok {
logrus.Errorf("watcher events returned !ok: %v", err)
return
}
if event.Op&fsnotify.Write == fsnotify.Write || event.Op&fsnotify.Rename == fsnotify.Rename {
logrus.Infof("detected change in certificate file: %v", event.Name)
_, err := certLoader.LoadCertificate()
if err != nil {
logrus.Errorf("error reloading certificate: %v", err)
} else {
logrus.Infof("successfully reloaded certificate")
}
logrus.Infof("detected change in certificate file: %v", event.Name)
_, err := certLoader.LoadCertificate()
if err != nil {
logrus.Errorf("error reloading certificate: %v", err)
} else {
logrus.Infof("successfully reloaded certificate")
}
case err, ok := <-watcher.Errors:
if !ok {
Expand Down
4 changes: 4 additions & 0 deletions admission-webhook/integration_tests/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ func TestPossibleToUpdatePodWithNewCert(t *testing.T) {
t.Skip("Non chart deployment method not supported")
}

//give a few mins to settle rotation
// TODO why is this needed?!
time.Sleep(120 * time.Second)

testName2 := testName + "after-rotation"
testConfig2, tearDownFunc2 := integrationTestSetup(t, testName2, credSpecTemplates, templates)
defer tearDownFunc2()
Expand Down
1 change: 1 addition & 0 deletions admission-webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func (webhook *webhook) start(port int, tlsConfig *tlsConfig, listeningChan chan
err = webhook.server.Serve(keepAliveListener)
} else {
if webhook.config.EnableCertReload {
logrus.Infof("Webhook certificate reload enabled")
certReloader := NewCertReloader(tlsConfig.crtPath, tlsConfig.keyPath)
_, err = certReloader.LoadCertificate()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions charts/gmsa/templates/issuer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ spec:
{{- if .Values.certificates.certReload.enabled }}
privateKey:
rotationPolicy: Always
isCA: true
{{- end }}
---
{{ template "cert-manager.apiversion" . }}
Expand Down

0 comments on commit 2dd1e8a

Please sign in to comment.