Skip to content

Commit

Permalink
Fix container wait operations (#386)
Browse files Browse the repository at this point in the history
<!-- This change is generated by MagicModules. -->
/cc @chrisst
  • Loading branch information
modular-magician authored and chrisst committed Jan 26, 2019
1 parent 664824b commit 042c6cb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion google-beta/container_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}

0 comments on commit 042c6cb

Please sign in to comment.