This feature request was initially described as a bugfix due to a misunderstanding of the spec.paused field.
Initial report
Brief summary
While the operator correctly propagates the configuration as part of the flags for the runner:
|
paused := true |
|
if k6.GetSpec().Paused != "" { |
|
paused, _ = strconv.ParseBool(k6.GetSpec().Paused) |
|
} |
|
|
|
if paused { |
|
command = append(command, "--paused") |
|
} |
It makes no checks prior to creating the starter:
|
case "initialized": |
|
return CreateJobs(ctx, log, k6, r) |
|
|
|
case "created": |
|
return StartJobs(ctx, log, k6, r) |
Neither functions above make any checks regarding spec.paused AFAICT.
Since the starter job always unpauses the the runner:
|
func NewStartContainer(hostnames []string, image string, imagePullPolicy corev1.PullPolicy, command []string, env []corev1.EnvVar, securityContext corev1.SecurityContext) corev1.Container { |
|
req, _ := json.Marshal( |
|
types.StatusAPIRequest{ |
|
Data: types.StatusAPIRequestData{ |
|
Attributes: types.StatusAPIRequestDataAttributes{ |
|
Paused: false, |
|
}, |
|
ID: "default", |
|
Type: "status", |
|
}, |
|
}) |
|
|
|
var parts []string |
|
for _, hostname := range hostnames { |
|
parts = append(parts, fmt.Sprintf("curl --retry 3 -X PATCH -H 'Content-Type: application/json' http://%s:6565/v1/status -d '%s'", hostname, req)) |
|
} |
We end up with spec.paused being ignored (technically, partially ignored because the --paused flag does get added to the runner arguments, but in practice it always unpauses due to how the starter behaves).
Suggested implementation
We might solve this by just adding an if statement when the status is "created", guarding the StartJobs function:
case "created":
if k6.IsPaused() {
// nothing to do. When the user updates spec.paused a new reconciliation will trigger and we'll check again
return ctrl.Result{}, nil
}
return StartJobs(ctx, log, k6, r)
Of course, this implies that changing spec.paused after the test has started continues to have no effect, but that seems sensible to me.
k6-operator version or image
0.0.16
Helm chart version (if applicable)
No response
TestRun / PrivateLoadZone YAML
Anything with spec.paused set to 'true'.
Other environment details (if applicable)
No response
Steps to reproduce the problem
- Create a
TestRun with spec.paused set to 'true'
- Wait for jobs to run
Expected behaviour
Runner does not start the test before I set spec.paused to 'false' or null.
Actual behaviour
Starter behaves exactly as if spec.paused was set to 'false' or null, and immediately starts the runner.
Feature Description
It would be nice if we could edit a live TestRun resource to suspend or resume it, similarly to what Kubernetes does with Jobs.
Suggested Solution (optional)
Add a spec.suspend field that controls whether to run the starter job or not.
Already existing or connected issues / PRs (optional)
No response
This feature request was initially described as a bugfix due to a misunderstanding of the
spec.pausedfield.Initial report
Brief summary
While the operator correctly propagates the configuration as part of the flags for the
runner:k6-operator/pkg/resources/jobs/runner.go
Lines 61 to 68 in 0f3957c
It makes no checks prior to creating the starter:
k6-operator/controllers/testrun_controller.go
Lines 193 to 197 in 0f3957c
Neither functions above make any checks regarding
spec.pausedAFAICT.Since the starter job always unpauses the the runner:
k6-operator/pkg/resources/containers/curl_start.go
Lines 15 to 30 in 0f3957c
We end up with
spec.pausedbeing ignored (technically, partially ignored because the--pausedflag does get added to the runner arguments, but in practice it always unpauses due to how the starter behaves).Suggested implementation
We might solve this by just adding an
ifstatement when the status is"created", guarding theStartJobsfunction:Of course, this implies that changing
spec.pausedafter the test has started continues to have no effect, but that seems sensible to me.k6-operator version or image
0.0.16
Helm chart version (if applicable)
No response
TestRun / PrivateLoadZone YAML
Anything with spec.paused set to
'true'.Other environment details (if applicable)
No response
Steps to reproduce the problem
TestRunwithspec.pausedset to'true'Expected behaviour
Runner does not start the test before I set
spec.pausedto'false'ornull.Actual behaviour
Starter behaves exactly as if
spec.pausedwas set to'false'ornull, and immediately starts the runner.Feature Description
It would be nice if we could edit a live
TestRunresource to suspend or resume it, similarly to what Kubernetes does withJobs.Suggested Solution (optional)
Add a
spec.suspendfield that controls whether to run the starter job or not.Already existing or connected issues / PRs (optional)
No response