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

Treat failed initializer as error (PR 291 continued) #401

Merged
merged 2 commits into from
May 23, 2024
Merged
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
8 changes: 7 additions & 1 deletion controllers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"time"
Expand Down Expand Up @@ -54,7 +55,12 @@ func inspectTestRun(ctx context.Context, log logr.Logger, k6 v1alpha1.TestRunI,
}

// there should be only 1 initializer pod
if podList.Items[0].Status.Phase != corev1.PodSucceeded && podList.Items[0].Status.Phase != corev1.PodFailed {
if podList.Items[0].Status.Phase == corev1.PodFailed {
returnErr = errors.New("initalizer job has failed")
log.Error(returnErr, "error:")
return
}
if podList.Items[0].Status.Phase != corev1.PodSucceeded {
log.Info("Waiting for initializing pod to finish")
return
}
Expand Down
8 changes: 8 additions & 0 deletions controllers/k6_initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ func RunValidations(ctx context.Context, log logr.Logger, k6 v1alpha1.TestRunI,
WithDetail(fmt.Sprintf("Failed to inspect the test script: %v", err)).
WithAbort()
cloud.SendTestRunEvents(r.k6CloudClient, v1alpha1.TestRunID(k6), log, events)
} else {
// if there is any error, we have to reflect it on the K6 manifest
k6.GetStatus().Stage = "error"
if _, err := r.UpdateStatus(ctx, k6, log); err != nil {
return ctrl.Result{}, ready, err
}

return ctrl.Result{}, ready, nil
}

// inspectTestRun made a log message already so just return without requeue
Expand Down
Loading