Skip to content

Commit d955f28

Browse files
fix: always repair underspecified volume key
1 parent 64b6592 commit d955f28

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Diff for: pkg/gce-pd-csi-driver/controller.go

+24
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,14 @@ func (gceCS *GCEControllerServer) ControllerUnpublishVolume(ctx context.Context,
394394
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("ControllerUnpublishVolume Volume ID is invalid: %v", err))
395395
}
396396

397+
project, volKey, err = gceCS.CloudProvider.RepairUnderspecifiedVolumeKey(ctx, project, volKey)
398+
if err != nil {
399+
if gce.IsGCENotFoundError(err) {
400+
return nil, status.Errorf(codes.NotFound, "ControllerUnpublishVolume could not find volume with ID %v: %v", volumeID, err)
401+
}
402+
return nil, status.Errorf(codes.Internal, "ControllerUnpublishVolume error repairing underspecified volume key: %v", err)
403+
}
404+
397405
// Acquires the lock for the volume on that node only, because we need to support the ability
398406
// to unpublish the same volume from different nodes concurrently
399407
lockingVolumeID := fmt.Sprintf("%s/%s", nodeID, volumeID)
@@ -451,6 +459,14 @@ func (gceCS *GCEControllerServer) ValidateVolumeCapabilities(ctx context.Context
451459
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("Volume ID is invalid: %v", err))
452460
}
453461

462+
project, volKey, err = gceCS.CloudProvider.RepairUnderspecifiedVolumeKey(ctx, project, volKey)
463+
if err != nil {
464+
if gce.IsGCENotFoundError(err) {
465+
return nil, status.Errorf(codes.NotFound, "ValidateVolumeCapabilities could not find volume with ID %v: %v", volumeID, err)
466+
}
467+
return nil, status.Errorf(codes.Internal, "ValidateVolumeCapabilities error repairing underspecified volume key: %v", err)
468+
}
469+
454470
if acquired := gceCS.volumeLocks.TryAcquire(volumeID); !acquired {
455471
return nil, status.Errorf(codes.Aborted, common.VolumeOperationAlreadyExistsFmt, volumeID)
456472
}
@@ -715,6 +731,14 @@ func (gceCS *GCEControllerServer) ControllerExpandVolume(ctx context.Context, re
715731
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("ControllerExpandVolume Volume ID is invalid: %v", err))
716732
}
717733

734+
project, volKey, err = gceCS.CloudProvider.RepairUnderspecifiedVolumeKey(ctx, project, volKey)
735+
if err != nil {
736+
if gce.IsGCENotFoundError(err) {
737+
return nil, status.Errorf(codes.NotFound, "ControllerExpandVolume could not find volume with ID %v: %v", volumeID, err)
738+
}
739+
return nil, status.Errorf(codes.Internal, "ControllerExpandVolume error repairing underspecified volume key: %v", err)
740+
}
741+
718742
resizedGb, err := gceCS.CloudProvider.ResizeDisk(ctx, project, volKey, reqBytes)
719743
if err != nil {
720744
return nil, status.Error(codes.Internal, fmt.Sprintf("ControllerExpandVolume failed to resize disk: %v", err))

0 commit comments

Comments
 (0)