@@ -611,22 +611,24 @@ func (cloud *CloudProvider) AttachDisk(ctx context.Context, volKey *meta.Key, re
611
611
if err != nil {
612
612
return fmt .Errorf ("failed cloud service attach disk call: %v" , err )
613
613
}
614
+ klog .V (5 ).Infof ("Attaching disk %s operation id is %s" , volKey , op .Name )
614
615
err = cloud .waitForZonalOp (ctx , op .Name , instanceZone )
615
616
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 )
617
618
}
618
619
return nil
619
620
}
620
621
621
622
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 )
623
624
op , err := cloud .service .Instances .DetachDisk (cloud .project , instanceZone , instanceName , deviceName ).Context (ctx ).Do ()
624
625
if err != nil {
625
626
return err
626
627
}
628
+ klog .V (5 ).Infof ("Detaching disk %s operation id is %s" , deviceName , op .Name )
627
629
err = cloud .waitForZonalOp (ctx , op .Name , instanceZone )
628
630
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 )
630
632
}
631
633
return nil
632
634
}
@@ -681,7 +683,7 @@ func (cloud *CloudProvider) waitForZonalOp(ctx context.Context, opName string, z
681
683
// The v1 API can query for v1, alpha, or beta operations.
682
684
svc := cloud .service
683
685
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 ) {
685
687
pollOp , err := svc .ZoneOperations .Get (project , zone , opName ).Context (ctx ).Do ()
686
688
if err != nil {
687
689
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,
743
745
}
744
746
745
747
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 {
747
752
return false , nil
748
753
}
749
754
if op .Error != nil && len (op .Error .Errors ) > 0 && op .Error .Errors [0 ] != nil {
0 commit comments