Browse Source

Merge pull request #3412 from yichengq/etcdctl-sync

etcdctl: better logging for sync process
Yicheng Qin 10 years ago
parent
commit
16e9e4b3d5
1 changed files with 12 additions and 2 deletions
  1. 12 2
      etcdctl/command/util.go

+ 12 - 2
etcdctl/command/util.go

@@ -187,7 +187,15 @@ func mustNewClient(c *cli.Context) client.Client {
 		os.Exit(1)
 		os.Exit(1)
 	}
 	}
 
 
+	debug := c.GlobalBool("debug")
+	if debug {
+		client.EnablecURLDebug()
+	}
+
 	if !c.GlobalBool("no-sync") {
 	if !c.GlobalBool("no-sync") {
+		if debug {
+			fmt.Fprintf(os.Stderr, "start to sync cluster using endpoints(%s)\n", strings.Join(hc.Endpoints(), ","))
+		}
 		ctx, cancel := context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
 		ctx, cancel := context.WithTimeout(context.Background(), client.DefaultRequestTimeout)
 		err := hc.Sync(ctx)
 		err := hc.Sync(ctx)
 		cancel()
 		cancel()
@@ -199,11 +207,13 @@ func mustNewClient(c *cli.Context) client.Client {
 			handleError(ExitServerError, err)
 			handleError(ExitServerError, err)
 			os.Exit(1)
 			os.Exit(1)
 		}
 		}
+		if debug {
+			fmt.Fprintf(os.Stderr, "got endpoints(%s) after sync\n", strings.Join(hc.Endpoints(), ","))
+		}
 	}
 	}
 
 
-	if c.GlobalBool("debug") {
+	if debug {
 		fmt.Fprintf(os.Stderr, "Cluster-Endpoints: %s\n", strings.Join(hc.Endpoints(), ", "))
 		fmt.Fprintf(os.Stderr, "Cluster-Endpoints: %s\n", strings.Join(hc.Endpoints(), ", "))
-		client.EnablecURLDebug()
 	}
 	}
 
 
 	return hc
 	return hc