Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/certwatcher/certwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,9 @@ func (cw *CertWatcher) handleEvent(event fsnotify.Event) {
log.Error(err, "error re-reading certificate")
}
}

// NeedLeaderElection indicates that the cert-manager
// does not need leader election.
func (cw *CertWatcher) NeedLeaderElection() bool {
return false
}
7 changes: 7 additions & 0 deletions pkg/certwatcher/certwatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (

"sigs.k8s.io/controller-runtime/pkg/certwatcher"
"sigs.k8s.io/controller-runtime/pkg/certwatcher/metrics"
"sigs.k8s.io/controller-runtime/pkg/manager"
)

var _ = Describe("CertWatcher", func() {
Expand Down Expand Up @@ -92,6 +93,12 @@ var _ = Describe("CertWatcher", func() {
}
})

It("should not require LeaderElection", func() {
leaderElectionRunnable, isLeaderElectionRunnable := any(watcher).(manager.LeaderElectionRunnable)
Expect(isLeaderElectionRunnable).To(BeTrue())
Expect(leaderElectionRunnable.NeedLeaderElection()).To(BeFalse())
})

It("should read the initial cert/key", func() {
// This test verifies the initial read succeeded. So interval doesn't matter.
doneCh := startWatcher(10 * time.Second)
Expand Down