Skip to content

Commit 758af11

Browse files
authored
Merge pull request kubernetes#78778 from hbagdi/fix/nil-functions
fix nil function invocation in client-go/tools/leaderelection
2 parents 4f15c01 + 9dbbc65 commit 758af11

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

staging/src/k8s.io/client-go/tools/leaderelection/leaderelection.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ func NewLeaderElector(lec LeaderElectionConfig) (*LeaderElector, error) {
8989
if lec.RetryPeriod < 1 {
9090
return nil, fmt.Errorf("retryPeriod must be greater than zero")
9191
}
92+
if lec.Callbacks.OnStartedLeading == nil {
93+
return nil, fmt.Errorf("OnStartedLeading callback must not be nil")
94+
}
95+
if lec.Callbacks.OnStoppedLeading == nil {
96+
return nil, fmt.Errorf("OnStoppedLeading callback must not be nil")
97+
}
9298

9399
if lec.Lock == nil {
94100
return nil, fmt.Errorf("Lock must not be nil.")

0 commit comments

Comments
 (0)