From 542a397b5a918a42c281aff743e75388c995b914 Mon Sep 17 00:00:00 2001 From: Smityz Date: Mon, 8 May 2023 19:05:44 +0800 Subject: [PATCH 1/3] mkdir for raftdb-path Signed-off-by: Smityz --- pkg/cluster/manager/deploy.go | 3 ++- pkg/cluster/spec/instance.go | 5 +++++ pkg/cluster/spec/tikv.go | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/cluster/manager/deploy.go b/pkg/cluster/manager/deploy.go index aba59074d4..9f53caba7e 100644 --- a/pkg/cluster/manager/deploy.go +++ b/pkg/cluster/manager/deploy.go @@ -266,7 +266,8 @@ func (m *Manager) Deploy( t := task.NewSimpleUerSSH(m.logger, inst.GetManageHost(), inst.GetSSHPort(), globalOptions.User, gOpt, sshProxyProps, globalOptions.SSHType). Mkdir(globalOptions.User, inst.GetManageHost(), deployDirs...). - Mkdir(globalOptions.User, inst.GetManageHost(), dataDirs...) + Mkdir(globalOptions.User, inst.GetManageHost(), dataDirs...). + Mkdir(globalOptions.User, inst.GetManageHost(), inst.ExtraDirs()...) if deployerInstance, ok := inst.(DeployerInstance); ok { deployerInstance.Deploy(t, "", deployDir, version, name, clusterVersion) diff --git a/pkg/cluster/spec/instance.go b/pkg/cluster/spec/instance.go index 56eaac76ab..43fc23a232 100644 --- a/pkg/cluster/spec/instance.go +++ b/pkg/cluster/spec/instance.go @@ -97,6 +97,7 @@ type Instance interface { GetPort() int GetSSHPort() int DeployDir() string + ExtraDirs() []string UsedPorts() []int UsedDirs() []string Status(ctx context.Context, timeout time.Duration, tlsCfg *tls.Config, pdList ...string) string @@ -360,6 +361,10 @@ func (i *BaseInstance) DeployDir() string { return reflect.Indirect(reflect.ValueOf(i.InstanceSpec)).FieldByName("DeployDir").String() } +func (i *BaseInstance) ExtraDirs() []string { + return nil +} + // TLSDir implements Instance interface func (i *BaseInstance) TLSDir() string { return i.DeployDir() diff --git a/pkg/cluster/spec/tikv.go b/pkg/cluster/spec/tikv.go index 6047bc4b9f..a76f82b03e 100644 --- a/pkg/cluster/spec/tikv.go +++ b/pkg/cluster/spec/tikv.go @@ -22,6 +22,7 @@ import ( "net/url" "os" "path/filepath" + "reflect" "strconv" "strings" "time" @@ -425,6 +426,15 @@ func (i *TiKVInstance) PostRestart(ctx context.Context, topo Topology, tlsCfg *t return nil } +func (i *TiKVInstance) ExtraDirs() []string { + configMap := reflect.Indirect(reflect.ValueOf(i.InstanceSpec)).FieldByName("Config").Interface().(map[string]interface{}) + raftDir := configMap["raftstore.raftdb-path"] + if raftDir == nil { + return nil + } + return []string{raftDir.(string)} +} + func addr(spec *TiKVSpec) string { if spec.AdvertiseAddr != "" { return spec.AdvertiseAddr From 17c01040ec128158968ef6d4cea82b542068023e Mon Sep 17 00:00:00 2001 From: Smityz Date: Tue, 9 May 2023 15:40:11 +0800 Subject: [PATCH 2/3] scale-out Signed-off-by: Smityz --- pkg/cluster/manager/builder.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/cluster/manager/builder.go b/pkg/cluster/manager/builder.go index 59f39bc817..95f0c7f43a 100644 --- a/pkg/cluster/manager/builder.go +++ b/pkg/cluster/manager/builder.go @@ -189,7 +189,8 @@ func buildScaleOutTask( tb := task.NewSimpleUerSSH(m.logger, inst.GetManageHost(), inst.GetSSHPort(), base.User, gOpt, p, sshType). Mkdir(base.User, inst.GetManageHost(), deployDirs...). Mkdir(base.User, inst.GetManageHost(), dataDirs...). - Mkdir(base.User, inst.GetManageHost(), logDir) + Mkdir(base.User, inst.GetManageHost(), logDir). + Mkdir(base.User, inst.GetManageHost(), inst.ExtraDirs()...) srcPath := "" if patchedComponents.Exist(inst.ComponentName()) { From 5db2cdbd7b14cfb84732f31c17e8da4f6a28f5e0 Mon Sep 17 00:00:00 2001 From: smityz Date: Sun, 17 Dec 2023 16:53:41 +0800 Subject: [PATCH 3/3] update --- pkg/cluster/spec/tikv.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/cluster/spec/tikv.go b/pkg/cluster/spec/tikv.go index 7132487374..5957c3c38b 100644 --- a/pkg/cluster/spec/tikv.go +++ b/pkg/cluster/spec/tikv.go @@ -22,7 +22,6 @@ import ( "net/url" "os" "path/filepath" - "reflect" "strconv" "strings" "time" @@ -463,8 +462,8 @@ func (i *TiKVInstance) PostRestart(ctx context.Context, topo Topology, tlsCfg *t } func (i *TiKVInstance) ExtraDirs() []string { - configMap := reflect.Indirect(reflect.ValueOf(i.InstanceSpec)).FieldByName("Config").Interface().(map[string]interface{}) - raftDir := configMap["raftstore.raftdb-path"] + spec := i.InstanceSpec.(*TiKVSpec) + raftDir := spec.Config["raftstore.raftdb-path"] if raftDir == nil { return nil }