mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
endpoint-reconcilers: split stop and remove
This commit is contained in:
parent
0d98463f9c
commit
14f2a335dc
@ -283,14 +283,16 @@ func checkEndpointSubsetFormatWithLease(e *corev1.Endpoints, expectedIPs []strin
|
||||
return true, ipsCorrect, portsCorrect
|
||||
}
|
||||
|
||||
func (r *leaseEndpointReconciler) StopReconciling(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
|
||||
r.reconcilingLock.Lock()
|
||||
defer r.reconcilingLock.Unlock()
|
||||
r.stopReconcilingCalled = true
|
||||
|
||||
func (r *leaseEndpointReconciler) RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
|
||||
if err := r.masterLeases.RemoveLease(ip.String()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLeaseStopReconciling(t *testing.T) {
|
||||
func TestLeaseRemoveEndpoints(t *testing.T) {
|
||||
ns := corev1.NamespaceDefault
|
||||
om := func(name string) metav1.ObjectMeta {
|
||||
return metav1.ObjectMeta{Namespace: ns, Name: name}
|
||||
@ -627,7 +627,7 @@ func TestLeaseStopReconciling(t *testing.T) {
|
||||
}
|
||||
}
|
||||
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 {
|
||||
t.Errorf("case %q: unexpected error: %v", test.testName, err)
|
||||
}
|
||||
|
@ -137,10 +137,9 @@ func (r *masterCountEndpointReconciler) ReconcileEndpoints(serviceName string, i
|
||||
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()
|
||||
defer r.reconcilingLock.Unlock()
|
||||
r.stopReconcilingCalled = true
|
||||
|
||||
e, err := r.endpointClient.Endpoints(metav1.NamespaceDefault).Get(serviceName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
@ -167,6 +166,12 @@ func (r *masterCountEndpointReconciler) StopReconciling(serviceName string, ip n
|
||||
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.
|
||||
//
|
||||
// Return values:
|
||||
|
@ -18,8 +18,9 @@ limitations under the License.
|
||||
package reconcilers
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"net"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
// NoneEndpointReconciler allows for the endpoint reconciler to be disabled
|
||||
@ -36,7 +37,10 @@ func (r *noneEndpointReconciler) ReconcileEndpoints(serviceName string, ip net.I
|
||||
return nil
|
||||
}
|
||||
|
||||
// StopReconciling noop reconcile
|
||||
func (r *noneEndpointReconciler) StopReconciling(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
|
||||
// RemoveEndpoints noop reconcile
|
||||
func (r *noneEndpointReconciler) RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *noneEndpointReconciler) StopReconciling() {
|
||||
}
|
||||
|
@ -18,8 +18,9 @@ limitations under the License.
|
||||
package reconcilers
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"net"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
// EndpointReconciler knows how to reconcile the endpoints for the apiserver service.
|
||||
@ -35,7 +36,10 @@ type EndpointReconciler interface {
|
||||
// endpoints for their {rw, ro} services.
|
||||
// * ReconcileEndpoints is called periodically from all apiservers.
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user