Skip to content

Commit a287980

Browse files
committed
[dingofs] support only mds services
1 parent d908c76 commit a287980

File tree

14 files changed

+124
-102
lines changed

14 files changed

+124
-102
lines changed

.vscode/launch.json

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
},
1818
"args": [
1919
"deploy",
20-
"-k",
21-
"--local"
20+
// "-k",
21+
// "--local"
2222
],
2323
"showLog": true,
2424
//"preLaunchTask": "enable-gcc-toolset"
2525
},
26-
{
26+
{
2727
"name": "dingoadm deploy dingo-store",
2828
"type": "go",
2929
"request": "launch",
@@ -41,6 +41,24 @@
4141
],
4242
"showLog": true,
4343
},
44+
{
45+
"name": "dingoadm deploy mdsv2 only",
46+
"type": "go",
47+
"request": "launch",
48+
"mode": "auto",
49+
"program": "${workspaceFolder}/cmd/dingoadm/main.go",
50+
"env": {
51+
"CGO_ENABLED": "1",
52+
"PATH": "/opt/rh/gcc-toolset-13/root/usr/bin:${env:PATH}",
53+
"dingo_cluster": "mdsv2-only"
54+
},
55+
"args": [
56+
"deploy",
57+
"-k",
58+
"--local"
59+
],
60+
"showLog": true,
61+
},
4462
{
4563
"name": "dingoadm -u",
4664
"type": "go",
@@ -173,6 +191,24 @@
173191
],
174192
"showLog": true,
175193
},
194+
{
195+
"name": "dingoadm cluster add mdsv2 only",
196+
"type": "go",
197+
"request": "launch",
198+
"mode": "auto",
199+
"program": "${workspaceFolder}/cmd/dingoadm/main.go",
200+
"env": {
201+
"CGO_ENABLED": "1",
202+
"PATH": "/opt/rh/gcc-toolset-13/root/usr/bin:${env:PATH}"
203+
},
204+
"args": [
205+
"cluster",
206+
"add",
207+
"mdsv2-only",
208+
"-f=/home/dongwei/deploy/dingofs/topology-mdsv2-only.yaml",
209+
],
210+
"showLog": true,
211+
},
176212
{
177213
"name": "dingoadm cluster checkout",
178214
"type": "go",
@@ -324,7 +360,23 @@
324360
"args": [
325361
"config",
326362
"commit",
327-
"/home/dongwei/deploy/dingofs/topology-mdsv2-v6-sync-java-opts.sh"
363+
"/home/dongwei/deploy/dingofs/topology-mdsv2-v6-sync-java-opts.yaml"
364+
],
365+
"showLog": true
366+
},
367+
{
368+
"name": "dingoadm config commit mdsv2-only",
369+
"type": "go",
370+
"request": "launch",
371+
"mode": "auto",
372+
"program": "${workspaceFolder}/cmd/dingoadm/main.go",
373+
"env": {
374+
"dingo_cluster": "mdsv2-only"
375+
},
376+
"args": [
377+
"config",
378+
"commit",
379+
"/home/dongwei/deploy/dingofs/topology-mdsv2-only.yaml"
328380
],
329381
"showLog": true
330382
},

cli/command/cluster/add.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,7 @@ func genCheckTopologyPlaybook(dingoadm *cli.DingoAdm,
106106
kind := dcs[0].GetKind()
107107
roles := dingoadm.GetRoles(dcs)
108108

109-
var skipRoles []string
110-
if kind == topology.KIND_DINGOFS {
111-
if kind == topology.KIND_DINGOFS {
112-
if !utils.Contains(roles, topology.ROLE_COORDINATOR) {
113-
skipRoles = append(skipRoles, topology.ROLE_COORDINATOR, topology.ROLE_STORE, topology.ROLE_MDS_V2)
114-
} else {
115-
skipRoles = append(skipRoles, topology.ROLE_ETCD, topology.ROLE_METASERVER, topology.ROLE_MDS_V2)
116-
}
117-
}
118-
}
109+
skipRoles := topology.FetchSkipRoles(kind, dcs, roles)
119110
pb := playbook.NewPlaybook(dingoadm)
120111
for _, step := range steps {
121112
pb.AddStep(&playbook.PlaybookStep{

cli/command/config/commit.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,7 @@ func genCheckTopologyPlaybook(dingoadm *cli.DingoAdm,
120120
kind := dcs[0].GetKind()
121121
roles := dingoadm.GetRoles(dcs)
122122

123-
var skipRoles []string
124-
if kind == topology.KIND_DINGOFS {
125-
if !utils.Contains(roles, topology.ROLE_COORDINATOR) {
126-
skipRoles = append(skipRoles, topology.ROLE_COORDINATOR, topology.ROLE_STORE, topology.ROLE_MDS_V2)
127-
} else {
128-
skipRoles = append(skipRoles, topology.ROLE_ETCD, topology.ROLE_METASERVER, topology.ROLE_MDS_V2)
129-
}
130-
}
131-
123+
skipRoles := topology.FetchSkipRoles(kind, dcs, roles)
132124
for _, step := range steps {
133125
pb.AddStep(&playbook.PlaybookStep{
134126
Type: step,

cli/command/deploy.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ var (
121121
CLEAN_PRECHECK_ENVIRONMENT,
122122
PULL_IMAGE,
123123
CREATE_CONTAINER,
124-
// SYNC_MDSV2_CONFIG
125-
// CREATE_META_TABLES,
124+
CREATE_MDSV2_CLI_CONTAINER,
125+
SYNC_CONFIG,
126+
START_MDSV2_CLI_CONTAINER,
127+
CREATE_META_TABLES,
126128
START_MDSV2,
127129
}
128130

@@ -329,17 +331,14 @@ func genDeployPlaybook(dingoadm *cli.DingoAdm,
329331
switch kind {
330332
case topology.KIND_DINGOFS:
331333
if utils.Contains(roles, topology.ROLE_COORDINATOR) {
332-
if len(roles) == 1 {
333-
// only mds v2, no coordinator/store
334-
steps = DINGOFS_MDSV2_ONLY_DEPLOY_STEPS
335-
} else {
336-
// mds v2 with coordinator/store
337-
steps = DINGOFS_MDSV2_FOLLOW_DEPLOY_STEPS
338-
if !utils.Contains(roles, topology.ROLE_DINGODB_EXECUTOR) {
339-
// remove executor reference step which is the last step
340-
steps = steps[:len(steps)-1]
341-
}
334+
// mds v2 with coordinator/store
335+
steps = DINGOFS_MDSV2_FOLLOW_DEPLOY_STEPS
336+
if !utils.Contains(roles, topology.ROLE_DINGODB_EXECUTOR) {
337+
// remove executor reference step which is the last step
338+
steps = steps[:len(steps)-1]
342339
}
340+
} else if utils.ContainsList(roles, []string{topology.ROLE_MDS_V2, topology.ROLE_MDSV2_CLI}) {
341+
steps = DINGOFS_MDSV2_ONLY_DEPLOY_STEPS
343342
} else if !utils.Contains(roles, topology.ROLE_METASERVER) {
344343
steps = DINGOFS_MDS_DEPLOY_STEPS
345344
} else {

cli/command/precheck.go

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,6 @@ const (
5959
)
6060

6161
var (
62-
CURVEBS_PRECHECK_STEPS = []int{
63-
playbook.CHECK_TOPOLOGY, // topology
64-
playbook.CHECK_SSH_CONNECT, // ssh
65-
playbook.CHECK_PERMISSION, // permission
66-
playbook.CHECK_KERNEL_VERSION, // kernel
67-
playbook.CLEAN_PRECHECK_ENVIRONMENT, // <none>
68-
playbook.CHECK_PORT_IN_USE, // network
69-
playbook.CHECK_DESTINATION_REACHABLE,
70-
playbook.START_HTTP_SERVER,
71-
playbook.CHECK_NETWORK_FIREWALL,
72-
playbook.GET_HOST_DATE, // date
73-
playbook.CHECK_HOST_DATE,
74-
playbook.CHECK_CHUNKFILE_POOL, // service
75-
//playbook.CHECK_S3,
76-
}
77-
7862
DINGOFS_PRECHECK_STEPS = []int{
7963
playbook.CHECK_TOPOLOGY, // topology
8064
playbook.CHECK_SSH_CONNECT, // ssh
@@ -188,17 +172,9 @@ func genPrecheckPlaybook(dingoadm *cli.DingoAdm,
188172
options precheckOptions) (*playbook.Playbook, error) {
189173
kind := dcs[0].GetKind()
190174
steps := DINGOFS_PRECHECK_STEPS
191-
if kind == topology.KIND_CURVEBS {
192-
steps = CURVEBS_PRECHECK_STEPS
193-
}
194175

195176
roles := dingoadm.GetRoles(dcs)
196-
var skipRoles []string
197-
if kind == topology.KIND_DINGOFS {
198-
if !utils.Contains(roles, topology.ROLE_MDS_V2) {
199-
skipRoles = append(skipRoles, topology.ROLE_COORDINATOR, topology.ROLE_STORE, topology.ROLE_MDS_V2)
200-
}
201-
}
177+
skipRoles := topology.FetchSkipRoles(kind, dcs, roles)
202178

203179
steps = skipPrecheckSteps(steps, options)
204180

cli/command/scale_out.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,8 @@ func checkScaleOutTopology(curveadm *cli.DingoAdm, data string) error {
229229

230230
func genScaleOutPrecheckPlaybook(curveadm *cli.DingoAdm, data string) (*playbook.Playbook, error) {
231231
dcsAll, _ := curveadm.ParseTopologyData(data)
232-
kind := dcsAll[0].GetKind()
232+
// kind := dcsAll[0].GetKind()
233233
steps := DINGOFS_PRECHECK_STEPS
234-
if kind == topology.KIND_CURVEBS {
235-
steps = CURVEBS_PRECHECK_STEPS
236-
}
237234
diffs, _ := diffTopology(curveadm, data)
238235
dcs2scaleOut := diffs[topology.DIFF_ADD]
239236

cli/command/status.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,16 @@ func displayStatus(dingoadm *cli.DingoAdm, dcs []*topology.DeployConfig, options
156156
excludeCols := []string{}
157157
roles := dingoadm.GetRoles(dcs)
158158
isMdsv2 := dcs[0].GetCtx().Lookup(topology.CTX_KEY_MDS_VERSION) == topology.CTX_VAL_MDS_V2
159+
isMdsv2Only := false
160+
if utils.ContainsList(roles, []string{topology.ROLE_MDS_V2, topology.ROLE_MDSV2_CLI}) && len(roles) == 2 {
161+
isMdsv2Only = true
162+
excludeCols = append(excludeCols, "Data Dir")
163+
}
159164

160165
output := ""
161166
width := 0
162167
if len(options.dir) == 0 {
163-
output, width = tui.FormatStatus(dcs[0].GetKind(), statuses, options.verbose, options.showInstances, excludeCols, isMdsv2)
168+
output, width = tui.FormatStatus(dcs[0].GetKind(), statuses, options.verbose, options.showInstances, excludeCols, isMdsv2, isMdsv2Only)
164169
} else {
165170
dirStrs := strings.Split(options.dir, ",")
166171
onlyDirs := []string{}
@@ -193,7 +198,7 @@ func displayStatus(dingoadm *cli.DingoAdm, dcs []*topology.DeployConfig, options
193198
dingoadm.WriteOutln("cluster name : %s", dingoadm.ClusterName())
194199
dingoadm.WriteOutln("cluster kind : %s", dcs[0].GetKind())
195200
dingoadm.WriteOutln("mds addr : %s", getClusterMdsV2Addr(dcs))
196-
if len(roles) == 1 {
201+
if utils.ContainsList(roles, []string{topology.ROLE_MDS_V2, topology.ROLE_MDSV2_CLI}) {
197202
dingoadm.WriteOutln("coordinator addr : %s", dcs[0].GetDingoStoreCoordinatorAddr())
198203
} else {
199204
dingoadm.WriteOutln("coordinator addr : %s", getClusterCoorAddr(dcs))

internal/configure/topology/dc.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ const (
8080
CTX_VAL_MDS_V2 = "v2"
8181
)
8282

83+
var SKIP_ALL_ROLES = []string{
84+
ROLE_COORDINATOR,
85+
ROLE_STORE,
86+
ROLE_MDS_V2,
87+
ROLE_ETCD,
88+
ROLE_METASERVER,
89+
ROLE_DINGODB_EXECUTOR,
90+
}
91+
8392
type (
8493
DeployConfig struct {
8594
kind string // KIND_CURVEFS / KIND_CUVREBS
@@ -328,3 +337,17 @@ func (dc *DeployConfig) Build() error {
328337
}
329338
return dc.convert()
330339
}
340+
341+
func FetchSkipRoles(kind string, dcs []*DeployConfig, roles []string) []string {
342+
var skipRoles []string
343+
if kind == KIND_DINGOFS {
344+
if dcs[0].GetCtx().Lookup(CTX_KEY_MDS_VERSION) == CTX_VAL_MDS_V1 {
345+
skipRoles = append(skipRoles, ROLE_COORDINATOR, ROLE_STORE, ROLE_MDS_V2)
346+
} else if utils.Contains(roles, ROLE_COORDINATOR) {
347+
skipRoles = append(skipRoles, ROLE_ETCD, ROLE_METASERVER, ROLE_MDS_V2)
348+
} else {
349+
skipRoles = SKIP_ALL_ROLES
350+
}
351+
}
352+
return skipRoles
353+
}

internal/configure/topology/topology.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ var (
9393
}
9494
DINGOFS_MDSV2_ONLY_ROLES = []string{
9595
ROLE_MDS_V2,
96+
ROLE_MDSV2_CLI,
9697
}
9798
DINGOFS_MDSV2_FOLLOW_ROLES = []string{
9899
ROLE_MDS_V2,
@@ -167,6 +168,9 @@ func ParseTopology(data string, ctx *Context) ([]*DeployConfig, error) {
167168
roles = append(roles, ROLE_DINGODB_EXECUTOR)
168169
ctx.Add(CTX_KEY_MDS_VERSION, CTX_VAL_MDS_V2)
169170
}
171+
} else if topology.EtcdServices.Deploy == nil {
172+
roles = append(roles, DINGOFS_MDSV2_ONLY_ROLES...)
173+
ctx.Add(CTX_KEY_MDS_VERSION, CTX_VAL_MDS_V2)
170174
} else {
171175
roles = append(roles, DINGOFS_ROLES...)
172176
ctx.Add(CTX_KEY_MDS_VERSION, CTX_VAL_MDS_V1)
@@ -211,7 +215,7 @@ func ParseTopology(data string, ctx *Context) ([]*DeployConfig, error) {
211215
case ROLE_MDSV2_CLI:
212216
// create tables role, only used to create meta tables
213217
// just keep one deploy config
214-
tmpDeploy := topology.CoordinatorServices.Deploy[0]
218+
tmpDeploy := topology.MdsServices.Deploy[0]
215219
tmpDeploy.Replicas = 0
216220
services = Service{
217221
Config: newIfNil(topology.MdsServices.Config),

internal/playbook/playbook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (p *Playbook) run(steps []*PlaybookStep) error {
9191
}
9292

9393
err = tasks.Execute(step.ExecOptions)
94-
if err != nil {
94+
if err != nil && step.Type != CHECK_PORT_IN_USE {
9595
return err
9696
}
9797

0 commit comments

Comments
 (0)