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