-
Notifications
You must be signed in to change notification settings - Fork 316
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
cluster: add option for tmpdir #2505
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thank you. I'm curious in what scenario will this happen? (i.e. /tmp is mounted with noexec) |
This is a common step in hardening a system. It is included in the "CIS Rocky Linux 9 Benchmark v2.0.0" for example (available from https://downloads.cisecurity.org ). |
I have an alternative patch where instead of modifying the value of diff --git a/components/cluster/command/check.go b/components/cluster/command/check.go
index d30f85e7..fa3cd63a 100644
--- a/components/cluster/command/check.go
+++ b/components/cluster/command/check.go
@@ -71,6 +71,7 @@ it will check the new instances `,
cmd.Flags().BoolVar(&opt.ApplyFix, "apply", false, "Try to fix failed checks")
cmd.Flags().BoolVar(&opt.ExistCluster, "cluster", false, "Check existing cluster, the input is a cluster name.")
cmd.Flags().Uint64Var(&gOpt.APITimeout, "api-timeout", 10, "Timeout in seconds when querying PD APIs.")
+ cmd.Flags().StringVarP(&opt.TempDir, "tempdir", "t", "/tmp/tiup", "The temporary directory.")
return cmd
}
diff --git a/pkg/cluster/manager/check.go b/pkg/cluster/manager/check.go
index 72a4d599..6fcdd1be 100644
--- a/pkg/cluster/manager/check.go
+++ b/pkg/cluster/manager/check.go
@@ -42,8 +42,9 @@ type CheckOptions struct {
IdentityFile string // path to the private key file
UsePassword bool // use password instead of identity file for ssh connection
Opr *operator.CheckOptions
- ApplyFix bool // try to apply fixes of failed checks
- ExistCluster bool // check an exist cluster
+ ApplyFix bool // try to apply fixes of failed checks
+ ExistCluster bool // check an exist cluster
+ TempDir string // tempdir
}
// CheckCluster check cluster before deploying or upgrading
@@ -336,7 +337,7 @@ func checkSystemInfo(
topo.GlobalOptions.SSHType,
opt.User != "root" && systemdMode != spec.UserMode,
).
- Mkdir(opt.User, inst.GetManageHost(), systemdMode != spec.UserMode, filepath.Join(task.CheckToolsPathDir, "bin")).
+ Mkdir(opt.User, inst.GetManageHost(), systemdMode != spec.UserMode, filepath.Join(opt.TempDir, "bin")).
CopyComponent(
spec.ComponentCheckCollector,
inst.OS(),
@@ -344,11 +345,11 @@ func checkSystemInfo(
insightVer,
"", // use default srcPath
inst.GetManageHost(),
- task.CheckToolsPathDir,
+ opt.TempDir,
).
Shell(
inst.GetManageHost(),
- filepath.Join(task.CheckToolsPathDir, "bin", "insight"),
+ filepath.Join(opt.TempDir, "bin", "insight"),
"",
false,
).
@@ -376,7 +377,7 @@ func checkSystemInfo(
topo.GlobalOptions.SSHType,
opt.User != "root" && systemdMode != spec.UserMode,
).
- Rmdir(inst.GetManageHost(), task.CheckToolsPathDir).
+ Rmdir(inst.GetManageHost(), opt.TempDir).
BuildAsStep(" - Cleanup check files on " + utils.JoinHostPort(inst.GetManageHost(), inst.GetSSHPort()))
cleanTasks = append(cleanTasks, t3)
} |
[LGTM Timeline notifier]Timeline:
|
What problem does this PR solve?
If
/tmp
is mounted withnoexec
then copying a binary and running it won't work. This adds an option to specify an alternative directory.What is changed and how it works?
Check List
Tests
Related changes
Release notes: