mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Make gce operation polling more robust.
Only fail the operation if we cannot poll it 3 consecutive times.
This commit is contained in:
parent
c752bc6ffb
commit
983748b2e2
@ -276,14 +276,20 @@ func (gce *GCECloud) targetPoolURL(name, region string) string {
|
|||||||
|
|
||||||
func waitForOp(op *compute.Operation, getOperation func() (*compute.Operation, error)) error {
|
func waitForOp(op *compute.Operation, getOperation func() (*compute.Operation, error)) error {
|
||||||
pollOp := op
|
pollOp := op
|
||||||
|
consecPollFails := 0
|
||||||
for pollOp.Status != "DONE" {
|
for pollOp.Status != "DONE" {
|
||||||
var err error
|
var err error
|
||||||
// TODO: add some backoff here.
|
time.Sleep(3 * time.Second)
|
||||||
time.Sleep(time.Second)
|
|
||||||
pollOp, err = getOperation()
|
pollOp, err = getOperation()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if consecPollFails == 2 {
|
||||||
|
// Only bail if we've seen 3 consecutive polling errors.
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
consecPollFails++
|
||||||
|
} else {
|
||||||
|
consecPollFails = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if pollOp.Error != nil && len(pollOp.Error.Errors) > 0 {
|
if pollOp.Error != nil && len(pollOp.Error.Errors) > 0 {
|
||||||
return &googleapi.Error{
|
return &googleapi.Error{
|
||||||
|
Loading…
Reference in New Issue
Block a user