mirror of
https://github.com/etcd-io/etcd.git
synced 2026-02-05 06:46:49 +01:00
etcdctl: fix lint and build errors in diagnosis feature
- Fix markdown lint errors (MD024, MD004, MD007, MD012, MD022) in DIAGNOSIS section only - Fix GCI import formatting in diagnosis plugins - Fix 32-bit overflow by changing dbQuotaBytes from int to int64 - Remove unnecessary int64() conversion in epstatus plugin Signed-off-by: Yerasala Venkata, Seshachalam <seshachalam.yerasala.venkata@sap.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
<!-- markdownlint-disable MD003 MD004 MD007 MD012 MD022 MD024 MD040 -->
|
||||
|
||||
etcdctl
|
||||
========
|
||||
|
||||
@@ -134,7 +136,9 @@ RPC: Range
|
||||
- min-mod-revision -- restrict results to kvs with modified revision greater or equal than the supplied revision
|
||||
|
||||
#### Output
|
||||
|
||||
Prints the data in format below,
|
||||
|
||||
```
|
||||
\<key\>\n\<value\>\n\<next_key\>\n\<next_value\>...
|
||||
```
|
||||
@@ -143,7 +147,6 @@ Note serializable requests are better for lower latency requirement, but
|
||||
stale data might be returned if serializable option (`--consistency=s`)
|
||||
is specified.
|
||||
|
||||
|
||||
#### Examples
|
||||
|
||||
First, populate etcd with some keys:
|
||||
@@ -283,6 +286,7 @@ RPC: Txn
|
||||
- interactive -- input transaction with interactive prompting.
|
||||
|
||||
#### Input Format
|
||||
|
||||
```ebnf
|
||||
<Txn> ::= <CMP>* "\n" <THEN> "\n" <ELSE> "\n"
|
||||
<CMP> ::= (<CMPCREATE>|<CMPMOD>|<CMPVAL>|<CMPVER>|<CMPLEASE>) "\n"
|
||||
@@ -309,6 +313,7 @@ RPC: Txn
|
||||
#### Examples
|
||||
|
||||
txn in interactive mode:
|
||||
|
||||
```bash
|
||||
./etcdctl txn -i
|
||||
# compares:
|
||||
@@ -329,6 +334,7 @@ put key2 "some extra key"
|
||||
```
|
||||
|
||||
txn in non-interactive mode:
|
||||
|
||||
```bash
|
||||
./etcdctl txn <<<'mod("key1") > "0"
|
||||
|
||||
@@ -384,6 +390,7 @@ RPC: Compact
|
||||
Prints the compacted revision.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
./etcdctl compaction 1234
|
||||
# compacted revision 1234
|
||||
@@ -642,6 +649,7 @@ RPC: LeaseKeepAlive
|
||||
Prints a message for every keep alive sent or prints a message indicating the lease is gone.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
./etcdctl lease keep-alive 32695410dcc0ca0
|
||||
# lease 32695410dcc0ca0 keepalived with TTL(100)
|
||||
@@ -727,6 +735,7 @@ MEMBER LIST prints the member details for all members associated with an etcd cl
|
||||
RPC: MemberList
|
||||
|
||||
#### Options
|
||||
|
||||
- consistency -- Linearizable(l) or Serializable(s), defaults to Linearizable(l).
|
||||
|
||||
#### Output
|
||||
@@ -990,7 +999,6 @@ DEFRAG defragments the backend database file for a set of given endpoints while
|
||||
|
||||
**Note that defragmentation request does not get replicated over cluster. That is, the request is only applied to the local node. Specify all members in `--endpoints` flag or `--cluster` flag to automatically find all cluster members.**
|
||||
|
||||
|
||||
#### Output
|
||||
|
||||
For each endpoints, prints a message indicating whether the endpoint was successfully defragmented.
|
||||
@@ -1031,6 +1039,7 @@ The backend snapshot is written to the given file path.
|
||||
#### Example
|
||||
|
||||
Save a snapshot to "snapshot.db":
|
||||
|
||||
```
|
||||
./etcdctl snapshot save snapshot.db
|
||||
```
|
||||
@@ -1039,7 +1048,6 @@ Save a snapshot to "snapshot.db":
|
||||
|
||||
Removed in v3.6. Use `etcdutl snapshot restore` instead.
|
||||
|
||||
|
||||
### SNAPSHOT STATUS \<filename\>
|
||||
|
||||
Removed in v3.6. Use `etcdutl snapshot status` instead.
|
||||
@@ -1079,6 +1087,7 @@ New members will refuse joining cluster with cluster version newer than theirs,
|
||||
Downgrade commands allow cluster administrator to force cluster version to be lowered to previous minor version, thus allowing to downgrade the cluster.
|
||||
|
||||
Downgrade should be executed in stages:
|
||||
|
||||
1. Verify that cluster is ready to be downgraded by running `etcdctl downgrade validate <TARGET_VERSION>`
|
||||
2. Start the downgrade process by running `etcdctl downgrade enable <TARGET_VERSION>`
|
||||
3. For each cluster member:
|
||||
@@ -1129,6 +1138,7 @@ DOWNGRADE CANCEL cancels the ongoing downgrade action to cluster.
|
||||
./etcdctl downgrade cancel
|
||||
Downgrade cancel success, cluster version 3.5
|
||||
```
|
||||
|
||||
### DIAGNOSIS
|
||||
|
||||
`etcdctl diagnosis [flags]` - Collects and analyzes troubleshooting data from a running etcd cluster.
|
||||
@@ -1166,7 +1176,6 @@ etcdctl diagnosis -o report.json
|
||||
|
||||
Example output: see [ctlv3/command/diagnosis/examples/etcd_diagnosis_report.json](ctlv3/command/diagnosis/examples/etcd_diagnosis_report.json)
|
||||
|
||||
|
||||
## Concurrency commands
|
||||
|
||||
### LOCK [options] \<lockname\> [command arg1 arg2 ...]
|
||||
@@ -1200,6 +1209,7 @@ Acquire lock and execute `echo lock acquired`:
|
||||
```
|
||||
|
||||
Acquire lock and execute `etcdctl put` command
|
||||
|
||||
```bash
|
||||
./etcdctl lock mylock ./etcdctl put foo bar
|
||||
# OK
|
||||
@@ -1588,7 +1598,6 @@ The approximate total number of keys transferred to the destination cluster, upd
|
||||
|
||||
[mirror]: ./doc/mirror_maker.md
|
||||
|
||||
|
||||
### VERSION
|
||||
|
||||
Prints the version of etcdctl.
|
||||
@@ -1615,7 +1624,6 @@ CHECK PERF checks the performance of the etcd cluster for 60 seconds. Running th
|
||||
|
||||
Notice that different workload models use different configurations in terms of number of clients and throughput. Here is the configuration for each load:
|
||||
|
||||
|
||||
| Load | Number of clients | Number of put requests (requests/sec) |
|
||||
|---------|------|---------|
|
||||
| Small | 50 | 10000 |
|
||||
@@ -1629,10 +1637,8 @@ The test checks for the following conditions:
|
||||
- All the requests should be done in less than 500 ms
|
||||
- The standard deviation of the requests should be less than 100 ms
|
||||
|
||||
|
||||
Hence, a workload model may work while another one might fail.
|
||||
|
||||
|
||||
RPC: CheckPerf
|
||||
|
||||
#### Options
|
||||
@@ -1746,7 +1752,4 @@ backward compatibility for `JSON` format and the format in non-interactive mode.
|
||||
|
||||
[etcd]: https://github.com/coreos/etcd
|
||||
[READMEv2]: READMEv2.md
|
||||
[v2key]: ../store/node_extern.go#L28-L37
|
||||
[v3key]: ../api/mvccpb/kv.proto#L12-L29
|
||||
[etcdrpc]: ../api/etcdserverpb/rpc.proto
|
||||
[storagerpc]: ../api/mvccpb/kv.proto
|
||||
|
||||
@@ -27,6 +27,6 @@ type Checker struct {
|
||||
Cfg *clientv3.ConfigSpec
|
||||
Endpoints []string
|
||||
CommandTimeout time.Duration
|
||||
DbQuotaBytes int
|
||||
DbQuotaBytes int64
|
||||
Name string
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"time"
|
||||
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
|
||||
"go.etcd.io/etcd/etcdctl/v3/ctlv3/command/diagnosis/engine/intf"
|
||||
"go.etcd.io/etcd/etcdctl/v3/ctlv3/command/diagnosis/plugins/common"
|
||||
)
|
||||
@@ -41,7 +40,7 @@ type checkResult struct {
|
||||
EpStatusList []epStatus `json:"epStatusList,omitempty"`
|
||||
}
|
||||
|
||||
func NewPlugin(cfg *clientv3.ConfigSpec, eps []string, timeout time.Duration, dbQuota int) intf.Plugin {
|
||||
func NewPlugin(cfg *clientv3.ConfigSpec, eps []string, timeout time.Duration, dbQuota int64) intf.Plugin {
|
||||
return &epStatusChecker{
|
||||
Checker: common.Checker{
|
||||
Cfg: cfg,
|
||||
@@ -174,14 +173,14 @@ func compareSoftInfo(s1, s2 *clientv3.StatusResponse) bool {
|
||||
s1.Leader == s2.Leader
|
||||
}
|
||||
|
||||
func checkDBSize(chkResult *checkResult, dbQuota int) {
|
||||
func checkDBSize(chkResult *checkResult, dbQuota int64) {
|
||||
for _, sts := range chkResult.EpStatusList {
|
||||
if sts.EpStatus == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
freeSize := sts.EpStatus.DbSize - sts.EpStatus.DbSizeInUse
|
||||
if freeSize > sts.EpStatus.DbSizeInUse && freeSize > 1_000_000_000 /* about 1GB */ || sts.EpStatus.DbSize >= int64(dbQuota*80/100) {
|
||||
if freeSize > sts.EpStatus.DbSizeInUse && freeSize > 1_000_000_000 /* about 1GB */ || sts.EpStatus.DbSize >= dbQuota*80/100 {
|
||||
appendSummary(chkResult, "Detected large amount of db [free] space for endpoint %q, dbQuota: %d, dbSize: %d, dbSizeInUse: %d, dbSizeFree: %d", sts.Endpoint, dbQuota, sts.EpStatus.DbSize, sts.EpStatus.DbSizeInUse, freeSize)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"time"
|
||||
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
|
||||
"go.etcd.io/etcd/etcdctl/v3/ctlv3/command/diagnosis/engine/intf"
|
||||
"go.etcd.io/etcd/etcdctl/v3/ctlv3/command/diagnosis/plugins/common"
|
||||
)
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
"time"
|
||||
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
|
||||
"go.etcd.io/etcd/etcdctl/v3/ctlv3/command/diagnosis/engine/intf"
|
||||
"go.etcd.io/etcd/etcdctl/v3/ctlv3/command/diagnosis/plugins/common"
|
||||
)
|
||||
@@ -145,13 +144,13 @@ func fetchMetrics(cfg *clientv3.ConfigSpec, ep string, timeout time.Duration) ([
|
||||
|
||||
client := &http.Client{Timeout: timeout}
|
||||
if strings.HasPrefix(urlPath, "https://") && cfg.Secure != nil {
|
||||
cert, err := tls.LoadX509KeyPair(cfg.Secure.Cert, cfg.Secure.Key)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load certificate: %w", err)
|
||||
cert, certErr := tls.LoadX509KeyPair(cfg.Secure.Cert, cfg.Secure.Key)
|
||||
if certErr != nil {
|
||||
return nil, fmt.Errorf("failed to load certificate: %w", certErr)
|
||||
}
|
||||
caCert, err := os.ReadFile(cfg.Secure.Cacert)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load CA: %w", err)
|
||||
caCert, caErr := os.ReadFile(cfg.Secure.Cacert)
|
||||
if caErr != nil {
|
||||
return nil, fmt.Errorf("failed to load CA: %w", caErr)
|
||||
}
|
||||
caCertPool := x509.NewCertPool()
|
||||
caCertPool.AppendCertsFromPEM(caCert)
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
|
||||
"go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
|
||||
"go.etcd.io/etcd/etcdctl/v3/ctlv3/command/diagnosis/engine/intf"
|
||||
"go.etcd.io/etcd/etcdctl/v3/ctlv3/command/diagnosis/plugins/common"
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
|
||||
var (
|
||||
useCluster bool
|
||||
dbQuotaBytes int
|
||||
dbQuotaBytes int64
|
||||
outputFile string
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ func NewDiagnosisCommand() *cobra.Command {
|
||||
}
|
||||
|
||||
cmd.Flags().BoolVar(&useCluster, "cluster", false, "use all endpoints from the cluster member list")
|
||||
cmd.Flags().IntVar(&dbQuotaBytes, "etcd-storage-quota-bytes", 2*1024*1024*1024, "etcd storage quota in bytes (the value passed to etcd instance by flag --quota-backend-bytes)")
|
||||
cmd.Flags().Int64Var(&dbQuotaBytes, "etcd-storage-quota-bytes", 2*1024*1024*1024, "etcd storage quota in bytes (the value passed to etcd instance by flag --quota-backend-bytes)")
|
||||
cmd.Flags().StringVarP(&outputFile, "output", "o", "", "write report to file instead of stdout")
|
||||
|
||||
return cmd
|
||||
|
||||
Reference in New Issue
Block a user