Skip to content

Commit af8c18c

Browse files
committed
[fix][upgrade][status] upgrade one by one; status with data/raft dir
1 parent 04999e9 commit af8c18c

File tree

9 files changed

+60
-40
lines changed

9 files changed

+60
-40
lines changed

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,21 @@
170170
"showLog": true,
171171
//"preLaunchTask": "enable-gcc-toolset"
172172
},
173+
{
174+
"name": "dingoadm upgrade",
175+
"type": "go",
176+
"request": "launch",
177+
"mode": "auto",
178+
"program": "${workspaceFolder}/cmd/dingoadm/main.go",
179+
"env": {
180+
"CGO_ENABLED": "1",
181+
"PATH": "/opt/rh/gcc-toolset-13/root/usr/bin:${env:PATH}"
182+
},
183+
"args": [
184+
"upgrade",
185+
],
186+
"showLog": true,
187+
},
173188
{
174189
"name": "dingoadm upgrade -f",
175190
"type": "go",

cli/command/status.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,11 @@ func displayStatus(dingoadm *cli.DingoAdm, dcs []*topology.DeployConfig, options
150150
}
151151
excludeCols := []string{}
152152
roles := dingoadm.GetRoles(dcs)
153-
if utils.Contains(roles, topology.ROLE_MDS_V2) {
154-
excludeCols = []string{"Data Dir"}
155-
}
156-
output, width := tui.FormatStatus(dcs[0].GetKind(), statuses, options.verbose, options.showInstances, excludeCols)
153+
isMdsv2 := utils.Contains(roles, topology.ROLE_MDS_V2)
154+
//if isMdsv2 {
155+
// excludeCols = []string{"Data Dir"}
156+
//}
157+
output, width := tui.FormatStatus(dcs[0].GetKind(), statuses, options.verbose, options.showInstances, excludeCols, isMdsv2)
157158
dingoadm.WriteOutln("")
158159

159160
switch dcs[0].GetKind() {

cli/command/upgrade.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ func genUpgradePlaybook(dingoadm *cli.DingoAdm,
132132
if len(DEPLOY_FILTER_ROLE[step]) > 0 {
133133
role := DEPLOY_FILTER_ROLE[step]
134134
stepDcs = dingoadm.FilterDeployConfigByRole(stepDcs, role)
135+
if len(stepDcs) == 0 {
136+
continue // no deploy config matched
137+
}
135138
}
136139

137140
if DEPLOY_LIMIT_SERVICE[step] > 0 {
@@ -167,25 +170,19 @@ func upgradeAtOnce(dingoadm *cli.DingoAdm, dcs []*topology.DeployConfig, options
167170
// 1) display upgrade title
168171
displayTitle(dingoadm, dcs, options)
169172

170-
// 2) confirm by user
171-
// if pass := tui.ConfirmYes(tui.DEFAULT_CONFIRM_PROMPT); !pass {
172-
// dingoadm.WriteOut(tui.PromptCancelOpetation("upgrade service"))
173-
// return errno.ERR_CANCEL_OPERATION
174-
// }
175-
176-
// 3) generate upgrade playbook
173+
// 2) generate upgrade playbook
177174
pb, err := genUpgradePlaybook(dingoadm, dcs, options)
178175
if err != nil {
179176
return err
180177
}
181178

182-
// 4) run playbook
179+
// 3) run playbook
183180
err = pb.Run()
184181
if err != nil {
185182
return err
186183
}
187184

188-
// 5) print success prompt
185+
// 4) print success prompt
189186
dingoadm.WriteOutln("")
190187
dingoadm.WriteOutln(color.GreenString("Upgrade %d services success :)", len(dcs)))
191188
return nil

internal/common/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const (
7474
SERVICE_STATUS_CLEANED = "Cleaned"
7575
SERVICE_STATUS_LOSED = "Losed"
7676
SERVICE_STATUS_UNKNOWN = "Unknown"
77+
SERVICE_DIR_ABSENT = "-"
7778

7879
// clean
7980
KEY_CLEAN_ITEMS = "CLEAN_ITEMS"

internal/configure/topology/dc_get.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
)
3636

3737
const (
38-
// service project layout
38+
// service project layout in container
3939
LAYOUT_DINGO_ROOT_DIR = "/dingo"
4040
LAYOUT_DINGOFS_ROOT_DIR = "/dingofs"
4141
LAYOUT_DINGOSTORE_ROOT_DIR = "/opt/dingo-store"
@@ -159,11 +159,16 @@ func (dc *DeployConfig) GetServiceConfig() map[string]string { return dc.service
159159
func (dc *DeployConfig) GetVariables() *variable.Variables { return dc.variables }
160160

161161
// (2): config item
162-
func (dc *DeployConfig) GetPrefix() string { return dc.getString(CONFIG_PREFIX) }
163-
func (dc *DeployConfig) GetReportUsage() bool { return dc.getBool(CONFIG_REPORT_USAGE) }
164-
func (dc *DeployConfig) GetContainerImage() string { return dc.getString(CONFIG_CONTAINER_IMAGE) }
165-
func (dc *DeployConfig) GetLogDir() string { return dc.getString(CONFIG_LOG_DIR) }
166-
func (dc *DeployConfig) GetDataDir() string { return dc.getString(CONFIG_DATA_DIR) }
162+
func (dc *DeployConfig) GetPrefix() string { return dc.getString(CONFIG_PREFIX) }
163+
func (dc *DeployConfig) GetReportUsage() bool { return dc.getBool(CONFIG_REPORT_USAGE) }
164+
func (dc *DeployConfig) GetContainerImage() string { return dc.getString(CONFIG_CONTAINER_IMAGE) }
165+
func (dc *DeployConfig) GetLogDir() string { return dc.getString(CONFIG_LOG_DIR) }
166+
func (dc *DeployConfig) GetDataDir() string {
167+
if dc.GetRole() == ROLE_MDS_V2 || dc.GetRole() == ROLE_DINGODB_EXECUTOR {
168+
return "-"
169+
}
170+
return dc.getString(CONFIG_DATA_DIR)
171+
}
167172
func (dc *DeployConfig) GetSeqOffset() int { return dc.getInt(CONFIG_SEQ_OFFSET) }
168173
func (dc *DeployConfig) GetSourceCoreDir() string { return dc.getString(CONFIG_SOURCE_CORE_DIR) }
169174
func (dc *DeployConfig) GetTargetCoreDir() string { return dc.getString(CONFIG_TARGET_CORE_DIR) }
@@ -203,8 +208,13 @@ func (dc *DeployConfig) GetListenExternalPort() int {
203208
return dc.GetListenPort()
204209
}
205210

211+
// GetDingoRaftDir returns the raft directory on the host for the Dingo Store service.
206212
func (dc *DeployConfig) GetDingoRaftDir() string {
207-
return dc.getString(CONFIG_DINGO_STORE_RAFT_DIR)
213+
if dc.GetRole() == ROLE_COORDINATOR || dc.GetRole() == ROLE_STORE {
214+
return dc.getString(CONFIG_DINGO_STORE_RAFT_DIR)
215+
} else {
216+
return "-"
217+
}
208218
}
209219

210220
func (dc *DeployConfig) GetDingoStoreServerListenHost() string {
@@ -279,6 +289,7 @@ type (
279289
SourcePath string
280290
}
281291

292+
// Layout defines the service project container path layout
282293
Layout struct {
283294
// project: curvebs/curvefs
284295
ProjectRootDir string // /curvebs
@@ -340,6 +351,7 @@ type (
340351
}
341352
)
342353

354+
// GetProjectLayout return service project container path layout
343355
func (dc *DeployConfig) GetProjectLayout() Layout {
344356
kind := dc.GetKind()
345357
role := dc.GetRole()

internal/configure/topology/dc_item.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ type (
8888
// (2) filter out the configuration item for service config OR
8989
// (3) set the default value for configuration item
9090
var (
91+
92+
// itemset is config service var on host
9193
itemset = &itemSet{
9294
items: []*item{},
9395
key2item: map[string]*item{},

internal/configure/topology/variables.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ var (
113113
{name: "service_external_port", role: []string{ROLE_METASERVER}},
114114
{name: "log_dir"},
115115
{name: "data_dir"},
116+
{name: "raft_dir", role: []string{ROLE_COORDINATOR, ROLE_STORE}},
116117
{name: "random_uuid"},
117118
}
118119

@@ -148,10 +149,11 @@ func skip(dc *DeployConfig, v Var) bool {
148149
return false
149150
}
150151

152+
// addVariables render container variable value
151153
func addVariables(dcs []*DeployConfig, idx int, vars []Var) error {
152154
dc := dcs[idx]
153155
for _, v := range vars {
154-
if skip(dc, v) == true {
156+
if skip(dc, v) {
155157
continue
156158
}
157159

@@ -300,6 +302,8 @@ func getValue(name string, dcs []*DeployConfig, idx int) string {
300302
return dc.GetProjectLayout().ServiceLogDir
301303
case "data_dir":
302304
return dc.GetProjectLayout().ServiceDataDir
305+
case "raft_dir":
306+
return dc.GetProjectLayout().DingoStoreRaftDir
303307
case "random_uuid":
304308
return uuid.NewString()
305309
case "cluster_etcd_http_addr":

internal/task/task/common/create_container.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ func getUlimits(dc *topology.DeployConfig) []string {
295295

296296
func getMountVolumes(dc *topology.DeployConfig) []step.Volume {
297297
volumes := []step.Volume{}
298-
layout := dc.GetProjectLayout()
299-
logDir := dc.GetLogDir()
300-
dataDir := dc.GetDataDir()
298+
layout := dc.GetProjectLayout() // service container path layout
299+
logDir := dc.GetLogDir() // service host log path
300+
dataDir := dc.GetDataDir() // service host data path
301301
sourceCoreDir := dc.GetSourceCoreDir()
302302
targetCoreDir := dc.GetTargetCoreDir()
303303

@@ -308,7 +308,7 @@ func getMountVolumes(dc *topology.DeployConfig) []step.Volume {
308308
})
309309
}
310310

311-
if len(dataDir) > 0 {
311+
if len(dataDir) > 0 && dataDir != comm.SERVICE_DIR_ABSENT {
312312
volumes = append(volumes, step.Volume{
313313
HostPath: dataDir,
314314
ContainerPath: layout.ServiceDataDir,

internal/tui/service/status.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func mergeStatues(statuses []task.ServiceStatus) []task.ServiceStatus {
221221
return ss
222222
}
223223

224-
func FormatStatus(kind string, statuses []task.ServiceStatus, verbose, expand bool, excludeCols []string) (string, int) {
224+
func FormatStatus(kind string, statuses []task.ServiceStatus, verbose, expand bool, excludeCols []string, isMdsv2 bool) (string, int) {
225225
lines := [][]interface{}{}
226226

227227
// title
@@ -251,7 +251,7 @@ func FormatStatus(kind string, statuses []task.ServiceStatus, verbose, expand bo
251251
})
252252
}
253253

254-
if kind == topology.KIND_DINGOSTORE {
254+
if kind == topology.KIND_DINGOSTORE || isMdsv2 {
255255
title = append(title, "Raft Dir")
256256
}
257257

@@ -265,7 +265,7 @@ func FormatStatus(kind string, statuses []task.ServiceStatus, verbose, expand bo
265265
statuses = mergeStatues(statuses)
266266
}
267267
for _, status := range statuses {
268-
if kind == topology.KIND_DINGOSTORE {
268+
if kind == topology.KIND_DINGOSTORE || isMdsv2 {
269269
lines = append(lines, []interface{}{
270270
status.Id,
271271
status.Role,
@@ -278,18 +278,6 @@ func FormatStatus(kind string, statuses []task.ServiceStatus, verbose, expand bo
278278
status.DataDir,
279279
status.RaftDir,
280280
})
281-
} else {
282-
lines = append(lines, []interface{}{
283-
status.Id,
284-
status.Role,
285-
status.Host,
286-
status.Instances,
287-
status.ContainerId,
288-
tui.DecorateMessage{Message: status.Status, Decorate: statusDecorate},
289-
utils.Choose(len(status.Ports) == 0, "-", status.Ports),
290-
status.LogDir,
291-
status.DataDir,
292-
})
293281
}
294282
}
295283

0 commit comments

Comments
 (0)