Repository: grafana/k6-operator (go)

Issue:
localFile feature is broken
Hi everyone !

I wanted to use scripts embedded in K6 runner containers but this feature seems only half-implemented.
Here's what I observed :
* verified against k8s `v1.24.0` & k8s `v1.22.2`
* using operator `ghcr.io/grafana/operator:controller-v0.0.7`
* `make install` / `make deploy` from git repo master (https://github.com/grafana/k6-operator/commit/9db5af67a7d026664eac5b2879db2103c96443cc)

```bash
> kubectl describe pods -n k6-operator-system k6-operator-controller-manager-b99d48f8b-ts895
  [...]
  manager:
    Container ID:  containerd://156c3dd7a9f3859d7116875871ab4ec747747c59ad6e1d5615e202a5a2eb80ad
    Image:         ghcr.io/grafana/operator:controller-v0.0.7
    Image ID:      ghcr.io/grafana/operator@sha256:b63818f86448a574a8c069b7089bcab4997569d396473e1b1b1f35fc8d7e9f40
    Port:          <none>
    Host Port:     <none>
    Command:
      /manager
    Args:
      --metrics-addr=127.0.0.1:8080
      --enable-leader-election
  [...]

> kubectl logs -n k6-operator-system k6-operator-controller-manager-b99d48f8b-ts895
2022-05-24T11:25:57.069Z	INFO	controller-runtime.metrics	metrics server is starting to listen	{"addr": "127.0.0.1:8080"}
2022-05-24T11:25:57.172Z	INFO	setup	starting manager
I0524 11:25:57.267031       1 leaderelection.go:242] attempting to acquire leader lease  k6-operator-system/fcdfce80.io...
2022-05-24T11:25:57.272Z	INFO	controller-runtime.manager	starting metrics server	{"path": "/metrics"}
```

K6 custom resource
```yaml
---
apiVersion: k6.io/v1alpha1
kind: K6
metadata:
  name: k6-localfile-tst
spec:
  parallelism: 1
  script:
    localFile: /k6/tests/ci.js
  runner:
    image: registry.private.foo.bar/public/bundled-k6-runner:a2959ce
```

Reconcilliation log output :
```
2022-05-24T11:43:00.726Z	INFO	controllers.K6	Reconcile(); stage = initialized	{"k6": "k6-operator-system/k6-localfile-tst"}
2022-05-24T11:43:00.726Z	INFO	controllers.K6	Creating test jobs	{"k6": "k6-operator-system/k6-localfile-tst"}
2022-05-24T11:43:00.726Z	INFO	controllers.K6	Launching k6 test #1	{"k6": "k6-operator-system/k6-localfile-tst"}
2022-05-24T11:43:00.726Z	INFO	controllers.K6	Runner job is ready to start with image `registry.private.foo.bar/public/bundled-k6-runner:a2959ce` and command `[sh -c if [ ! -f /k6/tests/ci.js ]; then echo "LocalFile not found exiting..."; exit 1; fi;
k6 run --quiet /k6/tests/ci.js --address=0.0.0.0:6565 --paused]`	{"k6": "k6-operator-system/k6-localfile-tst"}
2022-05-24T11:43:00.735Z	ERROR	controllers.K6	Failed to launch k6 test	{"k6": "k6-operator-system/k6-localfile-tst", "error": "Job.batch \"k6-localfile-tst-1\" is invalid: [spec.template.spec.volumes[0].name: Required value, spec.template.spec.containers[0].volumeMounts[0].name: Required value, spec.template.spec.containers[0].volumeMounts[0].name: Not found: \"\", spec.template.spec.containers[0].volumeMounts[0].mountPath: Required value]"}
github.com/go-logr/zapr.(*zapLogger).Error
	/go/pkg/mod/github.com/go-logr/zapr@v0.1.0/zapr.go:128
github.com/grafana/k6-operator/controllers.launchTest
	/workspace/controllers/k6_create.go:80
github.com/grafana/k6-operator/controllers.createJobSpecs
	/workspace/controllers/k6_create.go:51
github.com/grafana/k6-operator/controllers.CreateJobs
	/workspace/controllers/k6_create.go:24
github.com/grafana/k6-operator/controllers.(*K6Reconciler).Reconcile
	/workspace/controllers/k6_controller.go:70
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.2/pkg/internal/controller/controller.go:235
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.2/pkg/internal/controller/controller.go:209
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).worker
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.2/pkg/internal/controller/controller.go:188
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1
	/go/pkg/mod/k8s.io/apimachinery@v0.18.6/pkg/util/wait/wait.go:155
k8s.io/apimachinery/pkg/util/wait.BackoffUntil
	/go/pkg/mod/k8s.io/apimachinery@v0.18.6/pkg/util/wait/wait.go:156
k8s.io/apimachinery/pkg/util/wait.JitterUntil
	/go/pkg/mod/k8s.io/apimachinery@v0.18.6/pkg/util/wait/wait.go:133
k8s.io/apimachinery/pkg/util/wait.Until
	/go/pkg/mod/k8s.io/apimachinery@v0.18.6/pkg/util/wait/wait.go:90
2022-05-24T11:43:00.735Z	ERROR	controller	Reconciler error	{"reconcilerGroup": "k6.io", "reconcilerKind": "K6", "controller": "k6", "name": "k6-localfile-tst", "namespace": "k6-operator-system", "error": "Job.batch \"k6-localfile-tst-1\" is invalid: [spec.template.spec.volumes[0].name: Required value, spec.template.spec.containers[0].volumeMounts[0].name: Required value, spec.template.spec.containers[0].volumeMounts[0].name: Not found: \"\", spec.template.spec.containers[0].volumeMounts[0].mountPath: Required value]"}
github.com/go-logr/zapr.(*zapLogger).Error
	/go/pkg/mod/github.com/go-logr/zapr@v0.1.0/zapr.go:128
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.2/pkg/internal/controller/controller.go:237
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.2/pkg/internal/controller/controller.go:209
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).worker
	/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.2/pkg/internal/controller/controller.go:188
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1
	/go/pkg/mod/k8s.io/apimachinery@v0.18.6/pkg/util/wait/wait.go:155
k8s.io/apimachinery/pkg/util/wait.BackoffUntil
	/go/pkg/mod/k8s.io/apimachinery@v0.18.6/pkg/util/wait/wait.go:156
k8s.io/apimachinery/pkg/util/wait.JitterUntil
	/go/pkg/mod/k8s.io/apimachinery@v0.18.6/pkg/util/wait/wait.go:133
k8s.io/apimachinery/pkg/util/wait.Until
	/go/pkg/mod/k8s.io/apimachinery@v0.18.6/pkg/util/wait/wait.go:90
```

Analysis :
* localFile feature has been added
* localFile doesn't require any Job defined volume & volumeMount to work
* Currently the controller keep trying to spawn runner jobs with empty volume, even when we don't need it :
    * https://github.com/grafana/k6-operator/blob/main/pkg/resources/jobs/initializer.go#L92-L103
    * https://github.com/grafana/k6-operator/blob/main/pkg/types/types.go#L87-L89
    * https://github.com/grafana/k6-operator/blob/main/pkg/resources/jobs/runner.go#L156-L164

Please tell me if I'm wrong but the current state of this feature seems totally broken.
We need to return an empty array of volume, not an array with a single empty default volume.

I successfully tested the localFile behavior when hard removing the volumes from the template, so I'm pretty confident that there's something wrong here. 
I'm seeing if I can work on some fix, but I you can see something better / faster I'm fully OK with that.

Thanks for your work

Pull request:
Fix of regression for localFile option
Fixes #111 

Patch:
diff --git a/pkg/resources/jobs/initializer.go b/pkg/resources/jobs/initializer.go
index 3175bdc..c15a205 100644
--- a/pkg/resources/jobs/initializer.go
+++ b/pkg/resources/jobs/initializer.go
@@ -84,23 +84,16 @@ func NewInitializerJob(k6 *v1alpha1.K6, argLine string) (*batchv1.Job, error) {
 					RestartPolicy:                corev1.RestartPolicyNever,
 					Containers: []corev1.Container{
 						{
-							Image:     image,
-							Name:      "k6",
-							Command:   command,
-							Env:       env,
-							Resources: k6.Spec.Runner.Resources,
-							VolumeMounts: []corev1.VolumeMount{
-								{
-									Name:      "k6-test-volume",
-									MountPath: "/test",
-								},
-							},
-							Ports: ports,
+							Image:        image,
+							Name:         "k6",
+							Command:      command,
+							Env:          env,
+							Resources:    k6.Spec.Runner.Resources,
+							VolumeMounts: script.VolumeMount(),
+							Ports:        ports,
 						},
 					},
-					Volumes: []corev1.Volume{
-						script.Volume(),
-					},
+					Volumes: script.Volume(),
 				},
 			},
 		},
diff --git a/pkg/resources/jobs/runner.go b/pkg/resources/jobs/runner.go
index f6f5719..7d9ddbb 100644
--- a/pkg/resources/jobs/runner.go
+++ b/pkg/resources/jobs/runner.go
@@ -148,20 +148,16 @@ func NewRunnerJob(k6 *v1alpha1.K6, index int, testRunId, token string) (*batchv1
 					NodeSelector:                 k6.Spec.Runner.NodeSelector,
 					SecurityContext:              &k6.Spec.Runner.SecurityContext,
 					Containers: []corev1.Container{{
-						Image:     image,
-						Name:      "k6",
-						Command:   command,
-						Env:       env,
-						Resources: k6.Spec.Runner.Resources,
-						VolumeMounts: []corev1.VolumeMount{
-							script.VolumeMount(),
-						},
-						Ports: ports,
+						Image:        image,
+						Name:         "k6",
+						Command:      command,
+						Env:          env,
+						Resources:    k6.Spec.Runner.Resources,
+						VolumeMounts: script.VolumeMount(),
+						Ports:        ports,
 					}},
 					TerminationGracePeriodSeconds: &zero,
-					Volumes: []corev1.Volume{
-						script.Volume(),
-					},
+					Volumes:                       script.Volume(),
 				},
 			},
 		},
diff --git a/pkg/types/types.go b/pkg/types/types.go
index 6744776..57b2d3b 100644
--- a/pkg/types/types.go
+++ b/pkg/types/types.go
@@ -61,42 +61,48 @@ func (s *Script) FullName() string {
 }
 
 // Volume creates a Volume spec for the script
-func (s *Script) Volume() corev1.Volume {
+func (s *Script) Volume() []corev1.Volume {
 	switch s.Type {
 	case "VolumeClaim":
-		return corev1.Volume{
-			Name: "k6-test-volume",
-			VolumeSource: corev1.VolumeSource{
-				PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
-					ClaimName: s.Name,
+		return []corev1.Volume{
+			corev1.Volume{
+				Name: "k6-test-volume",
+				VolumeSource: corev1.VolumeSource{
+					PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
+						ClaimName: s.Name,
+					},
 				},
 			},
 		}
 
 	case "ConfigMap":
-		return corev1.Volume{
-			Name: "k6-test-volume",
-			VolumeSource: corev1.VolumeSource{
-				ConfigMap: &corev1.ConfigMapVolumeSource{
-					LocalObjectReference: corev1.LocalObjectReference{
-						Name: s.Name,
+		return []corev1.Volume{
+			corev1.Volume{
+				Name: "k6-test-volume",
+				VolumeSource: corev1.VolumeSource{
+					ConfigMap: &corev1.ConfigMapVolumeSource{
+						LocalObjectReference: corev1.LocalObjectReference{
+							Name: s.Name,
+						},
 					},
 				},
 			},
 		}
 	default:
-		return corev1.Volume{}
+		return []corev1.Volume{}
 	}
 }
 
 // VolumeMount creates a VolumeMount spec for the script
-func (s *Script) VolumeMount() corev1.VolumeMount {
+func (s *Script) VolumeMount() []corev1.VolumeMount {
 	if s.Type == "LocalFile" {
-		return corev1.VolumeMount{}
+		return []corev1.VolumeMount{}
 	}
-	return corev1.VolumeMount{
-		Name:      "k6-test-volume",
-		MountPath: "/test",
+	return []corev1.VolumeMount{
+		corev1.VolumeMount{
+			Name:      "k6-test-volume",
+			MountPath: "/test",
+		},
 	}
 }
 


Test patch:
diff --git a/pkg/resources/jobs/initializer_test.go b/pkg/resources/jobs/initializer_test.go
index 5a3fdc8..5edd404 100644
--- a/pkg/resources/jobs/initializer_test.go
+++ b/pkg/resources/jobs/initializer_test.go
@@ -59,18 +59,13 @@ func TestNewInitializerJob(t *testing.T) {
 								"sh", "-c",
 								"k6 archive /test/test.js -O ./test.js.archived.tar --out cloud && k6 inspect --execution-requirements ./test.js.archived.tar",
 							},
-							Env:       []corev1.EnvVar{},
-							Resources: corev1.ResourceRequirements{},
-							VolumeMounts: []corev1.VolumeMount{{
-								Name:      "k6-test-volume",
-								MountPath: "/test",
-							}},
-							Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
+							Env:          []corev1.EnvVar{},
+							Resources:    corev1.ResourceRequirements{},
+							VolumeMounts: script.VolumeMount(),
+							Ports:        []corev1.ContainerPort{{ContainerPort: 6565}},
 						},
 					},
-					Volumes: []corev1.Volume{
-						script.Volume(),
-					},
+					Volumes: script.Volume(),
 				},
 			},
 		},
diff --git a/pkg/resources/jobs/runner_test.go b/pkg/resources/jobs/runner_test.go
index b532823..3832973 100644
--- a/pkg/resources/jobs/runner_test.go
+++ b/pkg/resources/jobs/runner_test.go
@@ -99,11 +99,13 @@ func TestNewScriptNoScript(t *testing.T) {
 }
 
 func TestNewVolumeSpecVolumeClaim(t *testing.T) {
-	expectedOutcome := corev1.Volume{
-		Name: "k6-test-volume",
-		VolumeSource: corev1.VolumeSource{
-			PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
-				ClaimName: "test",
+	expectedOutcome := []corev1.Volume{
+		corev1.Volume{
+			Name: "k6-test-volume",
+			VolumeSource: corev1.VolumeSource{
+				PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
+					ClaimName: "test",
+				},
 			},
 		},
 	}
@@ -120,12 +122,14 @@ func TestNewVolumeSpecVolumeClaim(t *testing.T) {
 }
 
 func TestNewVolumeSpecConfigMap(t *testing.T) {
-	expectedOutcome := corev1.Volume{
-		Name: "k6-test-volume",
-		VolumeSource: corev1.VolumeSource{
-			ConfigMap: &corev1.ConfigMapVolumeSource{
-				LocalObjectReference: corev1.LocalObjectReference{
-					Name: "test",
+	expectedOutcome := []corev1.Volume{
+		corev1.Volume{
+			Name: "k6-test-volume",
+			VolumeSource: corev1.VolumeSource{
+				ConfigMap: &corev1.ConfigMapVolumeSource{
+					LocalObjectReference: corev1.LocalObjectReference{
+						Name: "test",
+					},
 				},
 			},
 		},
@@ -143,7 +147,7 @@ func TestNewVolumeSpecConfigMap(t *testing.T) {
 }
 
 func TestNewVolumeSpecNoType(t *testing.T) {
-	expectedOutcome := corev1.Volume{}
+	expectedOutcome := []corev1.Volume{}
 
 	script := &types.Script{
 		Name: "test",
@@ -283,21 +287,16 @@ func TestNewRunnerJob(t *testing.T) {
 					ServiceAccountName:           "default",
 					AutomountServiceAccountToken: &automountServiceAccountToken,
 					Containers: []corev1.Container{{
-						Image:     "ghcr.io/grafana/operator:latest-runner",
-						Name:      "k6",
-						Command:   []string{"k6", "run", "--quiet", "/test/test.js", "--address=0.0.0.0:6565", "--paused"},
-						Env:       []corev1.EnvVar{},
-						Resources: corev1.ResourceRequirements{},
-						VolumeMounts: []corev1.VolumeMount{{
-							Name:      "k6-test-volume",
-							MountPath: "/test",
-						}},
-						Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
+						Image:        "ghcr.io/grafana/operator:latest-runner",
+						Name:         "k6",
+						Command:      []string{"k6", "run", "--quiet", "/test/test.js", "--address=0.0.0.0:6565", "--paused"},
+						Env:          []corev1.EnvVar{},
+						Resources:    corev1.ResourceRequirements{},
+						VolumeMounts: script.VolumeMount(),
+						Ports:        []corev1.ContainerPort{{ContainerPort: 6565}},
 					}},
 					TerminationGracePeriodSeconds: &zero,
-					Volumes: []corev1.Volume{
-						script.Volume(),
-					},
+					Volumes:                       script.Volume(),
 				},
 			},
 		},
@@ -380,21 +379,16 @@ func TestNewRunnerJobNoisy(t *testing.T) {
 					AutomountServiceAccountToken: &automountServiceAccountToken,
 					SecurityContext:              &corev1.PodSecurityContext{},
 					Containers: []corev1.Container{{
-						Image:     "ghcr.io/grafana/operator:latest-runner",
-						Name:      "k6",
-						Command:   []string{"k6", "run", "/test/test.js", "--address=0.0.0.0:6565", "--paused"},
-						Env:       []corev1.EnvVar{},
-						Resources: corev1.ResourceRequirements{},
-						VolumeMounts: []corev1.VolumeMount{{
-							Name:      "k6-test-volume",
-							MountPath: "/test",
-						}},
-						Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
+						Image:        "ghcr.io/grafana/operator:latest-runner",
+						Name:         "k6",
+						Command:      []string{"k6", "run", "/test/test.js", "--address=0.0.0.0:6565", "--paused"},
+						Env:          []corev1.EnvVar{},
+						Resources:    corev1.ResourceRequirements{},
+						VolumeMounts: script.VolumeMount(),
+						Ports:        []corev1.ContainerPort{{ContainerPort: 6565}},
 					}},
 					TerminationGracePeriodSeconds: &zero,
-					Volumes: []corev1.Volume{
-						script.Volume(),
-					},
+					Volumes:                       script.Volume(),
 				},
 			},
 		},
@@ -478,21 +472,16 @@ func TestNewRunnerJobUnpaused(t *testing.T) {
 					AutomountServiceAccountToken: &automountServiceAccountToken,
 					SecurityContext:              &corev1.PodSecurityContext{},
 					Containers: []corev1.Container{{
-						Image:     "ghcr.io/grafana/operator:latest-runner",
-						Name:      "k6",
-						Command:   []string{"k6", "run", "--quiet", "/test/test.js", "--address=0.0.0.0:6565"},
-						Env:       []corev1.EnvVar{},
-						Resources: corev1.ResourceRequirements{},
-						VolumeMounts: []corev1.VolumeMount{{
-							Name:      "k6-test-volume",
-							MountPath: "/test",
-						}},
-						Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
+						Image:        "ghcr.io/grafana/operator:latest-runner",
+						Name:         "k6",
+						Command:      []string{"k6", "run", "--quiet", "/test/test.js", "--address=0.0.0.0:6565"},
+						Env:          []corev1.EnvVar{},
+						Resources:    corev1.ResourceRequirements{},
+						VolumeMounts: script.VolumeMount(),
+						Ports:        []corev1.ContainerPort{{ContainerPort: 6565}},
 					}},
 					TerminationGracePeriodSeconds: &zero,
-					Volumes: []corev1.Volume{
-						script.Volume(),
-					},
+					Volumes:                       script.Volume(),
 				},
 			},
 		},
@@ -576,21 +565,16 @@ func TestNewRunnerJobArguments(t *testing.T) {
 					AutomountServiceAccountToken: &automountServiceAccountToken,
 					SecurityContext:              &corev1.PodSecurityContext{},
 					Containers: []corev1.Container{{
-						Image:     "ghcr.io/grafana/operator:latest-runner",
-						Name:      "k6",
-						Command:   []string{"k6", "run", "--quiet", "--cool-thing", "/test/test.js", "--address=0.0.0.0:6565", "--paused"},
-						Env:       []corev1.EnvVar{},
-						Resources: corev1.ResourceRequirements{},
-						VolumeMounts: []corev1.VolumeMount{{
-							Name:      "k6-test-volume",
-							MountPath: "/test",
-						}},
-						Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
+						Image:        "ghcr.io/grafana/operator:latest-runner",
+						Name:         "k6",
+						Command:      []string{"k6", "run", "--quiet", "--cool-thing", "/test/test.js", "--address=0.0.0.0:6565", "--paused"},
+						Env:          []corev1.EnvVar{},
+						Resources:    corev1.ResourceRequirements{},
+						VolumeMounts: script.VolumeMount(),
+						Ports:        []corev1.ContainerPort{{ContainerPort: 6565}},
 					}},
 					TerminationGracePeriodSeconds: &zero,
-					Volumes: []corev1.Volume{
-						script.Volume(),
-					},
+					Volumes:                       script.Volume(),
 				},
 			},
 		},
@@ -675,21 +659,16 @@ func TestNewRunnerJobServiceAccount(t *testing.T) {
 					AutomountServiceAccountToken: &automountServiceAccountToken,
 					SecurityContext:              &corev1.PodSecurityContext{},
 					Containers: []corev1.Container{{
-						Image:     "ghcr.io/grafana/operator:latest-runner",
-						Name:      "k6",
-						Command:   []string{"k6", "run", "--quiet", "/test/test.js", "--address=0.0.0.0:6565", "--paused"},
-						Env:       []corev1.EnvVar{},
-						Resources: corev1.ResourceRequirements{},
-						VolumeMounts: []corev1.VolumeMount{{
-							Name:      "k6-test-volume",
-							MountPath: "/test",
-						}},
-						Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
+						Image:        "ghcr.io/grafana/operator:latest-runner",
+						Name:         "k6",
+						Command:      []string{"k6", "run", "--quiet", "/test/test.js", "--address=0.0.0.0:6565", "--paused"},
+						Env:          []corev1.EnvVar{},
+						Resources:    corev1.ResourceRequirements{},
+						VolumeMounts: script.VolumeMount(),
+						Ports:        []corev1.ContainerPort{{ContainerPort: 6565}},
 					}},
 					TerminationGracePeriodSeconds: &zero,
-					Volumes: []corev1.Volume{
-						script.Volume(),
-					},
+					Volumes:                       script.Volume(),
 				},
 			},
 		},
@@ -792,17 +771,12 @@ func TestNewRunnerJobIstio(t *testing.T) {
 								Value: "15",
 							},
 						},
-						Resources: corev1.ResourceRequirements{},
-						VolumeMounts: []corev1.VolumeMount{{
-							Name:      "k6-test-volume",
-							MountPath: "/test",
-						}},
-						Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
+						Resources:    corev1.ResourceRequirements{},
+						VolumeMounts: script.VolumeMount(),
+						Ports:        []corev1.ContainerPort{{ContainerPort: 6565}},
 					}},
 					TerminationGracePeriodSeconds: &zero,
-					Volumes: []corev1.Volume{
-						script.Volume(),
-					},
+					Volumes:                       script.Volume(),
 				},
 			},
 		},
@@ -900,17 +874,12 @@ func TestNewRunnerJobCloud(t *testing.T) {
 								Value: "token",
 							},
 						},
-						Resources: corev1.ResourceRequirements{},
-						VolumeMounts: []corev1.VolumeMount{{
-							Name:      "k6-test-volume",
-							MountPath: "/test",
-						}},
-						Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
+						Resources:    corev1.ResourceRequirements{},
+						VolumeMounts: script.VolumeMount(),
+						Ports:        []corev1.ContainerPort{{ContainerPort: 6565}},
 					}},
 					TerminationGracePeriodSeconds: &zero,
-					Volumes: []corev1.Volume{
-						script.Volume(),
-					},
+					Volumes:                       script.Volume(),
 				},
 			},
 		},
@@ -990,20 +959,16 @@ func TestNewRunnerJobLocalFile(t *testing.T) {
 					AutomountServiceAccountToken: &automountServiceAccountToken,
 					SecurityContext:              &corev1.PodSecurityContext{},
 					Containers: []corev1.Container{{
-						Image:     "ghcr.io/grafana/operator:latest-runner",
-						Name:      "k6",
-						Command:   []string{"sh", "-c", "if [ ! -f /test/test.js ]; then echo \"LocalFile not found exiting...\"; exit 1; fi;\nk6 run --quiet /test/test.js --address=0.0.0.0:6565 --paused"},
-						Env:       []corev1.EnvVar{},
-						Resources: corev1.ResourceRequirements{},
-						VolumeMounts: []corev1.VolumeMount{
-							script.VolumeMount(),
-						},
-						Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
+						Image:        "ghcr.io/grafana/operator:latest-runner",
+						Name:         "k6",
+						Command:      []string{"sh", "-c", "if [ ! -f /test/test.js ]; then echo \"LocalFile not found exiting...\"; exit 1; fi;\nk6 run --quiet /test/test.js --address=0.0.0.0:6565 --paused"},
+						Env:          []corev1.EnvVar{},
+						Resources:    corev1.ResourceRequirements{},
+						VolumeMounts: script.VolumeMount(),
+						Ports:        []corev1.ContainerPort{{ContainerPort: 6565}},
 					}},
 					TerminationGracePeriodSeconds: &zero,
-					Volumes: []corev1.Volume{
-						script.Volume(),
-					},
+					Volumes:                       script.Volume(),
 				},
 			},
 		},