From b016e8710aba411a7cbbb0682e61259ac47cbdc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 4 Feb 2025 16:47:54 +0100 Subject: [PATCH] cluster: add option for tmpdir --- components/cluster/command/check.go | 1 + pkg/cluster/manager/check.go | 6 ++++-- pkg/cluster/task/check.go | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/cluster/command/check.go b/components/cluster/command/check.go index d30f85e765..fa3cd63a11 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 72a4d5997e..181709c0f3 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 @@ -188,6 +189,7 @@ func checkSystemInfo( applyFixTasks []*task.StepDisplay downloadTasks []*task.StepDisplay ) + task.CheckToolsPathDir = opt.TempDir logger := ctx.Value(logprinter.ContextKeyLogger).(*logprinter.Logger) insightVer := "" diff --git a/pkg/cluster/task/check.go b/pkg/cluster/task/check.go index e08c18ce26..0548e557bb 100644 --- a/pkg/cluster/task/check.go +++ b/pkg/cluster/task/check.go @@ -41,7 +41,7 @@ var ( ) // place the check utilities are stored -const ( +var ( CheckToolsPathDir = "/tmp/tiup" )