Skip to content

Commit 14f2a33

Browse files
committed
endpoint-reconcilers: split stop and remove
1 parent 0d98463 commit 14f2a33

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

pkg/master/reconcilers/lease.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,16 @@ func checkEndpointSubsetFormatWithLease(e *corev1.Endpoints, expectedIPs []strin
283283
return true, ipsCorrect, portsCorrect
284284
}
285285

286-
func (r *leaseEndpointReconciler) StopReconciling(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
287-
r.reconcilingLock.Lock()
288-
defer r.reconcilingLock.Unlock()
289-
r.stopReconcilingCalled = true
290-
286+
func (r *leaseEndpointReconciler) RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
291287
if err := r.masterLeases.RemoveLease(ip.String()); err != nil {
292288
return err
293289
}
294290

295291
return r.doReconcile(serviceName, endpointPorts, true)
296292
}
293+
294+
func (r *leaseEndpointReconciler) StopReconciling() {
295+
r.reconcilingLock.Lock()
296+
defer r.reconcilingLock.Unlock()
297+
r.stopReconcilingCalled = true
298+
}

pkg/master/reconcilers/lease_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ func TestLeaseEndpointReconciler(t *testing.T) {
547547
}
548548
}
549549

550-
func TestLeaseStopReconciling(t *testing.T) {
550+
func TestLeaseRemoveEndpoints(t *testing.T) {
551551
ns := corev1.NamespaceDefault
552552
om := func(name string) metav1.ObjectMeta {
553553
return metav1.ObjectMeta{Namespace: ns, Name: name}
@@ -627,7 +627,7 @@ func TestLeaseStopReconciling(t *testing.T) {
627627
}
628628
}
629629
r := NewLeaseEndpointReconciler(clientset.CoreV1(), fakeLeases)
630-
err := r.StopReconciling(test.serviceName, net.ParseIP(test.ip), test.endpointPorts)
630+
err := r.RemoveEndpoints(test.serviceName, net.ParseIP(test.ip), test.endpointPorts)
631631
if err != nil {
632632
t.Errorf("case %q: unexpected error: %v", test.testName, err)
633633
}

pkg/master/reconcilers/mastercount.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,9 @@ func (r *masterCountEndpointReconciler) ReconcileEndpoints(serviceName string, i
137137
return err
138138
}
139139

140-
func (r *masterCountEndpointReconciler) StopReconciling(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
140+
func (r *masterCountEndpointReconciler) RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
141141
r.reconcilingLock.Lock()
142142
defer r.reconcilingLock.Unlock()
143-
r.stopReconcilingCalled = true
144143

145144
e, err := r.endpointClient.Endpoints(metav1.NamespaceDefault).Get(serviceName, metav1.GetOptions{})
146145
if err != nil {
@@ -167,6 +166,12 @@ func (r *masterCountEndpointReconciler) StopReconciling(serviceName string, ip n
167166
return err
168167
}
169168

169+
func (r *masterCountEndpointReconciler) StopReconciling() {
170+
r.reconcilingLock.Lock()
171+
defer r.reconcilingLock.Unlock()
172+
r.stopReconcilingCalled = true
173+
}
174+
170175
// Determine if the endpoint is in the format ReconcileEndpoints expects.
171176
//
172177
// Return values:

pkg/master/reconcilers/none.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ limitations under the License.
1818
package reconcilers
1919

2020
import (
21-
corev1 "k8s.io/api/core/v1"
2221
"net"
22+
23+
corev1 "k8s.io/api/core/v1"
2324
)
2425

2526
// NoneEndpointReconciler allows for the endpoint reconciler to be disabled
@@ -36,7 +37,10 @@ func (r *noneEndpointReconciler) ReconcileEndpoints(serviceName string, ip net.I
3637
return nil
3738
}
3839

39-
// StopReconciling noop reconcile
40-
func (r *noneEndpointReconciler) StopReconciling(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
40+
// RemoveEndpoints noop reconcile
41+
func (r *noneEndpointReconciler) RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
4142
return nil
4243
}
44+
45+
func (r *noneEndpointReconciler) StopReconciling() {
46+
}

pkg/master/reconcilers/reconcilers.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ limitations under the License.
1818
package reconcilers
1919

2020
import (
21-
corev1 "k8s.io/api/core/v1"
2221
"net"
22+
23+
corev1 "k8s.io/api/core/v1"
2324
)
2425

2526
// EndpointReconciler knows how to reconcile the endpoints for the apiserver service.
@@ -35,7 +36,10 @@ type EndpointReconciler interface {
3536
// endpoints for their {rw, ro} services.
3637
// * ReconcileEndpoints is called periodically from all apiservers.
3738
ReconcileEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort, reconcilePorts bool) error
38-
StopReconciling(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error
39+
// RemoveEndpoints removes this apiserver's lease.
40+
RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error
41+
// StopReonciling turns any later ReconcileEndpoints call into a noop.
42+
StopReconciling()
3943
}
4044

4145
// Type the reconciler type

0 commit comments

Comments
 (0)