diff --git a/pkg/api/constant.go b/pkg/api/constant.go index 5bdebc3b68e..fde1ad8c4fb 100644 --- a/pkg/api/constant.go +++ b/pkg/api/constant.go @@ -51,6 +51,10 @@ const ( APPCIKubeAPIURL = "https://api.ci.l2s4.p1.openshiftapps.com:6443" + // ReasonPending is the error reason for pods not scheduled in time. + // It is generated when pods are for whatever reason not scheduled before + // `podStartTimeout`. + ReasonPending = "pod_pending" // CliEnv if the env we use to expose the path to the cli CliEnv = "CLI_DIR" DefaultLeaseEnv = "LEASED_RESOURCE" diff --git a/pkg/util/builds.go b/pkg/util/builds.go index 8bddb13967f..33a44c3455a 100644 --- a/pkg/util/builds.go +++ b/pkg/util/builds.go @@ -12,7 +12,9 @@ import ( buildapi "github.com/openshift/api/build/v1" + "github.com/openshift/ci-tools/pkg/api" "github.com/openshift/ci-tools/pkg/kubernetes" + "github.com/openshift/ci-tools/pkg/results" ) // PendingBuildError fetches scheduling errors from the build pod's events @@ -28,5 +30,6 @@ func PendingBuildError(ctx context.Context, client kubernetes.PodClient, build * } else { ret = fmt.Errorf("%s:%s\n%s", msg, getReasonsForUnreadyContainers(&pod), getEventsForPod(ctx, &pod, client)) } + ret = results.ForReason(api.ReasonPending).ForError(ret) return } diff --git a/pkg/util/pods.go b/pkg/util/pods.go index ea997018ac7..24267bb61c3 100644 --- a/pkg/util/pods.go +++ b/pkg/util/pods.go @@ -23,7 +23,9 @@ import ( "k8s.io/apimachinery/pkg/util/wait" ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/openshift/ci-tools/pkg/api" "github.com/openshift/ci-tools/pkg/kubernetes" + "github.com/openshift/ci-tools/pkg/results" ) // WaitForPodFlag changes the behavior of the functions which monitor pods @@ -431,7 +433,7 @@ func checkPending(pod corev1.Pod, timeout time.Duration, now time.Time) (time.Ti if t := t0.Add(timeout); now.Before(t) { return t, nil } - return time.Time{}, fmt.Errorf("container %q has not started in %s", name, now.Sub(t0)) + return time.Time{}, results.ForReason(api.ReasonPending).ForError(fmt.Errorf("container %q has not started in %s", name, now.Sub(t0))) } prev := pod.CreationTimestamp.Time for _, s := range pod.Status.InitContainerStatuses {