Commit 14f2a335 authored by Dr. Stefan Schimanski's avatar Dr. Stefan Schimanski

endpoint-reconcilers: split stop and remove

parent 0d98463f
...@@ -283,14 +283,16 @@ func checkEndpointSubsetFormatWithLease(e *corev1.Endpoints, expectedIPs []strin ...@@ -283,14 +283,16 @@ func checkEndpointSubsetFormatWithLease(e *corev1.Endpoints, expectedIPs []strin
return true, ipsCorrect, portsCorrect return true, ipsCorrect, portsCorrect
} }
func (r *leaseEndpointReconciler) StopReconciling(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error { func (r *leaseEndpointReconciler) RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
r.reconcilingLock.Lock()
defer r.reconcilingLock.Unlock()
r.stopReconcilingCalled = true
if err := r.masterLeases.RemoveLease(ip.String()); err != nil { if err := r.masterLeases.RemoveLease(ip.String()); err != nil {
return err return err
} }
return r.doReconcile(serviceName, endpointPorts, true) return r.doReconcile(serviceName, endpointPorts, true)
} }
func (r *leaseEndpointReconciler) StopReconciling() {
r.reconcilingLock.Lock()
defer r.reconcilingLock.Unlock()
r.stopReconcilingCalled = true
}
...@@ -547,7 +547,7 @@ func TestLeaseEndpointReconciler(t *testing.T) { ...@@ -547,7 +547,7 @@ func TestLeaseEndpointReconciler(t *testing.T) {
} }
} }
func TestLeaseStopReconciling(t *testing.T) { func TestLeaseRemoveEndpoints(t *testing.T) {
ns := corev1.NamespaceDefault ns := corev1.NamespaceDefault
om := func(name string) metav1.ObjectMeta { om := func(name string) metav1.ObjectMeta {
return metav1.ObjectMeta{Namespace: ns, Name: name} return metav1.ObjectMeta{Namespace: ns, Name: name}
...@@ -627,7 +627,7 @@ func TestLeaseStopReconciling(t *testing.T) { ...@@ -627,7 +627,7 @@ func TestLeaseStopReconciling(t *testing.T) {
} }
} }
r := NewLeaseEndpointReconciler(clientset.CoreV1(), fakeLeases) r := NewLeaseEndpointReconciler(clientset.CoreV1(), fakeLeases)
err := r.StopReconciling(test.serviceName, net.ParseIP(test.ip), test.endpointPorts) err := r.RemoveEndpoints(test.serviceName, net.ParseIP(test.ip), test.endpointPorts)
if err != nil { if err != nil {
t.Errorf("case %q: unexpected error: %v", test.testName, err) t.Errorf("case %q: unexpected error: %v", test.testName, err)
} }
......
...@@ -137,10 +137,9 @@ func (r *masterCountEndpointReconciler) ReconcileEndpoints(serviceName string, i ...@@ -137,10 +137,9 @@ func (r *masterCountEndpointReconciler) ReconcileEndpoints(serviceName string, i
return err return err
} }
func (r *masterCountEndpointReconciler) StopReconciling(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error { func (r *masterCountEndpointReconciler) RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
r.reconcilingLock.Lock() r.reconcilingLock.Lock()
defer r.reconcilingLock.Unlock() defer r.reconcilingLock.Unlock()
r.stopReconcilingCalled = true
e, err := r.endpointClient.Endpoints(metav1.NamespaceDefault).Get(serviceName, metav1.GetOptions{}) e, err := r.endpointClient.Endpoints(metav1.NamespaceDefault).Get(serviceName, metav1.GetOptions{})
if err != nil { if err != nil {
...@@ -167,6 +166,12 @@ func (r *masterCountEndpointReconciler) StopReconciling(serviceName string, ip n ...@@ -167,6 +166,12 @@ func (r *masterCountEndpointReconciler) StopReconciling(serviceName string, ip n
return err return err
} }
func (r *masterCountEndpointReconciler) StopReconciling() {
r.reconcilingLock.Lock()
defer r.reconcilingLock.Unlock()
r.stopReconcilingCalled = true
}
// Determine if the endpoint is in the format ReconcileEndpoints expects. // Determine if the endpoint is in the format ReconcileEndpoints expects.
// //
// Return values: // Return values:
......
...@@ -18,8 +18,9 @@ limitations under the License. ...@@ -18,8 +18,9 @@ limitations under the License.
package reconcilers package reconcilers
import ( import (
corev1 "k8s.io/api/core/v1"
"net" "net"
corev1 "k8s.io/api/core/v1"
) )
// NoneEndpointReconciler allows for the endpoint reconciler to be disabled // NoneEndpointReconciler allows for the endpoint reconciler to be disabled
...@@ -36,7 +37,10 @@ func (r *noneEndpointReconciler) ReconcileEndpoints(serviceName string, ip net.I ...@@ -36,7 +37,10 @@ func (r *noneEndpointReconciler) ReconcileEndpoints(serviceName string, ip net.I
return nil return nil
} }
// StopReconciling noop reconcile // RemoveEndpoints noop reconcile
func (r *noneEndpointReconciler) StopReconciling(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error { func (r *noneEndpointReconciler) RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
return nil return nil
} }
func (r *noneEndpointReconciler) StopReconciling() {
}
...@@ -18,8 +18,9 @@ limitations under the License. ...@@ -18,8 +18,9 @@ limitations under the License.
package reconcilers package reconcilers
import ( import (
corev1 "k8s.io/api/core/v1"
"net" "net"
corev1 "k8s.io/api/core/v1"
) )
// EndpointReconciler knows how to reconcile the endpoints for the apiserver service. // EndpointReconciler knows how to reconcile the endpoints for the apiserver service.
...@@ -35,7 +36,10 @@ type EndpointReconciler interface { ...@@ -35,7 +36,10 @@ type EndpointReconciler interface {
// endpoints for their {rw, ro} services. // endpoints for their {rw, ro} services.
// * ReconcileEndpoints is called periodically from all apiservers. // * ReconcileEndpoints is called periodically from all apiservers.
ReconcileEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort, reconcilePorts bool) error ReconcileEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort, reconcilePorts bool) error
StopReconciling(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error // RemoveEndpoints removes this apiserver's lease.
RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error
// StopReonciling turns any later ReconcileEndpoints call into a noop.
StopReconciling()
} }
// Type the reconciler type // Type the reconciler type
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment