Skip to content

Commit a389709

Browse files
committed
Fix(migrate): chunkserver migrate
1 parent 9d83a9c commit a389709

File tree

3 files changed

+85
-3
lines changed

3 files changed

+85
-3
lines changed

cli/command/migrate.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,15 @@ var (
7171
// chunkserevr (curvebs)
7272
MIGRATE_CHUNKSERVER_STEPS = []int{
7373
playbook.BACKUP_ETCD_DATA,
74-
playbook.STOP_SERVICE,
75-
playbook.CLEAN_SERVICE, // only container
74+
// playbook.STOP_SERVICE,
75+
// playbook.CLEAN_SERVICE, // only container
7676
playbook.PULL_IMAGE,
7777
playbook.CREATE_CONTAINER,
7878
playbook.SYNC_CONFIG,
7979
playbook.CREATE_PHYSICAL_POOL,
8080
playbook.START_CHUNKSERVER,
8181
playbook.CREATE_LOGICAL_POOL,
82+
playbook.MARK_CHUNKSERVER_PENGDDING,
8283
}
8384

8485
// metaserver (curvefs)
@@ -199,7 +200,8 @@ func genMigratePlaybook(curveadm *cli.CurveAdm,
199200
// configs
200201
config := dcs2add
201202
switch step {
202-
case playbook.STOP_SERVICE,
203+
case playbook.MARK_CHUNKSERVER_PENGDDING,
204+
playbook.STOP_SERVICE,
203205
playbook.CLEAN_SERVICE:
204206
config = dcs2del
205207
case playbook.BACKUP_ETCD_DATA:

internal/playbook/factory.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const (
8383
GET_CLIENT_STATUS
8484
INSTALL_CLIENT
8585
UNINSTALL_CLIENT
86+
MARK_CHUNKSERVER_PENGDDING
8687

8788
// bs
8889
FORMAT_CHUNKFILE_POOL
@@ -247,6 +248,8 @@ func (p *Playbook) createTasks(step *PlaybookStep) (*tasks.Tasks, error) {
247248
t, err = comm.NewInstallClientTask(curveadm, config.GetCC(i))
248249
case UNINSTALL_CLIENT:
249250
t, err = comm.NewUninstallClientTask(curveadm, nil)
251+
case MARK_CHUNKSERVER_PENGDDING:
252+
t, err = comm.NewMarkChunkserverPendding(curveadm, nil)
250253
// bs
251254
case FORMAT_CHUNKFILE_POOL:
252255
t, err = bs.NewFormatChunkfilePoolTask(curveadm, config.GetFC(i))
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) 2022 NetEase Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Project: CurveAdm
19+
* Created Date: 2023-11-30
20+
* Author: Xianfei Cao (caoxianfei1)
21+
*/
22+
23+
package common
24+
25+
import (
26+
"fmt"
27+
28+
"github.com/opencurve/curveadm/cli/cli"
29+
"github.com/opencurve/curveadm/internal/configure/topology"
30+
"github.com/opencurve/curveadm/internal/task/step"
31+
"github.com/opencurve/curveadm/internal/task/task"
32+
tui "github.com/opencurve/curveadm/internal/tui/common"
33+
)
34+
35+
func NewMarkChunkserverPendding(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task.Task, error) {
36+
serviceId := curveadm.GetServiceId(dc.GetId())
37+
containerId, err := curveadm.GetContainerId(serviceId)
38+
if curveadm.IsSkip(dc) {
39+
return nil, nil
40+
} else if err != nil {
41+
return nil, err
42+
}
43+
44+
hc, err := curveadm.GetHost(dc.GetHost())
45+
if err != nil {
46+
return nil, err
47+
}
48+
49+
// new task
50+
subname := fmt.Sprintf("host=%s role=%s containerId=%s",
51+
dc.GetHost(), dc.GetRole(), tui.TrimContainerId(containerId))
52+
t := task.NewTask("Mark chunkserver pendding", subname, hc.GetSSHConfig())
53+
54+
var out string
55+
var success bool
56+
host, role := dc.GetHost(), dc.GetRole()
57+
cmd := "curvebs-tool -op=set_chunkserver -chunkserver_id=%s -chunkserver_status=pendding"
58+
t.AddStep(&step.ListContainers{
59+
ShowAll: true,
60+
Format: `"{{.ID}}"`,
61+
Filter: fmt.Sprintf("id=%s", containerId),
62+
Out: &out,
63+
ExecOptions: curveadm.ExecOptions(),
64+
})
65+
t.AddStep(&step.Lambda{
66+
Lambda: CheckContainerExist(host, role, containerId, &out),
67+
})
68+
t.AddStep(&step.ContainerExec{
69+
ContainerId: &containerId,
70+
Command: fmt.Sprintf(cmd, id),
71+
Success: &success,
72+
Out: &out,
73+
ExecOptions: curveadm.ExecOptions(),
74+
})
75+
76+
return t, nil
77+
}

0 commit comments

Comments
 (0)