From f32cfb5cb3e448ba41f322670071bc2e349a4224 Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 25 Jan 2019 16:28:54 -0800 Subject: [PATCH] Fix container wait operations (#2941) /cc @chrisst --- google/container_operation.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/google/container_operation.go b/google/container_operation.go index 188cf884..1005b6b1 100644 --- a/google/container_operation.go +++ b/google/container_operation.go @@ -21,9 +21,23 @@ func (w *ContainerOperationWaiter) State() string { } func (w *ContainerOperationWaiter) Error() error { - if w != nil && w.Op != nil { + if w == nil || w.Op == nil { + return nil + } + + // Error gets called during operation polling to see if there is an error. + // Since container's operation doesn't have an "error" field, we must wait + // until it's done and check the status message + for _, pending := range w.PendingStates() { + if w.Op.Status == pending { + return nil + } + } + + if w.Op.StatusMessage != "" { return fmt.Errorf(w.Op.StatusMessage) } + return nil } @@ -71,5 +85,6 @@ func containerOperationWait(config *Config, op *container.Operation, project, lo if err := w.SetOp(op); err != nil { return err } + return OperationWait(w, activity, timeoutMinutes) }