Skip to content

Commit d036a3d

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 d036a3d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

+10-5
Original file line numberDiff line numberDiff line change
@@ -611,22 +611,24 @@ func (cloud *CloudProvider) AttachDisk(ctx context.Context, volKey *meta.Key, re
611611
if err != nil {
612612
return fmt.Errorf("failed cloud service attach disk call: %v", err)
613613
}
614+
klog.V(5).Infof("Attaching disk %s operation id is ", volKey, op.Name)
614615
err = cloud.waitForZonalOp(ctx, op.Name, instanceZone)
615616
if err != nil {
616-
return fmt.Errorf("failed when waiting for zonal op: %v", err)
617+
return fmt.Errorf("failed when waiting for zonal op %s on attaching volume %v: %v", op.Name, volKey, err)
617618
}
618619
return nil
619620
}
620621

621622
func (cloud *CloudProvider) DetachDisk(ctx context.Context, deviceName, instanceZone, instanceName string) error {
622-
klog.V(5).Infof("Detaching disk %v from %v", deviceName, instanceName)
623+
klog.V(5).Infof("Detaching disk %s from %v", deviceName, instanceName)
623624
op, err := cloud.service.Instances.DetachDisk(cloud.project, instanceZone, instanceName, deviceName).Context(ctx).Do()
624625
if err != nil {
625626
return err
626627
}
628+
klog.V(5).Infof("Detaching disk %s operation id is ", deviceName, op.Name)
627629
err = cloud.waitForZonalOp(ctx, op.Name, instanceZone)
628630
if err != nil {
629-
return err
631+
return fmt.Errorf("failed when waiting for zonal op %s on detaching volume %s: %v", op.Name, deviceName, err)
630632
}
631633
return nil
632634
}
@@ -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)