Skip to content

Commit 0d3764a

Browse files
committed
Update gce operation timeout
Update gce operation timeout to 2 mins instead of 5 mins. The 90% of attach/detach disk is less than 15 second, and create volume is less than 1 min. Reduce the timeout of volume operation so that it can recover from previous operation quicker in case operation is dropped.
1 parent 53e8abd commit 0d3764a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/gce-cloud-provider/compute/gce-compute.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ func (cloud *CloudProvider) AttachDisk(ctx context.Context, volKey *meta.Key, re
610610
op, err := cloud.service.Instances.AttachDisk(cloud.project, instanceZone, instanceName, attachedDiskV1).Context(ctx).Do()
611611
if err != nil {
612612
return fmt.Errorf("failed cloud service attach disk call: %v", err)
613+
} else {
614+
klog.V(5).Infof("Attaching disk %s operation id is ", volKey, op.Name)
613615
}
614616
err = cloud.waitForZonalOp(ctx, op.Name, instanceZone)
615617
if err != nil {
@@ -681,7 +683,7 @@ func (cloud *CloudProvider) waitForZonalOp(ctx context.Context, opName string, z
681683
// The v1 API can query for v1, alpha, or beta operations.
682684
svc := cloud.service
683685
project := cloud.project
684-
return wait.Poll(3*time.Second, 5*time.Minute, func() (bool, error) {
686+
return wait.Poll(3*time.Second, 2*time.Minute, func() (bool, error) {
685687
pollOp, err := svc.ZoneOperations.Get(project, zone, opName).Context(ctx).Do()
686688
if err != nil {
687689
klog.Errorf("WaitForOp(op: %s, zone: %#v) failed to poll the operation", opName, zone)
@@ -743,7 +745,10 @@ func (cloud *CloudProvider) WaitForAttach(ctx context.Context, volKey *meta.Key,
743745
}
744746

745747
func opIsDone(op *computev1.Operation) (bool, error) {
746-
if op == nil || op.Status != operationStatusDone {
748+
if op == nil {
749+
return true, fmt.Errorf("operation is nil")
750+
}
751+
if op.Status != operationStatusDone {
747752
return false, nil
748753
}
749754
if op.Error != nil && len(op.Error.Errors) > 0 && op.Error.Errors[0] != nil {

0 commit comments

Comments
 (0)