Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] tools-v2: add snapshot-clone-status #2442

Merged
merged 1 commit into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions tools-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ A tool for CurveFS & CurveBs.
- [query chunk](#query-chunk)
- [query segment](#query-segment)
- [status](#status-1)
- [staus etcd](#staus-etcd)
- [staus mds](#staus-mds)
- [status etcd](#status-etcd-1)
- [status mds](#status-mds-1)
- [status client](#status-client)
- [status snapshotserver](#status-snapshotserver)
- [delete](#delete-1)
- [delete peer](#delete-peer)
- [update](#update)
Expand Down Expand Up @@ -1011,7 +1012,7 @@ Output:

### status

#### staus etcd
#### status etcd

get the etcd status of curvebs

Expand All @@ -1035,7 +1036,7 @@ Output:
+---------------------+---------+----------+
```

#### staus mds
#### status mds

get the mds status of curvebs

Expand All @@ -1059,6 +1060,7 @@ Output:
+-------------------+-------------------+-------------------+----------+
```


#### status client

get the client status of curvebs
Expand All @@ -1081,6 +1083,31 @@ Output:
+-------------+----------------+---------------------+-----+
```

#### status snapshotserver

get the mds status of curvebs

Usage:

```bash
curve bs status snapshotserver
```

Output:

```bash
+---------------------+---------------------+-------------------+----------+
| ADDR | DUMMYADDR | VERSION | STATUS |
+---------------------+---------------------+-------------------+----------+
| ***.***.**.***:**** | ***.***.**.***:**** | ci+562296c7+debug | follower |
+---------------------+---------------------+ + +
| ***.***.**.***:**** | ***.***.**.***:**** | | |
+---------------------+---------------------+ +----------+
| ***.***.**.***:**** | ***.***.**.***:**** | | leader |
+---------------------+---------------------+-------------------+----------+
```


### delete

#### delete peer
Expand Down Expand Up @@ -1273,6 +1300,8 @@ Output:
| status | |
| chunkserver-status | |
| snapshot-clone-status | |
| client-status | curve bs status client |
| snapshot-clone-status | curve bs status snapshotserver |
| copysets-status | |
| chunkserver-list | |
| cluster-status | |
Expand Down
6 changes: 3 additions & 3 deletions tools-v2/docs/zh/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ docker cp ./sbin/curve de7603f17cf9:/
4. 准备配置文件,将之拷贝进 playground 容器内:
```shell
docker cp ./pkg/config/template.yaml de7603f17cf9:/etc/curve/curve.yaml
docker cp ./pkg/config/curve.yaml de7603f17cf9:/etc/curve/curve.yaml
```
5. 进入对应的容器:
Expand Down Expand Up @@ -558,10 +558,10 @@ curveadm status
make
```
3. 准备配置文件,将项目目录下的 `tools-v2/pkg/config/template.yaml` 复制到 `$(HOME)/.curve/curve.yaml`
3. 准备配置文件,将项目目录下的 `tools-v2/pkg/config/curve.yaml` 复制到 `$(HOME)/.curve/curve.yaml`
```shell
cp ./pkg/config/template.yaml ~/.curve/curve.yaml
cp ./pkg/config/curve.yaml ~/.curve/curve.yaml
```
4. 在项目目录(`curve/tools-v2`) 下执行命令/调试:
Expand Down
15 changes: 10 additions & 5 deletions tools-v2/pkg/cli/command/curvebs/status/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ func NewEtcdCommand() *cobra.Command {
}

func (eCmd *EtcdCommand) AddFlags() {
config.AddBsEtcdAddrFlag(eCmd.Cmd)
config.AddHttpTimeoutFlag(eCmd.Cmd)
config.AddBsEtcdAddrFlag(eCmd.Cmd)
Cyber-SiKu marked this conversation as resolved.
Show resolved Hide resolved
}

func (eCmd *EtcdCommand) Init(cmd *cobra.Command, args []string) error {
eCmd.health = cobrautil.HEALTH_ERROR

header := []string{cobrautil.ROW_ADDR, cobrautil.ROW_VERSION, cobrautil.ROW_STATUS}
eCmd.SetHeader(header)
eCmd.TableNew.SetAutoMergeCellsByColumnIndex(cobrautil.GetIndexSlice(
Expand All @@ -85,6 +86,7 @@ func (eCmd *EtcdCommand) Init(cmd *cobra.Command, args []string) error {
if addrErr.TypeCode() != cmderror.CODE_SUCCESS {
return fmt.Errorf(addrErr.Message)
}

for _, addr := range etcdAddrs {
// set metric
timeout := viper.GetDuration(config.VIPER_GLOBALE_HTTPTIMEOUT)
Expand Down Expand Up @@ -117,6 +119,7 @@ func (eCmd *EtcdCommand) RunCommand(cmd *cobra.Command, args []string) error {
size++
go func(m *basecmd.Metric) {
result, err := basecmd.QueryMetric(m)

var key string
var metricKey string
if m.SubUri == STATUS_SUBURI {
Expand All @@ -126,13 +129,15 @@ func (eCmd *EtcdCommand) RunCommand(cmd *cobra.Command, args []string) error {
key = "version"
metricKey = VARSION_METRIC_KEY
}

var value string
if err.TypeCode() == cmderror.CODE_SUCCESS {
value, err = basecmd.GetKeyValueFromJsonMetric(result, metricKey)
if err.TypeCode() != cmderror.CODE_SUCCESS {
errs = append(errs, err)
}
}

results <- basecmd.MetricResult{
Addr: m.Addrs[0],
Key: key,
Expand Down Expand Up @@ -166,21 +171,21 @@ func (eCmd *EtcdCommand) RunCommand(cmd *cobra.Command, args []string) error {
break
}
}
mergeErr := cmderror.MergeCmdErrorExceptSuccess(errs)
eCmd.Error = mergeErr

if len(errs) > 0 && len(errs) < len(eCmd.rows) {
eCmd.health = cobrautil.HEALTH_WARN
} else if len(errs) == 0 {
eCmd.health = cobrautil.HEALTH_OK
}

mergeErr := cmderror.MergeCmdErrorExceptSuccess(errs)
eCmd.Error = mergeErr
list := cobrautil.ListMap2ListSortByKeys(eCmd.rows, eCmd.Header, []string{
cobrautil.ROW_STATUS, cobrautil.ROW_VERSION,
})
eCmd.TableNew.AppendBulk(list)

eCmd.Result = eCmd.rows

return nil
}

Expand All @@ -206,7 +211,7 @@ func GetEtcdStatus(caller *cobra.Command) (*interface{}, *tablewriter.Table, *cm
fmt.Sprintf("--%s", config.FORMAT), config.FORMAT_NOOUT,
})
config.AlignFlagsValue(caller, etcdCmd.Cmd, []string{
config.RPCRETRYTIMES, config.RPCTIMEOUT, config.CURVEFS_MDSADDR,
config.RPCRETRYTIMES, config.RPCTIMEOUT, config.CURVEFS_ETCDADDR,
})
etcdCmd.Cmd.SilenceErrors = true
etcdCmd.Cmd.Execute()
Expand Down
10 changes: 9 additions & 1 deletion tools-v2/pkg/cli/command/curvebs/status/mds/mds.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func NewMdsCommand() *cobra.Command {
}

func (mCmd *MdsCommand) AddFlags() {
config.AddBsMdsFlagOption(mCmd.Cmd)
config.AddHttpTimeoutFlag(mCmd.Cmd)
Cyber-SiKu marked this conversation as resolved.
Show resolved Hide resolved
config.AddBsMdsFlagOption(mCmd.Cmd)
config.AddBsMdsDummyFlagOption(mCmd.Cmd)
}

Expand All @@ -84,6 +84,7 @@ func (mCmd *MdsCommand) Init(cmd *cobra.Command, args []string) error {
if addrErr.TypeCode() != cmderror.CODE_SUCCESS {
return fmt.Errorf(addrErr.Message)
}

for _, addr := range dummyAddrs {
// Use the dummy port to access the metric service
timeout := viper.GetDuration(config.VIPER_GLOBALE_HTTPTIMEOUT)
Expand Down Expand Up @@ -118,16 +119,20 @@ func (mCmd *MdsCommand) RunCommand(cmd *cobra.Command, args []string) error {
size++
go func(m *basecmd.Metric) {
result, err := basecmd.QueryMetric(m)

var key string

if m.SubUri == STATUS_SUBURI {
key = "status"
} else {
key = "version"
}

var value string
if err.TypeCode() == cmderror.CODE_SUCCESS {
value, err = basecmd.GetMetricValue(result)
}

results <- basecmd.MetricResult{
Addr: m.Addrs[0],
Key: key,
Expand Down Expand Up @@ -157,18 +162,21 @@ func (mCmd *MdsCommand) RunCommand(cmd *cobra.Command, args []string) error {
break
}
}

if len(errs) > 0 && len(errs) < len(mCmd.rows) {
mCmd.health = cobrautil.HEALTH_WARN
} else if len(errs) == 0 {
mCmd.health = cobrautil.HEALTH_OK
}

mergeErr := cmderror.MergeCmdErrorExceptSuccess(errs)
mCmd.Error = mergeErr
list := cobrautil.ListMap2ListSortByKeys(mCmd.rows, mCmd.Header, []string{
cobrautil.ROW_STATUS, cobrautil.ROW_VERSION,
})
mCmd.TableNew.AppendBulk(list)
mCmd.Result = mCmd.rows

return nil
}

Expand Down
Loading