mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Merge pull request #80273 from tallclair/endpoints
Don't delete service endpoints when a generic error occurs
This commit is contained in:
commit
f2cfc160ef
@ -411,6 +411,10 @@ func (e *EndpointController) syncService(key string) error {
|
|||||||
}
|
}
|
||||||
service, err := e.serviceLister.Services(namespace).Get(name)
|
service, err := e.serviceLister.Services(namespace).Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if !errors.IsNotFound(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the corresponding endpoint, as the service has been deleted.
|
// Delete the corresponding endpoint, as the service has been deleted.
|
||||||
// TODO: Please note that this will delete an endpoint when a
|
// TODO: Please note that this will delete an endpoint when a
|
||||||
// service is deleted. However, if we're down at the time when
|
// service is deleted. However, if we're down at the time when
|
||||||
|
@ -1708,3 +1708,20 @@ func TestPodDeleteBatching(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSyncEndpointsServiceNotFound(t *testing.T) {
|
||||||
|
ns := metav1.NamespaceDefault
|
||||||
|
testServer, endpointsHandler := makeTestServer(t, ns)
|
||||||
|
defer testServer.Close()
|
||||||
|
endpoints := newController(testServer.URL, 0)
|
||||||
|
endpoints.endpointsStore.Add(&v1.Endpoints{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "foo",
|
||||||
|
Namespace: ns,
|
||||||
|
ResourceVersion: "1",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
endpoints.syncService(ns + "/foo")
|
||||||
|
endpointsHandler.ValidateRequestCount(t, 1)
|
||||||
|
endpointsHandler.ValidateRequest(t, testapi.Default.ResourcePath("endpoints", ns, "foo"), "DELETE", nil)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user