Handle unstructured status in RetryWatcher

Kubernetes-commit: 8302b5b262c506ff7d363338f980ce204d574354
This commit is contained in:
Tomas Nozicka
2019-03-08 09:34:56 +01:00
committed by Kubernetes Publisher
parent dfef1155b5
commit 54b354c5dc

View File

@@ -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