Skip to content

Commit dd09c3f

Browse files
committed
pkg/start/start_integration_test: Do not assume "deleted" for ConfigMap lock release
From the godocs: $ grep -A5 '// HolderIdentity' vendor/k8s.io/client-go/tools/leaderelection/resourcelock/interface.go // HolderIdentity is the ID that owns the lease. If empty, no one owns this lease and // all callers may acquire. Versions of this library prior to Kubernetes 1.14 will not // attempt to acquire leases with empty identities and will wait for the full lease // interval to expire before attempting to reacquire. This value is set to empty when // a client voluntarily steps down. HolderIdentity string `json:"holderIdentity"` The previous assumption that the release would involve ConfigMap deletion was born with the test in 2b81f47 (cvo: Release our leader lease when we are gracefully terminated, 2019-01-16, #87).
1 parent cc1921d commit dd09c3f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pkg/start/start_integration_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ func TestIntegrationCVO_gracefulStepDown(t *testing.T) {
560560

561561
// wait until the lock record exists
562562
err = wait.PollImmediate(200*time.Millisecond, 60*time.Second, func() (bool, error) {
563-
_, err := kc.CoreV1().ConfigMaps(ns).Get(ctx, ns, metav1.GetOptions{})
563+
_, _, err := lock.Get(ctx)
564564
if err != nil {
565565
if errors.IsNotFound(err) {
566566
return false, nil
@@ -582,26 +582,26 @@ func TestIntegrationCVO_gracefulStepDown(t *testing.T) {
582582
t.Fatalf("no leader election events found in\n%#v", events.Items)
583583
}
584584

585-
t.Logf("after the context is closed, the lock record should be deleted quickly")
585+
t.Logf("after the context is closed, the lock should be released quickly")
586586
cancel()
587587
startTime := time.Now()
588588
var endTime time.Time
589589
// the lock should be deleted immediately
590590
err = wait.PollImmediate(100*time.Millisecond, 10*time.Second, func() (bool, error) {
591-
_, err := kc.CoreV1().ConfigMaps(ns).Get(ctx, ns, metav1.GetOptions{})
592-
if errors.IsNotFound(err) {
593-
endTime = time.Now()
594-
return true, nil
595-
}
591+
electionRecord, _, err := lock.Get(ctx)
596592
if err != nil {
593+
if errors.IsNotFound(err) {
594+
return false, nil
595+
}
597596
return false, err
598597
}
599-
return false, nil
598+
endTime = time.Now()
599+
return electionRecord.HolderIdentity == "", nil
600600
})
601601
if err != nil {
602602
t.Fatal(err)
603603
}
604-
t.Logf("lock deleted in %s", endTime.Sub(startTime))
604+
t.Logf("lock released in %s", endTime.Sub(startTime))
605605

606606
select {
607607
case <-time.After(time.Second):

0 commit comments

Comments
 (0)