Skip to content

Commit 8302b5b

Browse files
committed
Handle unstructured status in RetryWatcher
1 parent 0b48018 commit 8302b5b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

staging/src/k8s.io/client-go/tools/watch/retrywatcher.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,17 @@ func (rw *RetryWatcher) doReceive() (bool, time.Duration) {
184184
continue
185185

186186
case watch.Error:
187-
status, ok := event.Object.(*metav1.Status)
187+
// This round trip allows us to handle unstructured status
188+
errObject := apierrors.FromObject(event.Object)
189+
statusErr, ok := errObject.(*apierrors.StatusError)
188190
if !ok {
189191
klog.Error(spew.Sprintf("Received an error which is not *metav1.Status but %#+v", event.Object))
190192
// Retry unknown errors
191193
return false, 0
192194
}
193195

196+
status := statusErr.ErrStatus
197+
194198
statusDelay := time.Duration(0)
195199
if status.Details != nil {
196200
statusDelay = time.Duration(status.Details.RetryAfterSeconds) * time.Second

0 commit comments

Comments
 (0)