From 99f234a1e26c18ee98199a12499f7554e012bc92 Mon Sep 17 00:00:00 2001 From: jaffee Date: Tue, 20 Dec 2016 14:03:24 -0600 Subject: [PATCH] add run-uuid to bspawn and thread through bagent and create also add forgotten crypto/ssh dependency to vendor which adds an unfortunate number of new files for all of golang.org/x/crypto --- cmd/pilosactl/main.go | 37 ++++++++++++++++++++++++++++--------- glide.lock | 14 ++++++++++++-- glide.yaml | 3 ++- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/cmd/pilosactl/main.go b/cmd/pilosactl/main.go index 5ea23aab6..f8ef18fe7 100644 --- a/cmd/pilosactl/main.go +++ b/cmd/pilosactl/main.go @@ -31,6 +31,8 @@ import ( "github.com/pilosa/pilosa/creator" "github.com/pilosa/pilosa/pilosactl" "github.com/pilosa/pilosa/roaring" + + "github.com/satori/go.uuid" ) var ( @@ -1067,6 +1069,7 @@ The following flags are allowed: type CreateOutput struct { Hosts []string `json:"hosts"` LogFiles []string `json:"log-files"` + RunUUID string `json:"run-uuid"` } // Run executes cluster creation. @@ -1160,6 +1163,8 @@ type BagentCommand struct { // Enable pretty printing of results, for human consumption. HumanReadable bool + RunUUID string `json:"-"` // ignoring this here because we add it to the top level of the output + // Slice of pilosa hosts to run the Benchmarks against. Hosts []string `json:"hosts"` @@ -1193,9 +1198,10 @@ func (cmd *BagentCommand) ParseFlags(args []string) error { fs.SetOutput(ioutil.Discard) var pilosaHosts string - fs.StringVar(&pilosaHosts, "hosts", "localhost:15000", "Comma separated list of host:port") - fs.IntVar(&cmd.AgentNum, "agentNum", 0, "An integer differentiating this agent from other in the fleet.") - fs.BoolVar(&cmd.HumanReadable, "human", false, "Boolean to enable human-readable format.") + fs.StringVar(&pilosaHosts, "hosts", "localhost:15000", "") + fs.IntVar(&cmd.AgentNum, "agentNum", 0, "") + fs.BoolVar(&cmd.HumanReadable, "human", false, "") + fs.StringVar(&cmd.RunUUID, "run-uuid", "", "") if err := fs.Parse(args); err != nil { return err @@ -1283,6 +1289,9 @@ func (cmd *BagentCommand) Run(ctx context.Context) error { res := sbm.Run(ctx, cmd.AgentNum) res["metadata"] = cmd + if cmd.RunUUID != "" { + res["run-uuid"] = cmd.RunUUID + } enc := json.NewEncoder(cmd.Stdout) enc.SetIndent("", " ") if cmd.HumanReadable { @@ -1377,6 +1386,7 @@ pilosactl spawn configfile // Run executes the main program execution. func (cmd *BspawnCommand) Run(ctx context.Context) error { + runUUID := uuid.NewV1() if len(cmd.PilosaHosts) == 0 { // must create cluster r, w := io.Pipe() @@ -1398,15 +1408,24 @@ func (cmd *BspawnCommand) Run(ctx context.Context) error { return err } cmd.PilosaHosts = clus.Hosts + + // add runUUID to create output, and print to stdout + enc := json.NewEncoder(cmd.Stdout) + enc.SetIndent("", " ") + clus.RunUUID = runUUID.String() + err = enc.Encode(clus) + if err != nil { + return err + } } if len(cmd.AgentHosts) > 0 { - return cmd.spawnRemote(ctx) + return cmd.spawnRemote(ctx, runUUID) } else { - return cmd.spawnLocal(ctx) + return cmd.spawnLocal(ctx, runUUID) } } -func (cmd *BspawnCommand) spawnRemote(ctx context.Context) error { +func (cmd *BspawnCommand) spawnRemote(ctx context.Context, runUUID uuid.UUID) error { agentIndex := 0 agentConnections, err := pilosactl.SSHClients(cmd.AgentHosts, cmd.SSHUser, "") if err != nil { @@ -1422,7 +1441,7 @@ func (cmd *BspawnCommand) spawnRemote(ctx context.Context) error { sessions = append(sessions, sess) sess.Stdout = cmd.Stdout sess.Stderr = cmd.Stderr - err = sess.Start("pilosactl bagent -agentNum=" + strconv.Itoa(i) + " -hosts=" + strings.Join(cmd.PilosaHosts, ",") + " " + strings.Join(sp.Args, " ")) + err = sess.Start("pilosactl bagent -agentNum=" + strconv.Itoa(i) + " -hosts=" + strings.Join(cmd.PilosaHosts, ",") + " -run-uuid=" + runUUID.String() + " " + strings.Join(sp.Args, " ")) if err != nil { return err } @@ -1438,13 +1457,13 @@ func (cmd *BspawnCommand) spawnRemote(ctx context.Context) error { return nil } -func (cmd *BspawnCommand) spawnLocal(ctx context.Context) error { +func (cmd *BspawnCommand) spawnLocal(ctx context.Context, runUUID uuid.UUID) error { agents := []*BagentCommand{} for _, sp := range cmd.Benchmarks { for i := 0; i < sp.Num; i++ { agentCmd := NewBagentCommand(cmd.Stdin, cmd.Stdout, cmd.Stderr) agents = append(agents, agentCmd) - err := agentCmd.ParseFlags(append([]string{"-agentNum", strconv.Itoa(i), "-hosts", strings.Join(cmd.PilosaHosts, ",")}, sp.Args...)) + err := agentCmd.ParseFlags(append([]string{"-agentNum", strconv.Itoa(i), "-hosts", strings.Join(cmd.PilosaHosts, ","), "-run-uuid", runUUID.String()}, sp.Args...)) if err != nil { return err } diff --git a/glide.lock b/glide.lock index 56d3ba799..b931b2ff9 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 9afe91839785e89880061fd2919b0a5cdb10d6f4c06b344c2924eeed0c9bfd65 -updated: 2016-12-01T16:53:45.096741528-07:00 +hash: 3b8279eaeec5a7b790ab8f2beacc451145362e91d8d9871d1c5b2313f7cd5d19 +updated: 2016-12-20T13:41:45.723967488-06:00 imports: - name: github.com/boltdb/bolt version: 4b1ebc1869ad66568b313d0dc410e2be72670dda @@ -21,6 +21,16 @@ imports: version: a6b377e3400b08991b80d6805d627f347f983866 subpackages: - lru +- name: github.com/satori/go.uuid + version: 879c5887cd475cd7864858769793b2ceb0d44feb +- name: golang.org/x/crypto + version: d8e61c69ab46ca38328da2f4995abaf93b252290 + subpackages: + - curve25519 + - ed25519 + - ed25519/internal/edwards25519 + - ssh + - ssh/agent - name: golang.org/x/sys version: c200b10b5d5e122be351b67af224adc6128af5bf subpackages: diff --git a/glide.yaml b/glide.yaml index 5b1808065..415ed2b83 100644 --- a/glide.yaml +++ b/glide.yaml @@ -24,4 +24,5 @@ import: version: c200b10b5d5e122be351b67af224adc6128af5bf subpackages: - unix - +- package: github.com/satori/go.uuid + version: v1.1.0