@@ -22,14 +22,14 @@ import (
22
22
"time"
23
23
24
24
v1 "k8s.io/api/coordination/v1"
25
- v1alpha1 "k8s.io/api/coordination/v1alpha1 "
25
+ v1alpha2 "k8s.io/api/coordination/v1alpha2 "
26
26
apierrors "k8s.io/apimachinery/pkg/api/errors"
27
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28
28
"k8s.io/apimachinery/pkg/fields"
29
29
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
30
30
"k8s.io/client-go/informers"
31
31
"k8s.io/client-go/kubernetes"
32
- coordinationv1alpha1client "k8s.io/client-go/kubernetes/typed/coordination/v1alpha1 "
32
+ coordinationv1alpha2client "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2 "
33
33
"k8s.io/client-go/tools/cache"
34
34
"k8s.io/client-go/util/workqueue"
35
35
"k8s.io/klog/v2"
@@ -43,7 +43,7 @@ type CacheSyncWaiter interface {
43
43
}
44
44
45
45
type LeaseCandidate struct {
46
- leaseClient coordinationv1alpha1client .LeaseCandidateInterface
46
+ leaseClient coordinationv1alpha2client .LeaseCandidateInterface
47
47
leaseCandidateInformer cache.SharedIndexInformer
48
48
informerFactory informers.SharedInformerFactory
49
49
hasSynced cache.InformerSynced
@@ -60,7 +60,7 @@ type LeaseCandidate struct {
60
60
clock clock.Clock
61
61
62
62
binaryVersion , emulationVersion string
63
- preferredStrategies [] v1.CoordinatedLeaseStrategy
63
+ strategy v1.CoordinatedLeaseStrategy
64
64
}
65
65
66
66
// NewCandidate creates new LeaseCandidate controller that creates a
@@ -73,7 +73,7 @@ func NewCandidate(clientset kubernetes.Interface,
73
73
candidateName string ,
74
74
targetLease string ,
75
75
binaryVersion , emulationVersion string ,
76
- preferredStrategies [] v1.CoordinatedLeaseStrategy ,
76
+ strategy v1.CoordinatedLeaseStrategy ,
77
77
) (* LeaseCandidate , CacheSyncWaiter , error ) {
78
78
fieldSelector := fields .OneTermEqualSelector ("metadata.name" , candidateName ).String ()
79
79
// A separate informer factory is required because this must start before informerFactories
@@ -84,10 +84,10 @@ func NewCandidate(clientset kubernetes.Interface,
84
84
options .FieldSelector = fieldSelector
85
85
}),
86
86
)
87
- leaseCandidateInformer := informerFactory .Coordination ().V1alpha1 ().LeaseCandidates ().Informer ()
87
+ leaseCandidateInformer := informerFactory .Coordination ().V1alpha2 ().LeaseCandidates ().Informer ()
88
88
89
89
lc := & LeaseCandidate {
90
- leaseClient : clientset .CoordinationV1alpha1 ().LeaseCandidates (candidateNamespace ),
90
+ leaseClient : clientset .CoordinationV1alpha2 ().LeaseCandidates (candidateNamespace ),
91
91
leaseCandidateInformer : leaseCandidateInformer ,
92
92
informerFactory : informerFactory ,
93
93
name : candidateName ,
@@ -96,13 +96,13 @@ func NewCandidate(clientset kubernetes.Interface,
96
96
clock : clock.RealClock {},
97
97
binaryVersion : binaryVersion ,
98
98
emulationVersion : emulationVersion ,
99
- preferredStrategies : preferredStrategies ,
99
+ strategy : strategy ,
100
100
}
101
101
lc .queue = workqueue .NewTypedRateLimitingQueueWithConfig (workqueue .DefaultTypedControllerRateLimiter [int ](), workqueue.TypedRateLimitingQueueConfig [int ]{Name : "leasecandidate" })
102
102
103
103
h , err := leaseCandidateInformer .AddEventHandler (cache.ResourceEventHandlerFuncs {
104
104
UpdateFunc : func (oldObj , newObj interface {}) {
105
- if leasecandidate , ok := newObj .(* v1alpha1 .LeaseCandidate ); ok {
105
+ if leasecandidate , ok := newObj .(* v1alpha2 .LeaseCandidate ); ok {
106
106
if leasecandidate .Spec .PingTime != nil && leasecandidate .Spec .PingTime .After (leasecandidate .Spec .RenewTime .Time ) {
107
107
lc .enqueueLease ()
108
108
}
@@ -184,17 +184,17 @@ func (c *LeaseCandidate) ensureLease(ctx context.Context) error {
184
184
return nil
185
185
}
186
186
187
- func (c * LeaseCandidate ) newLeaseCandidate () * v1alpha1 .LeaseCandidate {
188
- lc := & v1alpha1 .LeaseCandidate {
187
+ func (c * LeaseCandidate ) newLeaseCandidate () * v1alpha2 .LeaseCandidate {
188
+ lc := & v1alpha2 .LeaseCandidate {
189
189
ObjectMeta : metav1.ObjectMeta {
190
190
Name : c .name ,
191
191
Namespace : c .namespace ,
192
192
},
193
- Spec : v1alpha1 .LeaseCandidateSpec {
194
- LeaseName : c .leaseName ,
195
- BinaryVersion : c .binaryVersion ,
196
- EmulationVersion : c .emulationVersion ,
197
- PreferredStrategies : c . preferredStrategies ,
193
+ Spec : v1alpha2 .LeaseCandidateSpec {
194
+ LeaseName : c .leaseName ,
195
+ BinaryVersion : c .binaryVersion ,
196
+ EmulationVersion : c .emulationVersion ,
197
+ Strategy : c . strategy ,
198
198
},
199
199
}
200
200
lc .Spec .RenewTime = & metav1.MicroTime {Time : c .clock .Now ()}
0 commit comments