Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rbd: dont attempt explicit permission mod change from the RBD driver #2697

Merged
merged 2 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ func validateNormalUserPVCAccess(pvcPath string, f *framework.Framework) error {
},
},
Spec: v1.PodSpec{
SecurityContext: &v1.PodSecurityContext{FSGroup: &user},
Containers: []v1.Container{
{
Name: "write-pod",
Expand Down
16 changes: 5 additions & 11 deletions internal/rbd/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ func (ns *NodeServer) stageTransaction(
transaction := &stageTransaction{}

var err error
var readOnly bool

// Allow image to be mounted on multiple nodes if it is ROX
if req.VolumeCapability.AccessMode.Mode == csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY {
Expand Down Expand Up @@ -421,7 +420,7 @@ func (ns *NodeServer) stageTransaction(
transaction.isStagePathCreated = true

// nodeStage Path
readOnly, err = ns.mountVolumeToStagePath(ctx, req, staticVol, stagingTargetPath, devicePath)
err = ns.mountVolumeToStagePath(ctx, req, staticVol, stagingTargetPath, devicePath)
if err != nil {
return transaction, err
}
Expand All @@ -436,11 +435,6 @@ func (ns *NodeServer) stageTransaction(
return transaction, err
}

if !readOnly {
// #nosec - allow anyone to write inside the target path
err = os.Chmod(stagingTargetPath, 0o777)
}

return transaction, err
}

Expand Down Expand Up @@ -684,7 +678,7 @@ func (ns *NodeServer) mountVolumeToStagePath(
ctx context.Context,
req *csi.NodeStageVolumeRequest,
staticVol bool,
stagingPath, devicePath string) (bool, error) {
stagingPath, devicePath string) error {
readOnly := false
fsType := req.GetVolumeCapability().GetMount().GetFsType()
diskMounter := &mount.SafeFormatAndMount{Interface: ns.Mounter, Exec: utilexec.New()}
Expand All @@ -702,7 +696,7 @@ func (ns *NodeServer) mountVolumeToStagePath(
if err != nil {
log.ErrorLog(ctx, "failed to get disk format for path %s, error: %v", devicePath, err)

return readOnly, err
return err
}

opt := []string{"_netdev"}
Expand Down Expand Up @@ -742,7 +736,7 @@ func (ns *NodeServer) mountVolumeToStagePath(
if cmdErr != nil {
log.ErrorLog(ctx, "failed to run mkfs error: %v, output: %v", cmdErr, string(cmdOut))

return readOnly, cmdErr
return cmdErr
}
}
}
Expand All @@ -763,7 +757,7 @@ func (ns *NodeServer) mountVolumeToStagePath(
err)
}

return readOnly, err
return err
}

func (ns *NodeServer) mountVolume(ctx context.Context, stagingPath string, req *csi.NodePublishVolumeRequest) error {
Expand Down