Skip to content

Commit

Permalink
cloud: mark abort events with "k6" origin
Browse files Browse the repository at this point in the history
  • Loading branch information
yorugac committed Feb 4, 2025
1 parent 75741f2 commit 049b1aa
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion controllers/k6_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func CreateJobs(ctx context.Context, log logr.Logger, k6 *v1alpha1.TestRun, r *T
if v1alpha1.IsTrue(k6, v1alpha1.CloudTestRun) {
events := cloud.ErrorEvent(cloud.K6OperatorStartError).
WithDetail(fmt.Sprintf("Failed to create runner jobs: %v", err)).
WithAbort()
WithAbort(cloud.OriginK6)
cloud.SendTestRunEvents(r.k6CloudClient, k6.TestRunID(), log, events)
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/k6_finish.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func FinishJobs(ctx context.Context, log logr.Logger, k6 *v1alpha1.TestRun, r *T
if v1alpha1.IsTrue(k6, v1alpha1.CloudTestRun) && failed > 0 {
events := cloud.ErrorEvent(cloud.K6OperatorRunnerError).
WithDetail(msg).
WithAbort()
WithAbort(cloud.OriginK6)
cloud.SendTestRunEvents(r.k6CloudClient, k6.TestRunID(), log, events)
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/k6_initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func RunValidations(ctx context.Context, log logr.Logger, k6 *v1alpha1.TestRun,
// This error won't allow to start a test so let k6 Cloud know of it
events := cloud.ErrorEvent(cloud.K6OperatorStartError).
WithDetail(fmt.Sprintf("Failed to inspect the test script: %v", err)).
WithAbort()
WithAbort(cloud.OriginK6)
cloud.SendTestRunEvents(r.k6CloudClient, k6.TestRunID(), log, events)
} else {
// if there is any error, we have to reflect it on the K6 manifest
Expand Down
2 changes: 1 addition & 1 deletion controllers/k6_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func StartJobs(ctx context.Context, log logr.Logger, k6 *v1alpha1.TestRun, r *Te
if v1alpha1.IsTrue(k6, v1alpha1.CloudTestRun) {
events := cloud.ErrorEvent(cloud.K6OperatorStartError).
WithDetail(msg).
WithAbort()
WithAbort(cloud.OriginK6)
cloud.SendTestRunEvents(r.k6CloudClient, k6.TestRunID(), log, events)
}
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/testrun_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (r *TestRunReconciler) reconcile(ctx context.Context, req ctrl.Request, log
if isCloudTestRun(k6) {
events := cloud.ErrorEvent(cloud.K6OperatorStartError).
WithDetail(msg).
WithAbort()
WithAbort(cloud.OriginK6)
cloud.SendTestRunEvents(r.k6CloudClient, k6.TestRunID(), log, events)
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloud/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ func (e *Events) WithDetail(s string) *Events {
}

// WithAbort adds abortEvent to errorEvent if it already exists.
func (e *Events) WithAbort() *Events {
func (e *Events) WithAbort(o Origin) *Events {
if len(*e) == 0 {
return e
}

if (*e)[0].EventType == errorEvent {
*e = append(*e, AbortEvent(OriginUser))
*e = append(*e, AbortEvent(o))
}
return e
}
Expand Down

0 comments on commit 049b1aa

Please sign in to comment.