Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sujeet01 committed Sep 27, 2024
1 parent e3160be commit 0c38a74
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 2 additions & 0 deletions pkg/driver/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const (
ParameterNodeID = "node_id"
// ParameterDeviceName is the device name parameter
ParameterDeviceName = "device_name"
// ParameterReadOnly is the read only parameter
ParameterReadOnly = "readOnly"
// ParameterMkfsOptions is the name of the parameter used to specify the options for the mkfs command
ParameterMkfsOptions = "mkfs_options"

Expand Down
2 changes: 1 addition & 1 deletion pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func validateDeviceName(volume *storagev1alpha1.Volume, machine *computev1alpha1
}
}
}
return "", fmt.Errorf("failed to get device name of volume %s name from machine %s", client.ObjectKeyFromObject(volume), client.ObjectKeyFromObject(machine))
return "", fmt.Errorf("failed to get device name of volume %s from machine %s", client.ObjectKeyFromObject(volume), client.ObjectKeyFromObject(machine))
}

func isValidVolumeCapabilities(volCaps []*csi.VolumeCapability) bool {
Expand Down
19 changes: 9 additions & 10 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,10 @@ func (d *driver) NodeStageVolume(_ context.Context, req *csi.NodeStageVolumeRequ
// We will requeue here since the device path is not ready yet.
return nil, status.Errorf(codes.Unavailable, "Device path %s does not exist: %v", devicePath, err)
} else {
return nil, status.Errorf(codes.Internal, "Failed to determine wether the device path %s exists: %v", devicePath, err)
return nil, status.Errorf(codes.Internal, "Failed to determine whether the device path %s exists: %v", devicePath, err)
}
}

readOnly := false
if volumeContext["readOnly"] == "true" {
readOnly = true
}
mountOptions := req.GetVolumeCapability().GetMount().GetMountFlags()

targetPath := req.GetStagingTargetPath()
klog.InfoS("Validate mount point", "MountPoint", targetPath)
notMnt, err := d.mounter.IsLikelyNotMountPoint(targetPath)
Expand All @@ -70,17 +64,22 @@ func (d *driver) NodeStageVolume(_ context.Context, req *csi.NodeStageVolumeRequ
return nil, status.Errorf(codes.Internal, "Failed to create target directory %s for volume %s: %v", targetPath, req.GetVolumeId(), err)
}

mountOptions := req.GetVolumeCapability().GetMount().GetMountFlags()

readOnly, ok := volumeContext[ParameterReadOnly]
readOnlyFlag := ok && readOnly == "true"

var options []string
if readOnly {
if readOnlyFlag {
options = append(options, "ro")
} else {
options = append(options, "rw")
}
options = append(options, mountOptions...)

var formatOptions []string
mkfsOptions, exists := volumeContext[ParameterMkfsOptions]
if exists && mkfsOptions != "" {
mkfsOptions, ok := volumeContext[ParameterMkfsOptions]
if ok && mkfsOptions != "" {
formatOptions = append(formatOptions, strings.Split(mkfsOptions, " ")...)
}

Expand Down

0 comments on commit 0c38a74

Please sign in to comment.