@@ -115,7 +115,7 @@ func (cloud *CloudProvider) GetDefaultZone() string {
115
115
func (cloud * CloudProvider ) ListDisks (ctx context.Context ) ([]* computev1.Disk , string , error ) {
116
116
region , err := common .GetRegionFromZones ([]string {cloud .zone })
117
117
if err != nil {
118
- return nil , "" , fmt .Errorf ("failed to get region from zones: %v " , err )
118
+ return nil , "" , fmt .Errorf ("failed to get region from zones: %w " , err )
119
119
}
120
120
zones , err := cloud .ListZones (ctx , region )
121
121
if err != nil {
@@ -162,7 +162,7 @@ func (cloud *CloudProvider) RepairUnderspecifiedVolumeKey(ctx context.Context, p
162
162
}
163
163
region , err := common .GetRegionFromZones ([]string {cloud .zone })
164
164
if err != nil {
165
- return "" , nil , fmt .Errorf ("failed to get region from zones: %v " , err )
165
+ return "" , nil , fmt .Errorf ("failed to get region from zones: %w " , err )
166
166
}
167
167
switch volumeKey .Type () {
168
168
case meta .Zonal :
@@ -216,7 +216,7 @@ func (cloud *CloudProvider) ListZones(ctx context.Context, region string) ([]str
216
216
zones := []string {}
217
217
zoneList , err := cloud .service .Zones .List (cloud .project ).Filter (fmt .Sprintf ("region eq .*%s$" , region )).Do ()
218
218
if err != nil {
219
- return nil , fmt .Errorf ("failed to list zones in region %s: %v " , region , err )
219
+ return nil , fmt .Errorf ("failed to list zones in region %s: %w " , region , err )
220
220
}
221
221
for _ , zone := range zoneList .Items {
222
222
zones = append (zones , zone .Name )
@@ -493,7 +493,7 @@ func (cloud *CloudProvider) insertRegionalDisk(
493
493
klog .Warningf ("GCE PD %s already exists, reusing" , volKey .Name )
494
494
return nil
495
495
}
496
- return status .Error (codes .Internal , fmt .Sprintf ("unknown Insert disk error: %v" , err ))
496
+ return status .Error (codes .Internal , fmt .Sprintf ("unknown Insert disk error: %v" , err . Error () ))
497
497
}
498
498
klog .V (5 ).Infof ("InsertDisk operation %s for disk %s" , opName , diskToCreate .Name )
499
499
@@ -514,7 +514,7 @@ func (cloud *CloudProvider) insertRegionalDisk(
514
514
klog .Warningf ("GCE PD %s already exists after wait, reusing" , volKey .Name )
515
515
return nil
516
516
}
517
- return fmt .Errorf ("unknown Insert disk operation error: %v " , err )
517
+ return fmt .Errorf ("unknown Insert disk operation error: %w " , err )
518
518
}
519
519
return nil
520
520
}
@@ -604,7 +604,7 @@ func (cloud *CloudProvider) insertZonalDisk(
604
604
klog .Warningf ("GCE PD %s already exists, reusing" , volKey .Name )
605
605
return nil
606
606
}
607
- return fmt .Errorf ("unknown Insert disk error: %v " , err )
607
+ return fmt .Errorf ("unknown Insert disk error: %w " , err )
608
608
}
609
609
klog .V (5 ).Infof ("InsertDisk operation %s for disk %s" , opName , diskToCreate .Name )
610
610
@@ -626,7 +626,7 @@ func (cloud *CloudProvider) insertZonalDisk(
626
626
klog .Warningf ("GCE PD %s already exists after wait, reusing" , volKey .Name )
627
627
return nil
628
628
}
629
- return fmt .Errorf ("unknown Insert disk operation error: %v " , err )
629
+ return fmt .Errorf ("unknown Insert disk operation error: %w " , err )
630
630
}
631
631
return nil
632
632
}
@@ -685,7 +685,7 @@ func (cloud *CloudProvider) AttachDisk(ctx context.Context, project string, volK
685
685
686
686
deviceName , err := common .GetDeviceName (volKey )
687
687
if err != nil {
688
- return fmt .Errorf ("failed to get device name: %v " , err )
688
+ return fmt .Errorf ("failed to get device name: %w " , err )
689
689
}
690
690
attachedDiskV1 := & computev1.AttachedDisk {
691
691
DeviceName : deviceName ,
@@ -697,13 +697,13 @@ func (cloud *CloudProvider) AttachDisk(ctx context.Context, project string, volK
697
697
698
698
op , err := cloud .service .Instances .AttachDisk (project , instanceZone , instanceName , attachedDiskV1 ).Context (ctx ).Do ()
699
699
if err != nil {
700
- return fmt .Errorf ("failed cloud service attach disk call: %v " , err )
700
+ return fmt .Errorf ("failed cloud service attach disk call: %w " , err )
701
701
}
702
702
klog .V (5 ).Infof ("AttachDisk operation %s for disk %s" , op .Name , attachedDiskV1 .DeviceName )
703
703
704
704
err = cloud .waitForZonalOp (ctx , project , op .Name , instanceZone )
705
705
if err != nil {
706
- return fmt .Errorf ("failed when waiting for zonal op: %v " , err )
706
+ return fmt .Errorf ("failed when waiting for zonal op: %w " , err )
707
707
}
708
708
return nil
709
709
}
@@ -814,7 +814,7 @@ func (cloud *CloudProvider) WaitForAttach(ctx context.Context, project string, v
814
814
klog .V (6 ).Infof ("Polling for attach of disk %v to instance %v to complete for %v" , volKey .Name , instanceName , time .Since (start ))
815
815
disk , err := cloud .GetDisk (ctx , project , volKey , GCEAPIVersionV1 )
816
816
if err != nil {
817
- return false , fmt .Errorf ("GetDisk failed to get disk: %v " , err )
817
+ return false , fmt .Errorf ("GetDisk failed to get disk: %w " , err )
818
818
}
819
819
820
820
if disk == nil {
@@ -946,7 +946,7 @@ func (cloud *CloudProvider) waitForImageCreation(ctx context.Context, project, i
946
946
klog .V (6 ).Infof ("Checking GCE Image %s." , imageName )
947
947
image , err := cloud .GetImage (ctx , project , imageName )
948
948
if err != nil {
949
- klog .Warningf ("Error in getting image %s, %w " , imageName , err )
949
+ klog .Warningf ("Error in getting image %s, %v " , imageName , err . Error () )
950
950
} else if image != nil {
951
951
if image .Status != "PENDING" {
952
952
klog .V (6 ).Infof ("Image %s status is %s" , imageName , image .Status )
@@ -1009,7 +1009,7 @@ func (cloud *CloudProvider) ResizeDisk(ctx context.Context, project string, volK
1009
1009
klog .V (5 ).Infof ("Resizing disk %v to size %v" , volKey , requestBytes )
1010
1010
cloudDisk , err := cloud .GetDisk (ctx , project , volKey , GCEAPIVersionV1 )
1011
1011
if err != nil {
1012
- return - 1 , fmt .Errorf ("failed to get disk: %v " , err )
1012
+ return - 1 , fmt .Errorf ("failed to get disk: %w " , err )
1013
1013
}
1014
1014
1015
1015
sizeGb := cloudDisk .GetSizeGb ()
@@ -1037,13 +1037,13 @@ func (cloud *CloudProvider) resizeZonalDisk(ctx context.Context, project string,
1037
1037
}
1038
1038
op , err := cloud .service .Disks .Resize (project , volKey .Zone , volKey .Name , resizeReq ).Context (ctx ).Do ()
1039
1039
if err != nil {
1040
- return - 1 , fmt .Errorf ("failed to resize zonal volume %v: %v " , volKey .String (), err )
1040
+ return - 1 , fmt .Errorf ("failed to resize zonal volume %v: %w " , volKey .String (), err )
1041
1041
}
1042
1042
klog .V (5 ).Infof ("ResizeDisk operation %s for disk %s" , op .Name , volKey .Name )
1043
1043
1044
1044
err = cloud .waitForZonalOp (ctx , project , op .Name , volKey .Zone )
1045
1045
if err != nil {
1046
- return - 1 , fmt .Errorf ("failed waiting for op for zonal resize for %s: %v " , volKey .String (), err )
1046
+ return - 1 , fmt .Errorf ("failed waiting for op for zonal resize for %s: %w " , volKey .String (), err )
1047
1047
}
1048
1048
1049
1049
return requestGb , nil
@@ -1056,13 +1056,13 @@ func (cloud *CloudProvider) resizeRegionalDisk(ctx context.Context, project stri
1056
1056
1057
1057
op , err := cloud .service .RegionDisks .Resize (project , volKey .Region , volKey .Name , resizeReq ).Context (ctx ).Do ()
1058
1058
if err != nil {
1059
- return - 1 , fmt .Errorf ("failed to resize regional volume %v: %v " , volKey .String (), err )
1059
+ return - 1 , fmt .Errorf ("failed to resize regional volume %v: %w " , volKey .String (), err )
1060
1060
}
1061
1061
klog .V (5 ).Infof ("ResizeDisk operation %s for disk %s" , op .Name , volKey .Name )
1062
1062
1063
1063
err = cloud .waitForRegionalOp (ctx , project , op .Name , volKey .Region )
1064
1064
if err != nil {
1065
- return - 1 , fmt .Errorf ("failed waiting for op for regional resize for %s: %v " , volKey .String (), err )
1065
+ return - 1 , fmt .Errorf ("failed waiting for op for regional resize for %s: %w " , volKey .String (), err )
1066
1066
}
1067
1067
1068
1068
return requestGb , nil
@@ -1112,7 +1112,7 @@ func (cloud *CloudProvider) waitForSnapshotCreation(ctx context.Context, project
1112
1112
klog .V (6 ).Infof ("Checking GCE Snapshot %s." , snapshotName )
1113
1113
snapshot , err := cloud .GetSnapshot (ctx , project , snapshotName )
1114
1114
if err != nil {
1115
- klog .Warningf ("Error in getting snapshot %s, %w " , snapshotName , err )
1115
+ klog .Warningf ("Error in getting snapshot %s, %v " , snapshotName , err . Error () )
1116
1116
} else if snapshot != nil {
1117
1117
if snapshot .Status != "CREATING" {
1118
1118
klog .V (6 ).Infof ("Snapshot %s status is %s" , snapshotName , snapshot .Status )
@@ -1159,7 +1159,7 @@ func encodeTags(tags map[string]string) (string, error) {
1159
1159
1160
1160
enc , err := json .Marshal (tags )
1161
1161
if err != nil {
1162
- return "" , fmt .Errorf ("failed to encodeTags %v: %v " , tags , err )
1162
+ return "" , fmt .Errorf ("failed to encodeTags %v: %w " , tags , err )
1163
1163
}
1164
1164
return string (enc ), nil
1165
1165
}
0 commit comments