Skip to content

Commit

Permalink
fix(cluster/spec): promethus installDir with context
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvisa committed Jan 26, 2021
1 parent 3e3f7c3 commit d37b230
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 0 additions & 6 deletions pkg/cluster/spec/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion pkg/cluster/spec/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
package spec

import (
"context"
"io/ioutil"
"os"
"os/user"
"path"
"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"
Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit d37b230

Please sign in to comment.