From d37b23029c14f12447a63f39b7965965d07e9633 Mon Sep 17 00:00:00 2001 From: 9547 Date: Tue, 26 Jan 2021 23:48:25 +0800 Subject: [PATCH] fix(cluster/spec): promethus installDir with context --- pkg/cluster/spec/prometheus.go | 6 ------ pkg/cluster/spec/prometheus_test.go | 5 ++++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/cluster/spec/prometheus.go b/pkg/cluster/spec/prometheus.go index 86f5bf4ea2..9526e7dd18 100644 --- a/pkg/cluster/spec/prometheus.go +++ b/pkg/cluster/spec/prometheus.go @@ -326,12 +326,6 @@ func (i *MonitorInstance) installRules(ctx context.Context, e ctxt.Executor, dep } func (i *MonitorInstance) initRules(ctx context.Context, e ctxt.Executor, spec PrometheusSpec, paths meta.DirPaths) error { - if spec.RuleDir != "" { - return i.TransferLocalConfigDir(ctx, e, spec.RuleDir, path.Join(paths.Deploy, "conf"), func(name string) bool { - return strings.HasSuffix(name, ".rules.yml") - }) - } - // To make this step idempotent, we need cleanup old rules first cmds := []string{ "mkdir -p %[1]s/conf", diff --git a/pkg/cluster/spec/prometheus_test.go b/pkg/cluster/spec/prometheus_test.go index 131419a69e..f6186eca90 100644 --- a/pkg/cluster/spec/prometheus_test.go +++ b/pkg/cluster/spec/prometheus_test.go @@ -14,6 +14,7 @@ package spec import ( + "context" "io/ioutil" "os" "os/user" @@ -21,6 +22,7 @@ import ( "path/filepath" "testing" + "github.com/pingcap/tiup/pkg/checkpoint" "github.com/pingcap/tiup/pkg/cluster/executor" "github.com/pingcap/tiup/pkg/meta" "github.com/stretchr/testify/assert" @@ -58,7 +60,8 @@ func TestLocalRuleDirs(t *testing.T) { e, err := executor.New(executor.SSHTypeNone, false, executor.SSHConfig{Host: "127.0.0.1", User: user.Username}) assert.Nil(t, err) - err = promInstance.initRules(e, promInstance.InstanceSpec.(PrometheusSpec), meta.DirPaths{Deploy: deployDir}) + ctx := checkpoint.NewContext(context.Background()) + err = promInstance.initRules(ctx, e, promInstance.InstanceSpec.(PrometheusSpec), meta.DirPaths{Deploy: deployDir}) assert.Nil(t, err) assert.FileExists(t, path.Join(deployDir, "conf", "dummy.rules.yml"))