Skip to content

Commit 2a35e06

Browse files
committed
WIP: fake rejection
TODO: - find out if it really works by looking at logs (seems to fast atm) - also, fix the broken "ns-psp:unprivileged" references
1 parent 2f09f8c commit 2a35e06

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package controllers
77
import (
88
"context"
99
"fmt"
10+
"slices"
1011
"strings"
1112
"sync"
1213
"time"
@@ -290,6 +291,23 @@ func (r *WorkspaceReconciler) actOnStatus(ctx context.Context, workspace *worksp
290291
}
291292
pod := &workspacePods.Items[0]
292293

294+
marker := slices.ContainsFunc(workspace.Spec.UserEnvVars, func(e corev1.EnvVar) bool {
295+
return e.Name == "GITPOD_WORKSPACE_CONTEXT_URL" && strings.Contains(e.Value, "geropl")
296+
})
297+
if workspace.Status.PodRecreated == 0 && marker && (workspace.Status.Phase == workspacev1.WorkspacePhasePending || workspace.Status.Phase == workspacev1.WorkspacePhaseCreating) {
298+
patch := client.MergeFrom(pod.DeepCopy())
299+
pod.Status.Phase = corev1.PodFailed
300+
pod.Status.Reason = "NodeAffinity"
301+
pod.Status.Message = "Pod was rejected"
302+
303+
log.WithValues("ws", workspace.Name).Info("REJECTING POD FOR TESTING")
304+
err = r.Client.Status().Patch(ctx, pod, patch)
305+
if err != nil {
306+
log.WithValues("ws", workspace.Name).Error(err, "REJECTING POD FOR TESTING: error while patching workspace pod")
307+
}
308+
return ctrl.Result{Requeue: true, RequeueAfter: 5 * time.Second}, nil
309+
}
310+
293311
switch {
294312
// if there is a pod, and it's failed, delete it
295313
case workspace.IsConditionTrue(workspacev1.WorkspaceConditionFailed) && !isPodBeingDeleted(pod):

0 commit comments

Comments
 (0)