Validate lock identity

Ensure that the lock identity is not empty. This can cause unexpected issues during leader election.

Kubernetes-commit: 5519b89a28eeea5a5b134092242aff770fcc07eb
This commit is contained in:
Johan Oskarsson
2023-05-16 09:41:18 -07:00
committed by Kubernetes Publisher
parent 151a5919db
commit 0011bf6b0b
2 changed files with 42 additions and 0 deletions

View File

@@ -99,6 +99,11 @@ func NewLeaderElector(lec LeaderElectionConfig) (*LeaderElector, error) {
if lec.Lock == nil {
return nil, fmt.Errorf("Lock must not be nil.")
}
id := lec.Lock.Identity()
if id == "" {
return nil, fmt.Errorf("Lock identity is empty")
}
le := LeaderElector{
config: lec,
clock: clock.RealClock{},