Skip to content

Commit 6f88e53

Browse files
committed
[feat] tools-v2: add snapshot-clone-status
Signed-off-by: Xinlong-Chen <[email protected]>
1 parent 61c07b3 commit 6f88e53

File tree

8 files changed

+367
-81
lines changed

8 files changed

+367
-81
lines changed

tools-v2/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,30 @@ Output:
10571057
+-------------------+-------------------+-------------------+----------+
10581058
```
10591059

1060+
#### staus snapshot
1061+
1062+
get the snapshot clone status of curvefs
1063+
1064+
Usage:
1065+
1066+
```bash
1067+
curve bs status snapshot
1068+
```
1069+
1070+
Output:
1071+
1072+
```bash
1073+
+---------------------+---------------------+-------------------+----------+
1074+
| ADDR | DUMMYADDR | VERSION | STATUS |
1075+
+---------------------+---------------------+-------------------+----------+
1076+
| ***.***.**.***:**** | ***.***.**.***:**** | ci+562296c7+debug | follower |
1077+
+---------------------+---------------------+ + +
1078+
| ***.***.**.***:**** | ***.***.**.***:**** | | |
1079+
+---------------------+---------------------+ +----------+
1080+
| ***.***.**.***:**** | ***.***.**.***:**** | | leader |
1081+
+---------------------+---------------------+-------------------+----------+
1082+
```
1083+
10601084
### delete
10611085

10621086
#### delete peer

tools-v2/docs/zh/develop.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ docker cp ./sbin/curve de7603f17cf9:/
386386
4. 准备配置文件,将之拷贝进 playground 容器内:
387387
388388
```shell
389-
docker cp ./pkg/config/template.yaml de7603f17cf9:/etc/curve/curve.yaml
389+
docker cp ./pkg/config/curve.yaml de7603f17cf9:/etc/curve/curve.yaml
390390
```
391391
392392
5. 进入对应的容器:
@@ -558,10 +558,10 @@ curveadm status
558558
make
559559
```
560560
561-
3. 准备配置文件,将项目目录下的 `tools-v2/pkg/config/template.yaml` 复制到 `$(HOME)/.curve/curve.yaml`
561+
3. 准备配置文件,将项目目录下的 `tools-v2/pkg/config/curve.yaml` 复制到 `$(HOME)/.curve/curve.yaml`
562562
563563
```shell
564-
cp ./pkg/config/template.yaml ~/.curve/curve.yaml
564+
cp ./pkg/config/curve.yaml ~/.curve/curve.yaml
565565
```
566566
567567
4. 在项目目录(`curve/tools-v2`) 下执行命令/调试:

tools-v2/pkg/cli/command/curvebs/status/etcd/etcd.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ func NewEtcdCommand() *cobra.Command {
6868
}
6969

7070
func (eCmd *EtcdCommand) AddFlags() {
71-
config.AddBsEtcdAddrFlag(eCmd.Cmd)
7271
config.AddHttpTimeoutFlag(eCmd.Cmd)
72+
config.AddBsEtcdAddrFlag(eCmd.Cmd)
7373
}
7474

7575
func (eCmd *EtcdCommand) Init(cmd *cobra.Command, args []string) error {
7676
eCmd.health = cobrautil.HEALTH_ERROR
77+
7778
header := []string{cobrautil.ROW_ADDR, cobrautil.ROW_VERSION, cobrautil.ROW_STATUS}
7879
eCmd.SetHeader(header)
7980
eCmd.TableNew.SetAutoMergeCellsByColumnIndex(cobrautil.GetIndexSlice(
@@ -85,6 +86,7 @@ func (eCmd *EtcdCommand) Init(cmd *cobra.Command, args []string) error {
8586
if addrErr.TypeCode() != cmderror.CODE_SUCCESS {
8687
return fmt.Errorf(addrErr.Message)
8788
}
89+
8890
for _, addr := range etcdAddrs {
8991
// set metric
9092
timeout := viper.GetDuration(config.VIPER_GLOBALE_HTTPTIMEOUT)
@@ -117,6 +119,7 @@ func (eCmd *EtcdCommand) RunCommand(cmd *cobra.Command, args []string) error {
117119
size++
118120
go func(m *basecmd.Metric) {
119121
result, err := basecmd.QueryMetric(m)
122+
120123
var key string
121124
var metricKey string
122125
if m.SubUri == STATUS_SUBURI {
@@ -126,13 +129,15 @@ func (eCmd *EtcdCommand) RunCommand(cmd *cobra.Command, args []string) error {
126129
key = "version"
127130
metricKey = VARSION_METRIC_KEY
128131
}
132+
129133
var value string
130134
if err.TypeCode() == cmderror.CODE_SUCCESS {
131135
value, err = basecmd.GetKeyValueFromJsonMetric(result, metricKey)
132136
if err.TypeCode() != cmderror.CODE_SUCCESS {
133137
errs = append(errs, err)
134138
}
135139
}
140+
136141
results <- basecmd.MetricResult{
137142
Addr: m.Addrs[0],
138143
Key: key,
@@ -166,21 +171,21 @@ func (eCmd *EtcdCommand) RunCommand(cmd *cobra.Command, args []string) error {
166171
break
167172
}
168173
}
169-
mergeErr := cmderror.MergeCmdErrorExceptSuccess(errs)
170-
eCmd.Error = mergeErr
171174

172175
if len(errs) > 0 && len(errs) < len(eCmd.rows) {
173176
eCmd.health = cobrautil.HEALTH_WARN
174177
} else if len(errs) == 0 {
175178
eCmd.health = cobrautil.HEALTH_OK
176179
}
177180

181+
mergeErr := cmderror.MergeCmdErrorExceptSuccess(errs)
182+
eCmd.Error = mergeErr
178183
list := cobrautil.ListMap2ListSortByKeys(eCmd.rows, eCmd.Header, []string{
179184
cobrautil.ROW_STATUS, cobrautil.ROW_VERSION,
180185
})
181186
eCmd.TableNew.AppendBulk(list)
182-
183187
eCmd.Result = eCmd.rows
188+
184189
return nil
185190
}
186191

@@ -206,7 +211,7 @@ func GetEtcdStatus(caller *cobra.Command) (*interface{}, *tablewriter.Table, *cm
206211
fmt.Sprintf("--%s", config.FORMAT), config.FORMAT_NOOUT,
207212
})
208213
config.AlignFlagsValue(caller, etcdCmd.Cmd, []string{
209-
config.RPCRETRYTIMES, config.RPCTIMEOUT, config.CURVEFS_MDSADDR,
214+
config.RPCRETRYTIMES, config.RPCTIMEOUT, config.CURVEFS_ETCDADDR,
210215
})
211216
etcdCmd.Cmd.SilenceErrors = true
212217
etcdCmd.Cmd.Execute()

tools-v2/pkg/cli/command/curvebs/status/mds/mds.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ func NewMdsCommand() *cobra.Command {
5959
}
6060

6161
func (mCmd *MdsCommand) AddFlags() {
62-
config.AddBsMdsFlagOption(mCmd.Cmd)
6362
config.AddHttpTimeoutFlag(mCmd.Cmd)
63+
config.AddBsMdsFlagOption(mCmd.Cmd)
6464
config.AddBsMdsDummyFlagOption(mCmd.Cmd)
6565
}
6666

@@ -84,6 +84,7 @@ func (mCmd *MdsCommand) Init(cmd *cobra.Command, args []string) error {
8484
if addrErr.TypeCode() != cmderror.CODE_SUCCESS {
8585
return fmt.Errorf(addrErr.Message)
8686
}
87+
8788
for _, addr := range dummyAddrs {
8889
// Use the dummy port to access the metric service
8990
timeout := viper.GetDuration(config.VIPER_GLOBALE_HTTPTIMEOUT)
@@ -118,16 +119,20 @@ func (mCmd *MdsCommand) RunCommand(cmd *cobra.Command, args []string) error {
118119
size++
119120
go func(m *basecmd.Metric) {
120121
result, err := basecmd.QueryMetric(m)
122+
121123
var key string
124+
122125
if m.SubUri == STATUS_SUBURI {
123126
key = "status"
124127
} else {
125128
key = "version"
126129
}
130+
127131
var value string
128132
if err.TypeCode() == cmderror.CODE_SUCCESS {
129133
value, err = basecmd.GetMetricValue(result)
130134
}
135+
131136
results <- basecmd.MetricResult{
132137
Addr: m.Addrs[0],
133138
Key: key,
@@ -157,18 +162,21 @@ func (mCmd *MdsCommand) RunCommand(cmd *cobra.Command, args []string) error {
157162
break
158163
}
159164
}
165+
160166
if len(errs) > 0 && len(errs) < len(mCmd.rows) {
161167
mCmd.health = cobrautil.HEALTH_WARN
162168
} else if len(errs) == 0 {
163169
mCmd.health = cobrautil.HEALTH_OK
164170
}
171+
165172
mergeErr := cmderror.MergeCmdErrorExceptSuccess(errs)
166173
mCmd.Error = mergeErr
167174
list := cobrautil.ListMap2ListSortByKeys(mCmd.rows, mCmd.Header, []string{
168175
cobrautil.ROW_STATUS, cobrautil.ROW_VERSION,
169176
})
170177
mCmd.TableNew.AppendBulk(list)
171178
mCmd.Result = mCmd.rows
179+
172180
return nil
173181
}
174182

0 commit comments

Comments
 (0)