Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloud: mark abort events with "k6" origin #526

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading