Skip to content

Commit 5756146

Browse files
committed
Fix(mount): path already mounted.
Signed-off-by: Wine93 <[email protected]>
1 parent 1cf0a96 commit 5756146

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

internal/task/task/fs/mount.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,12 @@ func mountPoint2ContainerName(mountPoint string) string {
217217
return fmt.Sprintf("curvefs-filesystem-%s", utils.MD5Sum(mountPoint))
218218
}
219219

220-
func checkMountStatus(mountPoint string, out *string) step.LambdaType {
220+
func checkMountStatus(mountPoint, name string, out *string) step.LambdaType {
221221
return func(ctx *context.Context) error {
222-
if len(*out) == 0 {
223-
return nil
222+
if *out == name {
223+
return errno.ERR_FS_PATH_ALREADY_MOUNTED.F("mountPath: %s", mountPoint)
224224
}
225-
return errno.ERR_FS_PATH_ALREADY_MOUNTED.F("mountPath: %s", mountPoint)
225+
return nil
226226
}
227227
}
228228

@@ -305,14 +305,13 @@ func NewMountFSTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.T
305305
})
306306
t.AddStep(&step.ListContainers{
307307
ShowAll: true,
308-
Format: "'{{.Status}}'",
309-
Quiet: true,
308+
Format: "'{{.Names}}'",
310309
Filter: fmt.Sprintf("name=%s", containerName),
311310
Out: &out,
312311
ExecOptions: curveadm.ExecOptions(),
313312
})
314313
t.AddStep(&step.Lambda{
315-
Lambda: checkMountStatus(mountPoint, &out),
314+
Lambda: checkMountStatus(mountPoint, containerName, &out),
316315
})
317316
t.AddStep(&step.PullImage{
318317
Image: cc.GetContainerImage(),

internal/task/task/fs/umount.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ func (s *step2RemoveContainer) Execute(ctx *context.Context) error {
117117
func NewUmountFSTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error) {
118118
options := curveadm.MemStorage().Get(comm.KEY_MOUNT_OPTIONS).(MountOptions)
119119
fsId := curveadm.GetFilesystemId(options.Host, options.MountPoint)
120-
containerId, err := curveadm.Storage().GetClientContainerId(fsId)
121-
if err != nil {
122-
return nil, errno.ERR_GET_CLIENT_CONTAINER_ID_FAILED.E(err)
123-
}
124120
hc, err := curveadm.GetHost(options.Host)
125121
if err != nil {
126122
return nil, err
@@ -133,11 +129,12 @@ func NewUmountFSTask(curveadm *cli.CurveAdm, v interface{}) (*task.Task, error)
133129

134130
// add step to task
135131
var status string
132+
containerId := mountPoint2ContainerName(mountPoint)
133+
136134
t.AddStep(&step.ListContainers{
137135
ShowAll: true,
138136
Format: "'{{.Status}}'",
139-
Quiet: true,
140-
Filter: fmt.Sprintf("id=%s", containerId),
137+
Filter: fmt.Sprintf("name=%s", containerId),
141138
Out: &status,
142139
ExecOptions: curveadm.ExecOptions(),
143140
})

0 commit comments

Comments
 (0)