pingcap / pingcap/tiup

Command will trigger to stop cluster services(tiup cluster clean --log)

Open
#1,066 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/feature-request
Dominant language
Go
Stars
466
Forks
338
Avg merge
3d 7h
Merged PRs (30d)
8

Description

使用命令清理运行中的集群日志的时候(tiup cluster clean --log),

发现该动作会先关停集群然后再删除所有的日志文件。

理论清理日志和停集群没有关联而且不小心手抖下可能就掉坑了,这样实现不太好吧。

tikv.log 日志会自动截断,但没有自动清理的删除, 通常我们清理日志如:
find ./.log ! -ctime -7 -exec rm {} ;

# tiup --version
v1.3.1 tiup
Go Version: go1.13
Git Branch: release-1.3
GitHash: d51bd0c

# tiup cluster --version
Starting component `cluster`: /root/.tiup/components/cluster/v1.3.1/tiup-cluster --version
tiup version v1.3.1 tiup
Go Version: go1.13
Git Branch: release-1.3
GitHash: d51bd0c

tiup 输出日志

[root@ip-xxx.xx.x-51 log]# tiup cluster clean tidb-dylan --log -R tikv
Starting component `cluster`: /root/.tiup/components/cluster/v1.3.1/tiup-cluster clean tidb-dylan --log -R tikv

Error: unknown shorthand flag: 'R' in -R

Verbose debug logs has been written to /root/.tiup/logs/tiup-cluster-debug-2021-01-13-17-23-17.log.
Error: run `/root/.tiup/components/cluster/v1.3.1/tiup-cluster` (wd:/root/.tiup/data/SLxqtjT) failed: exit status 1
[root@ip-xxx.xx.x-51 log]# tiup cluster clean tidb-dylan --log
Starting component `cluster`: /root/.tiup/components/cluster/v1.3.1/tiup-cluster clean tidb-dylan --log
This operation will stop tidb v4.0.9 cluster tidb-dylan and clean its' log.
Nodes will be ignored: []
Roles will be ignored: []
Files to be deleted are: 
xxx.xx.x.51:
 /data2/dylan/deploy/prometheus-19090/log/*.log
 /data2/dylan/deploy/tiflash-9000/log/*.log
 /data2/dylan/deploy/pd-12379/log/*.log
 /data2/dylan/deploy/alertmanager-19093/log/*.log
 /data2/dylan/deploy/grafana-13000/log/*.log
xxx.xx.x.52:
 /data2/dylan/deploy/tidb-4008/log/*.log
 /data2/dylan/deploy/pd-12379/log/*.log
xxx.xx.x.53:
 /data2/dylan/deploy/tidb-4008/log/*.log
 /data2/dylan/deploy/tikv-11160/log/*.log
 /data2/dylan/deploy/pd-12379/log/*.log
xxx.xx.x.54:
 /data2/dylan/deploy/tikv-11160/log/*.log
xxx.xx.x.55:
 /data2/dylan/deploy/tikv-11160/log/*.log
Do you want to continue? [y/N]: y
Cleanup cluster...
+ [ Serial ] - SSHKeySet: privateKey=/root/.tiup/storage/cluster/clusters/tidb-dylan/ssh/id_rsa, publicKey=/root/.tiup/storage/cluster/clusters/tidb-dylan/ssh/id_rsa.pub
+ [Parallel] - UserSSH: user=tidb, host=xxx.xx.x.51
+ [Parallel] - UserSSH: user=tidb, host=xxx.xx.x.55
+ [Parallel] - UserSSH: user=tidb, host=xxx.xx.x.51
+ [Parallel] - UserSSH: user=tidb, host=xxx.xx.x.51
+ [Parallel] - UserSSH: user=tidb, host=xxx.xx.x.51
+ [Parallel] - UserSSH: user=tidb, host=xxx.xx.x.54
+ [Parallel] - UserSSH: user=tidb, host=xxx.xx.x.53
+ [Parallel] - UserSSH: user=tidb, host=xxx.xx.x.52
+ [Parallel] - UserSSH: user=tidb, host=xxx.xx.x.53
+ [Parallel] - UserSSH: user=tidb, host=xxx.xx.x.51
+ [Parallel] - UserSSH: user=tidb, host=xxx.xx.x.53
+ [Parallel] - UserSSH: user=tidb, host=xxx.xx.x.52
+ [ Serial ] - StopCluster
Stopping component alertmanager
        Stopping instance xxx.xx.x.51
        Stop alertmanager xxx.xx.x.51:19093 success
Stopping component grafana
        Stopping instance xxx.xx.x.51
        Stop grafana xxx.xx.x.51:13000 success
Stopping component prometheus
        Stopping instance xxx.xx.x.51
        Stop prometheus xxx.xx.x.51:19090 success
Stopping component tiflash
        Stopping instance xxx.xx.x.51
        Stop tiflash xxx.xx.x.51:9000 success
Stopping component tidb
        Stopping instance xxx.xx.x.53
        Stopping instance xxx.xx.x.52
        Stop tidb xxx.xx.x.53:4008 success
        Stop tidb xxx.xx.x.52:4008 success
Stopping component tikv
        Stopping instance xxx.xx.x.55
        Stopping instance xxx.xx.x.53
        Stopping instance xxx.xx.x.54
        Stop tikv xxx.xx.x.55:11160 success
        Stop tikv xxx.xx.x.54:11160 success
        Stop tikv xxx.xx.x.53:11160 success
Stopping component node_exporter
Stopping component blackbox_exporter
Stopping component node_exporter
Stopping component blackbox_exporter
Stopping component pd
        Stopping instance xxx.xx.x.53
        Stopping instance xxx.xx.x.52
        Stopping instance xxx.xx.x.51
        Stop pd xxx.xx.x.51:12379 success
        Stop pd xxx.xx.x.53:12379 success
        Stop pd xxx.xx.x.52:12379 success
Stopping component node_exporter
Stopping component blackbox_exporter
Stopping component node_exporter
Stopping component blackbox_exporter
Stopping component node_exporter
Stopping component blackbox_exporter
+ [ Serial ] - CleanupCluster
Cleanup instance xxx.xx.x.53
Cleanup xxx.xx.x.53 success
Cleanup instance xxx.xx.x.54
Cleanup xxx.xx.x.54 success
Cleanup instance xxx.xx.x.55
Cleanup xxx.xx.x.55 success
Cleanup instance xxx.xx.x.51
Cleanup xxx.xx.x.51 success
Cleanup instance xxx.xx.x.52
Cleanup xxx.xx.x.52 success
Cleanup cluster `tidb-dylan` successfully

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the tiup cluster clean --log command entry point and its cleanup flow. Reproduce the command against a test cluster or inspect existing command tests if available; done means cleaning logs no longer stops cluster services and the log files are still removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.