From 983748b2e29e40405331fb1bfcbc1c95f7d20cde Mon Sep 17 00:00:00 2001 From: CJ Cullen Date: Thu, 30 Jul 2015 14:26:08 -0700 Subject: [PATCH] Make gce operation polling more robust. Only fail the operation if we cannot poll it 3 consecutive times. --- pkg/cloudprovider/gce/gce.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/cloudprovider/gce/gce.go b/pkg/cloudprovider/gce/gce.go index 8b618496f9d..732742e7b39 100644 --- a/pkg/cloudprovider/gce/gce.go +++ b/pkg/cloudprovider/gce/gce.go @@ -276,13 +276,19 @@ func (gce *GCECloud) targetPoolURL(name, region string) string { func waitForOp(op *compute.Operation, getOperation func() (*compute.Operation, error)) error { pollOp := op + consecPollFails := 0 for pollOp.Status != "DONE" { var err error - // TODO: add some backoff here. - time.Sleep(time.Second) + time.Sleep(3 * time.Second) pollOp, err = getOperation() if err != nil { - return err + if consecPollFails == 2 { + // Only bail if we've seen 3 consecutive polling errors. + return err + } + consecPollFails++ + } else { + consecPollFails = 0 } } if pollOp.Error != nil && len(pollOp.Error.Errors) > 0 {