@@ -22,12 +22,12 @@ import (
22
22
23
23
"github.com/blang/semver/v4"
24
24
v1 "k8s.io/api/coordination/v1"
25
- v1beta1 "k8s.io/api/coordination/v1beta1 "
25
+ v1alpha2 "k8s.io/api/coordination/v1alpha2 "
26
26
"k8s.io/utils/clock"
27
27
)
28
28
29
- func pickBestLeaderOldestEmulationVersion (candidates []* v1beta1 .LeaseCandidate ) * v1beta1 .LeaseCandidate {
30
- var electee * v1beta1 .LeaseCandidate
29
+ func pickBestLeaderOldestEmulationVersion (candidates []* v1alpha2 .LeaseCandidate ) * v1alpha2 .LeaseCandidate {
30
+ var electee * v1alpha2 .LeaseCandidate
31
31
for _ , c := range candidates {
32
32
if ! validLeaseCandidateForOldestEmulationVersion (c ) {
33
33
continue
@@ -39,7 +39,7 @@ func pickBestLeaderOldestEmulationVersion(candidates []*v1beta1.LeaseCandidate)
39
39
return electee
40
40
}
41
41
42
- func pickBestStrategy (candidates []* v1beta1 .LeaseCandidate ) (v1.CoordinatedLeaseStrategy , error ) {
42
+ func pickBestStrategy (candidates []* v1alpha2 .LeaseCandidate ) (v1.CoordinatedLeaseStrategy , error ) {
43
43
nilStrategy := v1 .CoordinatedLeaseStrategy ("" )
44
44
if len (candidates ) == 0 {
45
45
return nilStrategy , fmt .Errorf ("no candidates" )
@@ -62,7 +62,7 @@ func pickBestStrategy(candidates []*v1beta1.LeaseCandidate) (v1.CoordinatedLease
62
62
return strategy , nil
63
63
}
64
64
65
- func validLeaseCandidateForOldestEmulationVersion (l * v1beta1 .LeaseCandidate ) bool {
65
+ func validLeaseCandidateForOldestEmulationVersion (l * v1alpha2 .LeaseCandidate ) bool {
66
66
_ , err := semver .ParseTolerant (l .Spec .EmulationVersion )
67
67
if err != nil {
68
68
return false
@@ -71,7 +71,7 @@ func validLeaseCandidateForOldestEmulationVersion(l *v1beta1.LeaseCandidate) boo
71
71
return err == nil
72
72
}
73
73
74
- func getEmulationVersionOrZero (l * v1beta1 .LeaseCandidate ) semver.Version {
74
+ func getEmulationVersionOrZero (l * v1alpha2 .LeaseCandidate ) semver.Version {
75
75
value := l .Spec .EmulationVersion
76
76
v , err := semver .ParseTolerant (value )
77
77
if err != nil {
@@ -80,7 +80,7 @@ func getEmulationVersionOrZero(l *v1beta1.LeaseCandidate) semver.Version {
80
80
return v
81
81
}
82
82
83
- func getBinaryVersionOrZero (l * v1beta1 .LeaseCandidate ) semver.Version {
83
+ func getBinaryVersionOrZero (l * v1alpha2 .LeaseCandidate ) semver.Version {
84
84
value := l .Spec .BinaryVersion
85
85
v , err := semver .ParseTolerant (value )
86
86
if err != nil {
@@ -90,7 +90,7 @@ func getBinaryVersionOrZero(l *v1beta1.LeaseCandidate) semver.Version {
90
90
}
91
91
92
92
// -1: lhs better, 1: rhs better
93
- func compare (lhs , rhs * v1beta1 .LeaseCandidate ) int {
93
+ func compare (lhs , rhs * v1alpha2 .LeaseCandidate ) int {
94
94
l := getEmulationVersionOrZero (lhs )
95
95
r := getEmulationVersionOrZero (rhs )
96
96
result := l .Compare (r )
@@ -115,7 +115,7 @@ func isLeaseExpired(clock clock.Clock, lease *v1.Lease) bool {
115
115
lease .Spec .RenewTime .Add (time .Duration (* lease .Spec .LeaseDurationSeconds )* time .Second ).Before (currentTime )
116
116
}
117
117
118
- func isLeaseCandidateExpired (clock clock.Clock , lease * v1beta1 .LeaseCandidate ) bool {
118
+ func isLeaseCandidateExpired (clock clock.Clock , lease * v1alpha2 .LeaseCandidate ) bool {
119
119
currentTime := clock .Now ()
120
120
return lease .Spec .RenewTime == nil ||
121
121
lease .Spec .RenewTime .Add (leaseCandidateValidDuration ).Before (currentTime )
0 commit comments