diff --git a/cmd/mirror.go b/cmd/mirror.go
index 6b22ce47ba..2616fce9f1 100644
--- a/cmd/mirror.go
+++ b/cmd/mirror.go
@@ -647,7 +647,7 @@ func initRepo(path, keyDir string) error {
// the `mirror merge` sub command
func newMirrorMergeCmd() *cobra.Command {
cmd := &cobra.Command{
- Use: "merge [mirror-dir-N]",
+ Use: "merge [mirror-dir-N]",
Example: ` tiup mirror merge tidb-community-v4.0.1 # merge v4.0.1 into current mirror
tiup mirror merge tidb-community-v4.0.1 tidb-community-v4.0.2 # merge v4.0.1 and v4.0.2 into current mirror`,
Short: "Merge two or more offline mirror",
diff --git a/components/cluster/command/deploy.go b/components/cluster/command/deploy.go
index eb47fda4fd..1848e5a05a 100644
--- a/components/cluster/command/deploy.go
+++ b/components/cluster/command/deploy.go
@@ -104,9 +104,9 @@ func postDeployHook(builder *task.Builder, topo spec.Topology) {
builder.ParallelStep("+ Check status", false, nodeInfoTask)
}
- enableTask := task.NewBuilder().Func("Enable cluster", func(ctx *task.Context) error {
+ enableTask := task.NewBuilder().Func("Setting service auto start on boot", func(ctx *task.Context) error {
return operator.Enable(ctx, topo, operator.Options{}, true)
- }).BuildAsStep("Enable cluster").SetHidden(true)
+ }).BuildAsStep("Enable service").SetHidden(true)
- builder.ParallelStep("+ Enable cluster", false, enableTask)
+ builder.Parallel(false, enableTask)
}
diff --git a/pkg/cluster/manager/deploy.go b/pkg/cluster/manager/deploy.go
index 14b5f20675..92c23a893b 100644
--- a/pkg/cluster/manager/deploy.go
+++ b/pkg/cluster/manager/deploy.go
@@ -363,6 +363,6 @@ func (m *Manager) Deploy(
}
hint := color.New(color.Bold).Sprintf("%s start %s", cliutil.OsArgs0(), name)
- log.Infof("Deployed cluster `%s` successfully, you can start the cluster via `%s`", name, hint)
+ log.Infof("Cluster `%s` deployed successfully, you can start it with command: `%s`", name, hint)
return nil
}
diff --git a/pkg/cluster/manager/edit_config.go b/pkg/cluster/manager/edit_config.go
index a8400d7809..bacb176d50 100644
--- a/pkg/cluster/manager/edit_config.go
+++ b/pkg/cluster/manager/edit_config.go
@@ -54,14 +54,14 @@ func (m *Manager) EditConfig(name string, skipConfirm bool) error {
return nil
}
- log.Infof("Apply the change...")
+ log.Infof("Applying changes...")
metadata.SetTopology(newTopo)
err = m.specManager.SaveMeta(name, metadata)
if err != nil {
return perrs.Annotate(err, "failed to save meta")
}
- log.Infof("Apply change successfully, please use `%s reload %s [-N ] [-R ]` to reload config.", cliutil.OsArgs0(), name)
+ log.Infof("Applied successfully, please use `%s reload %s [-N ] [-R ]` to reload config.", cliutil.OsArgs0(), name)
return nil
}
diff --git a/pkg/cluster/operation/check.go b/pkg/cluster/operation/check.go
index 1bb62a435a..26f6280e7f 100644
--- a/pkg/cluster/operation/check.go
+++ b/pkg/cluster/operation/check.go
@@ -669,7 +669,7 @@ func CheckTHP(e executor.Executor) *CheckResult {
return result
}
- for _, line := range strings.Split(string(stdout), "\n") {
+ for _, line := range strings.Split(strings.Trim(string(stdout), "\n"), "\n") {
if !strings.Contains(line, "[never]") {
result.Err = fmt.Errorf("THP is enabled, please disable it for best performance")
return result
diff --git a/pkg/cluster/spec/prometheus.go b/pkg/cluster/spec/prometheus.go
index 9e4cb2d94a..d5ac294bf7 100644
--- a/pkg/cluster/spec/prometheus.go
+++ b/pkg/cluster/spec/prometheus.go
@@ -199,7 +199,7 @@ func (i *MonitorInstance) InitConfig(
cfig.AddPump(pump.Host, uint64(pump.Port))
}
}
- if servers, found := topoHasField("Trainers"); found {
+ if servers, found := topoHasField("Drainers"); found {
for i := 0; i < servers.Len(); i++ {
drainer := servers.Index(i).Interface().(DrainerSpec)
uniqueHosts.Insert(drainer.Host)
diff --git a/pkg/cluster/spec/tikv.go b/pkg/cluster/spec/tikv.go
index c078ef942c..ca06acd079 100644
--- a/pkg/cluster/spec/tikv.go
+++ b/pkg/cluster/spec/tikv.go
@@ -24,6 +24,7 @@ import (
"time"
"github.com/pingcap/errors"
+ "github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/tiup/pkg/cluster/api"
"github.com/pingcap/tiup/pkg/cluster/executor"
"github.com/pingcap/tiup/pkg/cluster/template/scripts"
@@ -70,15 +71,31 @@ func checkStoreStatus(storeAddr string, tlsCfg *tls.Config, pdList ...string) st
return "Down"
}
- // only get status of the latest store, it is the store with lagest ID number
+ // only get status of the latest store, it is the store with largest ID number
// older stores might be legacy ones that already offlined
var latestStore *pdserverapi.StoreInfo
+
for _, store := range stores.Stores {
if storeAddr == store.Store.Address {
if latestStore == nil {
latestStore = store
continue
}
+
+ // If the PD leader has been switched multiple times, the store IDs
+ // may be not monitonically assigned. To workaround this, we iterate
+ // over the whole store list to see if any of the store's state is
+ // not marked as "tombstone", then use that as the result.
+ // See: https://github.com/tikv/pd/issues/3303
+ //
+ // It's logically not necessary to find the store with largest ID
+ // number anymore in this process, but we're keeping the behavior
+ // as the reasonable approach would still be using the state from
+ // latest store, and this is only a workaround.
+ if store.Store.State != metapb.StoreState_Tombstone {
+ return store.Store.StateName
+ }
+
if store.Store.Id > latestStore.Store.Id {
latestStore = store
}
diff --git a/pkg/repository/v1_repository.go b/pkg/repository/v1_repository.go
index 0a91f2d49f..dc8e78ecbf 100644
--- a/pkg/repository/v1_repository.go
+++ b/pkg/repository/v1_repository.go
@@ -207,14 +207,13 @@ func (r *V1Repository) ensureManifests() error {
verbose.Log("Ensure manifests finished in %s", time.Since(start))
}(time.Now())
- // Update snapshot.
- snapshot, err := r.updateLocalSnapshot()
- if err != nil {
+ // Update root before anything else.
+ if err := r.updateLocalRoot(); err != nil {
return errors.Trace(err)
}
- // Update root.
- err = r.updateLocalRoot()
+ // Update snapshot.
+ snapshot, err := r.updateLocalSnapshot()
if err != nil {
return errors.Trace(err)
}
@@ -353,7 +352,7 @@ func (r *V1Repository) updateLocalRoot() error {
url := FnameWithVersion(v1manifest.ManifestURLRoot, oldRoot.Version+1)
nextManifest, err := r.fetchManifestWithKeyStore(url, &newRoot, maxRootSize, &keyStore)
if err != nil {
- // Break if we have read the newest version.
+ // Break if we have read the latest version.
if errors.Cause(err) == ErrNotFound {
break
}
@@ -825,7 +824,7 @@ func (r *V1Repository) BinaryPath(installPath string, componentID string, versio
specVersion = component.Nightly
}
- // We need yanked version because we may install that version before it was yanked
+ // We need yanked version because we may have installed that version before it was yanked
versionItem, ok := component.VersionListWithYanked(r.PlatformString())[specVersion]
if !ok {
return "", errors.Errorf("no version: %s", version)
diff --git a/pkg/repository/v1_repository_test.go b/pkg/repository/v1_repository_test.go
index 27faec8dfb..b0bdd6f221 100644
--- a/pkg/repository/v1_repository_test.go
+++ b/pkg/repository/v1_repository_test.go
@@ -443,7 +443,7 @@ func TestEnsureManifests(t *testing.T) {
assert.NotContains(t, local.Saved, v1manifest.ManifestFilenameRoot)
// Happy update
- root2, priv2 := rootManifest(t)
+ root2, priv2 := rootManifest(t) // generate new root key
root, _ := repo.loadRoot()
root2.Version = root.Version + 1
mirror.Resources["/43.root.json"] = serialize(t, root2, priv, priv2)
@@ -451,11 +451,11 @@ func TestEnsureManifests(t *testing.T) {
rootMeta := snapshot.Meta[v1manifest.ManifestURLRoot]
rootMeta.Version = root2.Version
snapshot.Meta[v1manifest.ManifestURLRoot] = rootMeta
- snapStr = serialize(t, snapshot, priv)
+ snapStr = serialize(t, snapshot, priv2) // sign snapshot with new key
ts.Meta[v1manifest.ManifestURLSnapshot].Hashes[v1manifest.SHA256] = hash(snapStr)
ts.Version++
mirror.Resources[v1manifest.ManifestURLSnapshot] = snapStr
- mirror.Resources[v1manifest.ManifestURLTimestamp] = serialize(t, ts, priv)
+ mirror.Resources[v1manifest.ManifestURLTimestamp] = serialize(t, ts, priv2)
local.Saved = []string{}
err = repo.ensureManifests()