Skip to content

Commit 8008a90

Browse files
committed
Combine all initializer commands with && to catch any failing commands
By running two commands instead of one (the second being the cat | grep), any failures (non-zero exit code) of the first part (containing `k6 inspect`) will be lost and masked away. By chaining them all with `&&` the first non-zero RC will fail the whole command and return. Fixes: grafana#435
1 parent 2fdcbb9 commit 8008a90

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Diff for: pkg/resources/jobs/initializer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func NewInitializerJob(k6 v1alpha1.TestRunI, argLine string) (*batchv1.Job, erro
7676
// printing JSON as usual. Then parse temp file only for errors, ignoring
7777
// any other log messages.
7878
// Related: https://github.com/grafana/k6-docs/issues/877
79-
"mkdir -p $(dirname %s) && k6 archive %s -O %s %s 2> /tmp/k6logs && k6 inspect --execution-requirements %s 2> /tmp/k6logs ; ! cat /tmp/k6logs | grep 'level=error'",
79+
"mkdir -p $(dirname %s) && k6 archive %s -O %s %s 2> /tmp/k6logs && k6 inspect --execution-requirements %s 2> /tmp/k6logs && ! cat /tmp/k6logs | grep 'level=error'",
8080
archiveName, scriptName, archiveName, argLine,
8181
archiveName))
8282

Diff for: pkg/resources/jobs/initializer_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestNewInitializerJob(t *testing.T) {
6363
Name: "k6",
6464
Command: []string{
6565
"sh", "-c",
66-
"mkdir -p $(dirname /tmp/test.js.archived.tar) && k6 archive /test/test.js -O /tmp/test.js.archived.tar --out cloud 2> /tmp/k6logs && k6 inspect --execution-requirements /tmp/test.js.archived.tar 2> /tmp/k6logs ; ! cat /tmp/k6logs | grep 'level=error'",
66+
"mkdir -p $(dirname /tmp/test.js.archived.tar) && k6 archive /test/test.js -O /tmp/test.js.archived.tar --out cloud 2> /tmp/k6logs && k6 inspect --execution-requirements /tmp/test.js.archived.tar 2> /tmp/k6logs && ! cat /tmp/k6logs | grep 'level=error'",
6767
},
6868
Env: []corev1.EnvVar{},
6969
EnvFrom: []corev1.EnvFromSource{

0 commit comments

Comments
 (0)