@@ -560,7 +560,7 @@ func (cloud *CloudProvider) insertRegionalDisk(
560
560
if IsGCEError (err , "alreadyExists" ) {
561
561
disk , err := cloud .GetDisk (ctx , project , volKey , gceAPIVersion )
562
562
if err != nil {
563
- return err
563
+ return status . Error ( codes . Unavailable , err . Error ())
564
564
}
565
565
err = cloud .ValidateExistingDisk (ctx , disk , params ,
566
566
int64 (capacityRange .GetRequiredBytes ()),
@@ -572,16 +572,18 @@ func (cloud *CloudProvider) insertRegionalDisk(
572
572
klog .Warningf ("GCE PD %s already exists, reusing" , volKey .Name )
573
573
return nil
574
574
}
575
- return status . Error ( codes . Internal , fmt .Sprintf ("unknown Insert disk error: %v " , err . Error ()) )
575
+ return fmt .Errorf ("unknown Insert Regional disk error: %w " , err )
576
576
}
577
577
klog .V (5 ).Infof ("InsertDisk operation %s for disk %s" , opName , diskToCreate .Name )
578
578
579
579
err = cloud .waitForRegionalOp (ctx , project , opName , volKey .Region )
580
+ // failed to wait for Op to finish, however, the Op possibly is still running as expected
581
+ // the error code returned should be non-final
580
582
if err != nil {
581
583
if IsGCEError (err , "alreadyExists" ) {
582
584
disk , err := cloud .GetDisk (ctx , project , volKey , gceAPIVersion )
583
585
if err != nil {
584
- return err
586
+ return status . Errorf ( codes . Unavailable , "error when getting disk: %v" , err . Error ())
585
587
}
586
588
err = cloud .ValidateExistingDisk (ctx , disk , params ,
587
589
int64 (capacityRange .GetRequiredBytes ()),
@@ -593,7 +595,7 @@ func (cloud *CloudProvider) insertRegionalDisk(
593
595
klog .Warningf ("GCE PD %s already exists after wait, reusing" , volKey .Name )
594
596
return nil
595
597
}
596
- return fmt .Errorf ("unknown Insert disk operation error : %w " , err )
598
+ return status .Errorf (codes . Unavailable , "unknown error when polling the operation : %v " , err . Error () )
597
599
}
598
600
return nil
599
601
}
@@ -695,7 +697,7 @@ func (cloud *CloudProvider) insertZonalDisk(
695
697
if IsGCEError (err , "alreadyExists" ) {
696
698
disk , err := cloud .GetDisk (ctx , project , volKey , gceAPIVersion )
697
699
if err != nil {
698
- return err
700
+ return status . Error ( codes . Unavailable , err . Error ())
699
701
}
700
702
err = cloud .ValidateExistingDisk (ctx , disk , params ,
701
703
int64 (capacityRange .GetRequiredBytes ()),
@@ -714,10 +716,12 @@ func (cloud *CloudProvider) insertZonalDisk(
714
716
err = cloud .waitForZonalOp (ctx , project , opName , volKey .Zone )
715
717
716
718
if err != nil {
719
+ // failed to wait for Op to finish, however, the Op possibly is still running as expected
720
+ // the error code returned should be non-final
717
721
if IsGCEError (err , "alreadyExists" ) {
718
722
disk , err := cloud .GetDisk (ctx , project , volKey , gceAPIVersion )
719
723
if err != nil {
720
- return err
724
+ return status . Errorf ( codes . Unavailable , "error when getting disk: %v" , err . Error ())
721
725
}
722
726
err = cloud .ValidateExistingDisk (ctx , disk , params ,
723
727
int64 (capacityRange .GetRequiredBytes ()),
@@ -729,7 +733,7 @@ func (cloud *CloudProvider) insertZonalDisk(
729
733
klog .Warningf ("GCE PD %s already exists after wait, reusing" , volKey .Name )
730
734
return nil
731
735
}
732
- return fmt .Errorf ("unknown Insert disk operation error : %w " , err )
736
+ return status .Errorf (codes . Unavailable , "unknown error when polling the operation : %v " , err . Error () )
733
737
}
734
738
return nil
735
739
}
0 commit comments