-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add all mount flags to start command #12930
Changes from 9 commits
5ddb53f
4369ccc
0d33b6f
ed14104
7a01568
8927e2e
2910ecf
331034f
7b3377e
874a1d9
f8028bc
3ad2f8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,22 +51,20 @@ func showVersionInfo(k8sVersion string, cr cruntime.Manager) { | |
} | ||
|
||
// configureMounts configures any requested filesystem mounts | ||
func configureMounts(wg *sync.WaitGroup, mount bool, mountString string) { | ||
func configureMounts(wg *sync.WaitGroup, cc config.ClusterConfig) { | ||
wg.Add(1) | ||
defer wg.Done() | ||
|
||
if !mount { | ||
if !cc.Mount { | ||
return | ||
} | ||
|
||
out.Step(style.Mounting, "Creating mount {{.name}} ...", out.V{"name": mountString}) | ||
out.Step(style.Mounting, "Creating mount {{.name}} ...", out.V{"name": cc.MountString}) | ||
path := os.Args[0] | ||
mountDebugVal := 0 | ||
if klog.V(8).Enabled() { | ||
mountDebugVal = 1 | ||
} | ||
profile := viper.GetString("profile") | ||
mountCmd := exec.Command(path, "mount", "-p", profile, fmt.Sprintf("--v=%d", mountDebugVal), mountString) | ||
|
||
args := generateMountArgs(profile, cc) | ||
mountCmd := exec.Command(path, args...) | ||
mountCmd.Env = append(os.Environ(), constants.IsMinikubeChildProcess+"=true") | ||
if klog.V(8).Enabled() { | ||
mountCmd.Stdout = os.Stdout | ||
|
@@ -79,3 +77,34 @@ func configureMounts(wg *sync.WaitGroup, mount bool, mountString string) { | |
exit.Error(reason.HostMountPid, "Error writing mount pid", err) | ||
} | ||
} | ||
|
||
func generateMountArgs(profile string, cc config.ClusterConfig) []string { | ||
mountDebugVal := 0 | ||
if klog.V(8).Enabled() { | ||
mountDebugVal = 1 | ||
} | ||
|
||
args := []string{"mount", cc.MountString} | ||
flags := []struct { | ||
name string | ||
value string | ||
}{ | ||
{"profile", profile}, | ||
{"v", fmt.Sprintf("%d", mountDebugVal)}, | ||
{constants.Mount9PVersionFlag, cc.Mount9PVersion}, | ||
{constants.MountGIDFlag, cc.MountGID}, | ||
{constants.MountIPFlag, cc.MountIP}, | ||
{constants.MountMSizeFlag, fmt.Sprintf("%d", cc.MountMSize)}, | ||
{constants.MountModeFlag, fmt.Sprintf("%d", cc.MountMode)}, | ||
{constants.MountPortFlag, fmt.Sprintf("%d", cc.MountPort)}, | ||
{constants.MountTypeFlag, cc.MountType}, | ||
{constants.MountUIDFlag, cc.MountUID}, | ||
} | ||
for _, flag := range flags { | ||
sharifelgamal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
args = append(args, fmt.Sprintf("--%s", flag.name), flag.value) | ||
} | ||
for _, option := range cc.MountOptions { | ||
args = append(args, fmt.Sprintf("--%s", constants.MountOptionsFlag), option) | ||
} | ||
return args | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there any cases where flags could possess inconsistent values? Should we have logic, to say, for example, that mountSize value is out of range (maybe we want to do this in a separate PR). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I can add that is a follow up PR, I created an issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense! |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some have "Flag" at the end and some do not. Are all of these flags? Could we drop "Flag" for consistency between these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mountIP
,mountPort
&mountType
are already defined inmount.go
so I had to differentiate themThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, works for me.