Skip to content

Commit 49e05a3

Browse files
committed
[mount] config skip pull image by '--local' when mount fs
1 parent 9b533f3 commit 49e05a3

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

cli/command/client/mount.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ var (
5353
)
5454

5555
type mountOptions struct {
56-
host string
57-
mountFSName string
58-
mountFSType string
59-
mountPoint string
60-
filename string
61-
insecure bool
56+
host string
57+
mountFSName string
58+
mountFSType string
59+
mountPoint string
60+
filename string
61+
insecure bool
62+
useLocalImage bool
6263
}
6364

6465
func checkMountOptions(curveadm *cli.CurveAdm, options mountOptions) error {
@@ -95,6 +96,7 @@ func NewMountCommand(curveadm *cli.CurveAdm) *cobra.Command {
9596
flags.StringVarP(&options.filename, "conf", "c", "client.yaml", "Specify client configuration file")
9697
flags.StringVar(&options.mountFSType, "fstype", "s3", "Specify fs data backend")
9798
flags.BoolVarP(&options.insecure, "insecure", "k", false, "Mount without precheck")
99+
flags.BoolVar(&options.useLocalImage, "local", false, "Use local image to mount")
98100

99101
return cmd
100102
}
@@ -122,6 +124,7 @@ func genMountPlaybook(curveadm *cli.CurveAdm,
122124
},
123125
comm.KEY_CLIENT_HOST: options.host, // for checker
124126
comm.KEY_CHECK_KERNEL_MODULE_NAME: comm.KERNERL_MODULE_FUSE,
127+
comm.KEY_USE_LOCAL_IMAGE: options.useLocalImage,
125128
},
126129
ExecOptions: playbook.ExecOptions{
127130
SilentSubBar: step == playbook.CHECK_CLIENT_S3,

internal/common/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const (
8585
KEY_CLIENT_STATUS_VERBOSE = "CLIENT_STATUS_VERBOSE"
8686
KEY_MAP_OPTIONS = "MAP_OPTIONS"
8787
KEY_MOUNT_OPTIONS = "MOUNT_OPTIONS"
88+
KEY_USE_LOCAL_IMAGE = "USE_LOCAL_IMAGE"
8889
CLIENT_STATUS_LOSED = "Losed"
8990
CLIENT_STATUS_UNKNOWN = "Unknown"
9091
KERNERL_MODULE_NBD = "nbd"

internal/task/task/fs/mount.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,13 @@ func NewMountFSTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.T
360360
t.AddStep(&step.Lambda{
361361
Lambda: checkMountStatus(mountPoint, containerName, &out),
362362
})
363-
t.AddStep(&step.PullImage{
364-
Image: cc.GetContainerImage(),
365-
ExecOptions: curveadm.ExecOptions(),
366-
})
363+
useLocalImage := curveadm.MemStorage().Get(comm.KEY_USE_LOCAL_IMAGE).(bool)
364+
if !useLocalImage {
365+
t.AddStep(&step.PullImage{
366+
Image: cc.GetContainerImage(),
367+
ExecOptions: curveadm.ExecOptions(),
368+
})
369+
}
367370
t.AddStep(&step.CreateContainer{
368371
Image: cc.GetContainerImage(),
369372
Command: getMountCommand(cc, mountFSName, mountFSType, mountPoint),

0 commit comments

Comments
 (0)