diff --git a/staging/src/k8s.io/client-go/tools/watch/retrywatcher.go b/staging/src/k8s.io/client-go/tools/watch/retrywatcher.go index 62c14b07844..e45d58ec15d 100644 --- a/staging/src/k8s.io/client-go/tools/watch/retrywatcher.go +++ b/staging/src/k8s.io/client-go/tools/watch/retrywatcher.go @@ -184,13 +184,17 @@ func (rw *RetryWatcher) doReceive() (bool, time.Duration) { continue case watch.Error: - status, ok := event.Object.(*metav1.Status) + // This round trip allows us to handle unstructured status + errObject := apierrors.FromObject(event.Object) + statusErr, ok := errObject.(*apierrors.StatusError) if !ok { klog.Error(spew.Sprintf("Received an error which is not *metav1.Status but %#+v", event.Object)) // Retry unknown errors return false, 0 } + status := statusErr.ErrStatus + statusDelay := time.Duration(0) if status.Details != nil { statusDelay = time.Duration(status.Details.RetryAfterSeconds) * time.Second