mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdctl: connect to the same endpoint as the target to be maintained
The client may connect to a different endpint as the target to be maintained. When auth is enabled, the target endpoint might haven't finished applying the authentiation request, so it might reject the corresponding maintenance request due to permission denied. Signed-off-by: Benjamin Wang <wachao@vmware.com>
This commit is contained in:
parent
7f46da223d
commit
74085136b3
@ -35,10 +35,11 @@ func NewDefragCommand() *cobra.Command {
|
||||
}
|
||||
|
||||
func defragCommandFunc(cmd *cobra.Command, args []string) {
|
||||
|
||||
failures := 0
|
||||
c := mustClientFromCmd(cmd)
|
||||
cfg := clientConfigFromCmd(cmd)
|
||||
for _, ep := range endpointsFromCluster(cmd) {
|
||||
cfg.Endpoints = []string{ep}
|
||||
c := mustClient(cfg)
|
||||
ctx, cancel := commandCtx(cmd)
|
||||
start := time.Now()
|
||||
_, err := c.Defragment(ctx, ep)
|
||||
@ -50,6 +51,7 @@ func defragCommandFunc(cmd *cobra.Command, args []string) {
|
||||
} else {
|
||||
fmt.Printf("Finished defragmenting etcd member[%s]. took %s\n", ep, d.String())
|
||||
}
|
||||
c.Close()
|
||||
}
|
||||
|
||||
if failures != 0 {
|
||||
|
@ -191,14 +191,17 @@ type epStatus struct {
|
||||
}
|
||||
|
||||
func epStatusCommandFunc(cmd *cobra.Command, args []string) {
|
||||
c := mustClientFromCmd(cmd)
|
||||
cfg := clientConfigFromCmd(cmd)
|
||||
|
||||
var statusList []epStatus
|
||||
var err error
|
||||
for _, ep := range endpointsFromCluster(cmd) {
|
||||
cfg.Endpoints = []string{ep}
|
||||
c := mustClient(cfg)
|
||||
ctx, cancel := commandCtx(cmd)
|
||||
resp, serr := c.Status(ctx, ep)
|
||||
cancel()
|
||||
c.Close()
|
||||
if serr != nil {
|
||||
err = serr
|
||||
fmt.Fprintf(os.Stderr, "Failed to get the status of endpoint %s (%v)\n", ep, serr)
|
||||
@ -220,14 +223,17 @@ type epHashKV struct {
|
||||
}
|
||||
|
||||
func epHashKVCommandFunc(cmd *cobra.Command, args []string) {
|
||||
c := mustClientFromCmd(cmd)
|
||||
cfg := clientConfigFromCmd(cmd)
|
||||
|
||||
var hashList []epHashKV
|
||||
var err error
|
||||
for _, ep := range endpointsFromCluster(cmd) {
|
||||
cfg.Endpoints = []string{ep}
|
||||
c := mustClient(cfg)
|
||||
ctx, cancel := commandCtx(cmd)
|
||||
resp, serr := c.HashKV(ctx, ep, epHashKVRev)
|
||||
cancel()
|
||||
c.Close()
|
||||
if serr != nil {
|
||||
err = serr
|
||||
fmt.Fprintf(os.Stderr, "Failed to get the hash of endpoint %s (%v)\n", ep, serr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user