Merge pull request #109624 from aryan9600/fix-endpointslice-deletion

Ignore EndpointSlices that are marked for deletion
This commit is contained in:
Kubernetes Prow Robot
2022-06-09 00:11:42 -07:00
committed by GitHub
4 changed files with 122 additions and 1 deletions

View File

@@ -368,6 +368,9 @@ func (c *Controller) syncService(key string) error {
return err
}
// Drop EndpointSlices that have been marked for deletion to prevent the controller from getting stuck.
endpointSlices = dropEndpointSlicesPendingDeletion(endpointSlices)
if c.endpointSliceTracker.StaleSlices(service, endpointSlices) {
return endpointsliceutil.NewStaleInformerCache("EndpointSlice informer cache is out of date")
}
@@ -561,3 +564,14 @@ func trackSync(err error) {
}
endpointslicemetrics.EndpointSliceSyncs.WithLabelValues(metricLabel).Inc()
}
func dropEndpointSlicesPendingDeletion(endpointSlices []*discovery.EndpointSlice) []*discovery.EndpointSlice {
n := 0
for _, endpointSlice := range endpointSlices {
if endpointSlice.DeletionTimestamp == nil {
endpointSlices[n] = endpointSlice
n++
}
}
return endpointSlices[:n]
}