Skip to content

Commit 4ccb2c2

Browse files
author
Saied Kazemi
authored
Fix the format of scamper command argument (#111)
* Fix the format of scamper command argument The flags that are passed to scamper's command (e.g., tracelb) via the -I flag should be specified as one string argument. Quotes are only needed when using the shell or printing log messages. Tests: - go test ./... - docker-compose uy (tracetool=scamper) docker exec -it trc_traceroute-caller_1 apt-get update ... scamper.go:134: Trace succeeded in context 0xc0000bd620 ... * Assign slice of args to a string variable
1 parent 2c5aafc commit 4ccb2c2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tracer/scamper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ func (s *Scamper) trace(conn connection.Connection, t time.Time) (string, error)
107107
tracelbCmd = append(tracelbCmd, []string{"-O", "ptr"}...)
108108
}
109109
tracelbCmd = append(tracelbCmd, conn.RemoteIP)
110+
iVal := strings.Join(tracelbCmd, " ")
110111
cmd := shx.Pipe(
111-
shx.Exec(s.Binary, "-I", fmt.Sprintf("%q", strings.Join(tracelbCmd, " ")), "-o-", "-O", "json"),
112+
shx.Exec(s.Binary, "-I", iVal, "-o-", "-O", "json"),
112113
shx.Write(&buff),
113114
)
114115

115116
// Now run the command.
116-
log.Printf("Trace started in context %p (%s -I \"%s\" -o- -O json)\n",
117-
ctx, s.Binary, strings.Join(tracelbCmd, " "))
117+
log.Printf("Trace started in context %p (%s -I %q -o- -O json)\n", ctx, s.Binary, iVal)
118118
start := time.Now()
119119
err = cmd.Run(ctx, shx.New())
120120
latency := time.Since(start).Seconds()

tracer/scamper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestScamper(t *testing.T) {
5252
uuid, err := conn.UUID()
5353
rtx.Must(err, "Could not make uuid")
5454
expected := `{"UUID":"` + uuid + `","TracerouteCallerVersion":"` + prometheusx.GitShortCommit + `","CachedResult":false,"CachedUUID":""}
55-
-I "tracelb -P icmp-echo -q 3 -W 0 -O ptr 10.1.1.1" -o- -O json
55+
-I tracelb -P icmp-echo -q 3 -W 0 -O ptr 10.1.1.1 -o- -O json
5656
`
5757
if strings.TrimSpace(out) != strings.TrimSpace(expected) {
5858
t.Error("Bad output:", out)

0 commit comments

Comments
 (0)