Skip to content

Commit dff1d29

Browse files
committed
test: delete unclaimed members after a consent loss also when the pool needs no create
Change-Id: I5e6dc789d00252e41e256193698a62cc092e3696 Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent b1ab7ad commit dff1d29

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎internal/controller/coderworkspacepool_delete_test.go‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,22 @@ func TestPoolScaleDownAndLoweredCap(t *testing.T) {
211211
}
212212
require.Equal(t, 2, deleting, "the cap deletes one, the scale-down one more")
213213
}
214+
215+
// TestPoolConsentLossUncachedWhenFull: a pool that needs no create still
216+
// checks consent on an uncached read, so a cache that still allows the
217+
// template keeps no unclaimed member after the admin removed it (Codex
218+
// 4274557698).
219+
func TestPoolConsentLossUncachedWhenFull(t *testing.T) {
220+
t.Parallel()
221+
e := newPoolMemberEnv(t)
222+
ready := e.createMember(t, nil)
223+
e.setMemberStatus(t, ready, withWorkspace(readyStatus))
224+
requirePool(t, e.reconcilePool(t, 1), "Ready", true, false)
225+
e.allowOwner(t, e.tester.String(), "default.other")
226+
stale := staleControlPlaneClient{k8sClient, func(o *coderv1alpha1.WorkspacePoolOwner) { o.Templates = []string{"default.docker"} }}
227+
r := &controller.CoderWorkspacePoolReconciler{Client: stale, APIReader: k8sClient, Scheme: scheme, Clock: e.clock}
228+
_, err := r.Reconcile(e.ctx, ctrl.Request{NamespacedName: types.NamespacedName{Namespace: e.ns, Name: e.pool.Name}})
229+
require.NoError(t, err)
230+
require.True(t, e.gone(t, ready))
231+
require.Equal(t, "TemplateNotAllowed", e.reconcilePool(t, 0).Status.Reason)
232+
}

0 commit comments

Comments
 (0)