Skip to content

Commit

Permalink
fix csi fuse cli and staging path
Browse files Browse the repository at this point in the history
  • Loading branch information
ssz1997 committed Oct 25, 2023
1 parent 5c3a5b1 commit d44ee88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 10 additions & 3 deletions csi/alluxio/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const alluxioFuseHostPath = "/mnt/alluxio/fuse"

func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
targetPath := req.GetTargetPath()

stagingPath := fmt.Sprintf("%s-%s", alluxioFuseHostPath, req.VolumeId)
notMnt, err := ensureMountPoint(targetPath)
if err != nil {
glog.V(3).Infof("Error checking mount point: %+v.", err)
Expand All @@ -68,7 +68,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
return &csi.NodePublishVolumeResponse{}, nil
}

args := []string{"--bind", alluxioFuseHostPath, targetPath}
args := []string{"--bind", stagingPath, targetPath}
command := exec.Command("mount", args...)
_, err = command.CombinedOutput()
if err != nil {
Expand Down Expand Up @@ -110,7 +110,8 @@ func (ns *nodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
glog.V(3).Infof("Error creating CSI Fuse pod. %+v", err)
return nil, status.Error(codes.Internal, err.Error())
}
if err := checkIfMountPointReady(alluxioFuseHostPath); err != nil {
stagingPath := fmt.Sprintf("%s-%s", alluxioFuseHostPath, req.VolumeId)
if err := checkIfMountPointReady(stagingPath); err != nil {
glog.V(3).Infof("Mount point is not ready, or error occurs. %+v", err)
return nil, status.Error(codes.Internal, err.Error())
}
Expand All @@ -135,6 +136,12 @@ func getAndCompleteFusePodObj(ns *nodeServer, req *csi.NodeStageVolumeRequest) (
// Set node name for scheduling
csiFusePodObj.Spec.NodeName = ns.nodeId

// Use unique mount path
stagingPath := fmt.Sprintf("%s-%s", alluxioFuseHostPath, req.VolumeId)
csiFusePodObj.Spec.InitContainers[0].Command[2] = stagingPath
csiFusePodObj.Spec.Containers[0].Args[0] = strings.ReplaceAll(csiFusePodObj.Spec.Containers[0].Args[0], alluxioFuseHostPath, stagingPath)
csiFusePodObj.Spec.Containers[0].Lifecycle.PreStop.Exec.Command[2] = stagingPath

return csiFusePodObj, nil
}

Expand Down
7 changes: 4 additions & 3 deletions deploy/charts/alluxio/templates/csi/csi-fuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ data:
command: ["/bin/sh", "-c"]
args:
- umount -l {{ $alluxioFuseMountPoint }};
{{- if ne (get .Values.properties "alluxio.mount.table.source") "ETCD" }}
/entrypoint.sh fuse {{ required "The path of the dataset must be set." .Values.dataset.path }} {{ $alluxioFuseMountPoint }} {{- range .Values.fuse.mountOptions }} -o {{ . }} {{- end }}
{{- else }}
{{- $mountTableSource := get .Values.properties "alluxio.mount.table.source" }}
{{- if or (eq $mountTableSource "ETCD") (eq $mountTableSource "STATIC_FILE") }}
/entrypoint.sh fuse {{ $alluxioFuseMountPoint }} {{- range .Values.fuse.mountOptions }} -o {{ . }} {{- end }}
{{- else }}
/entrypoint.sh fuse {{ required "The path of the dataset must be set." .Values.dataset.path }} {{ $alluxioFuseMountPoint }} {{- range .Values.fuse.mountOptions }} -o {{ . }} {{- end }}
{{- end }}
env:
{{- range $key, $value := .Values.fuse.env }}
Expand Down

0 comments on commit d44ee88

Please sign in to comment.