Skip to content
Open
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/test/e2e/e2e.test
/test/e2e/ginkgo
cloud-config
/.idea
29 changes: 29 additions & 0 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ func NewNodeServer(connector cloud.Interface, mounter mount.Interface, nodeName
}
}

func ensurePermissions(ctx context.Context, mounter mount.Interface, targetPath string) error {
if os.PathSeparator != '/' {
return nil
}

// containers running with different uid wouldn't be able to use regular mounts. pe. bitnami ones
ctxzap.Extract(ctx).Sugar().Infow("Ensuring permissions","targetPath", targetPath)
err := mounter.Command("chmod", "+rwx", targetPath).Run()
if err != nil {
return status.Errorf(codes.Internal, "Cannot fix permissions in %s", targetPath, err.Error())
}
err = mounter.Command("chmod", "a+rwx", targetPath).Run()
if err != nil {
return status.Errorf(codes.Internal, "Cannot fix permissions in %s", targetPath, err.Error())
}
return nil
}

func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {

// Check parameters
Expand Down Expand Up @@ -114,6 +132,12 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
return nil, status.Error(codes.Internal, err.Error())
}
}

err = ensurePermissions(ctx, ns.mounter, target)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

return &csi.NodeStageVolumeResponse{}, nil
}

Expand Down Expand Up @@ -271,6 +295,11 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
}
}

err := ensurePermissions(ctx, ns.mounter, targetPath)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

return &csi.NodePublishVolumeResponse{}, nil
}

Expand Down