Skip to content

Commit ac1c86b

Browse files
committed
[ws-manager] Fix typo in PodRejection constant
1 parent 2f09f8c commit ac1c86b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

components/ws-manager-mk2/controllers/status.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ const (
3737
// headlessTaskFailedPrefix is the prefix of the pod termination message if a headless task failed (e.g. user error
3838
// or aborted prebuild).
3939
headlessTaskFailedPrefix = "headless task failed: "
40+
41+
// podRejectedReasonNodeAffinity is the value of pod.status.Reason in case the pod got rejected by kubelet because of a NodeAffinity mismatch
42+
podRejectedReasonNodeAffinity = "NodeAffinity"
43+
44+
// podRejectedReasonOutOfCPU is the value of pod.status.Reason in case the pod got rejected by kubelet because of insufficient CPU available
45+
podRejectedReasonOutOfCPU = "OutOfcpu"
4046
)
4147

4248
func (r *WorkspaceReconciler) updateWorkspaceStatus(ctx context.Context, workspace *workspacev1.Workspace, pods *corev1.PodList, cfg *config.Configuration) (err error) {
@@ -125,7 +131,7 @@ func (r *WorkspaceReconciler) updateWorkspaceStatus(ctx context.Context, workspa
125131

126132
if failure != "" && !workspace.IsConditionTrue(workspacev1.WorkspaceConditionFailed) {
127133
// Check: A situation where we want to retry?
128-
if pod.Status.Phase == corev1.PodFailed && (pod.Status.Reason == "NodeAffinity" || pod.Status.Reason == "OutOfCPU") && strings.HasPrefix(pod.Status.Message, "Pod was rejected") {
134+
if pod.Status.Phase == corev1.PodFailed && (pod.Status.Reason == podRejectedReasonNodeAffinity || pod.Status.Reason == podRejectedReasonOutOfCPU) && strings.HasPrefix(pod.Status.Message, "Pod was rejected") {
129135
// This is a situation where we want to re-create the pod!
130136
log.Info("workspace scheduling failed", "workspace", workspace.Name, "reason", failure)
131137
workspace.Status.SetCondition(workspacev1.NewWorkspaceConditionPodRejected(failure, metav1.ConditionTrue))

components/ws-manager-mk2/controllers/workspace_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ func rejectPod(pod *corev1.Pod) {
785785
By("adding pod rejected condition")
786786
updateObjWithRetries(k8sClient, pod, true, func(pod *corev1.Pod) {
787787
pod.Status.Phase = corev1.PodFailed
788-
pod.Status.Reason = "NodeAffinity"
788+
pod.Status.Reason = "OutOfcpu"
789789
pod.Status.Message = "Pod was rejected"
790790
})
791791
}

0 commit comments

Comments
 (0)