@@ -25,7 +25,7 @@ import (
25
25
"google.golang.org/grpc/codes"
26
26
"google.golang.org/grpc/status"
27
27
"k8s.io/apimachinery/pkg/util/wait"
28
- "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/utils "
28
+ "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common "
29
29
)
30
30
31
31
type GCECompute interface {
@@ -62,11 +62,7 @@ func (cloud *CloudProvider) GetDiskOrError(ctx context.Context, volumeZone, volu
62
62
glog .Infof ("Getting disk %v from zone %v" , volumeName , volumeZone )
63
63
disk , err := svc .Disks .Get (project , volumeZone , volumeName ).Context (ctx ).Do ()
64
64
if err != nil {
65
- if IsGCEError (err , "notFound" ) {
66
- return nil , status .Error (codes .NotFound , fmt .Sprintf ("disk %v does not exist" , volumeName ))
67
- }
68
-
69
- return nil , status .Error (codes .Internal , fmt .Sprintf ("unknown disk GET error: %v" , err ))
65
+ return nil , err
70
66
}
71
67
glog .Infof ("Got disk %v from zone %v" , volumeName , volumeZone )
72
68
return disk , nil
@@ -86,12 +82,12 @@ func (cloud *CloudProvider) GetAndValidateExistingDisk(ctx context.Context, conf
86
82
87
83
if resp != nil {
88
84
// Disk already exists
89
- requestValid := utils .GbToBytes (resp .SizeGb ) >= reqBytes && reqBytes != 0
90
- responseValid := utils .GbToBytes (resp .SizeGb ) <= limBytes && limBytes != 0
85
+ requestValid := common .GbToBytes (resp .SizeGb ) >= reqBytes && reqBytes != 0
86
+ responseValid := common .GbToBytes (resp .SizeGb ) <= limBytes && limBytes != 0
91
87
if ! requestValid || ! responseValid {
92
88
return true , status .Error (codes .AlreadyExists , fmt .Sprintf (
93
89
"Disk already exists with incompatible capacity. Need %v (Required) < %v (Existing) < %v (Limit)" ,
94
- reqBytes , utils .GbToBytes (resp .SizeGb ), limBytes ))
90
+ reqBytes , common .GbToBytes (resp .SizeGb ), limBytes ))
95
91
}
96
92
97
93
respType := strings .Split (resp .Type , "/" )
@@ -190,11 +186,7 @@ func (cloud *CloudProvider) GetInstanceOrError(ctx context.Context, instanceZone
190
186
glog .Infof ("Getting instance %v from zone %v" , instanceName , instanceZone )
191
187
instance , err := svc .Instances .Get (project , instanceZone , instanceName ).Do ()
192
188
if err != nil {
193
- if IsGCEError (err , "notFound" ) {
194
- return nil , status .Error (codes .NotFound , fmt .Sprintf ("instance %v does not exist" , instanceName ))
195
- }
196
-
197
- return nil , status .Error (codes .Internal , fmt .Sprintf ("unknown instance GET error: %v" , err ))
189
+ return nil , err
198
190
}
199
191
glog .Infof ("Got instance %v from zone %v" , instanceName , instanceZone )
200
192
return instance , nil
0 commit comments