Skip to content

Commit 4120599

Browse files
committed
Fix tests
1 parent 06abb06 commit 4120599

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

components/node-labeler/cmd/run.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func (wc *WorkspaceCountController) periodicReconciliation() {
314314
for {
315315
select {
316316
case <-ticker.C:
317-
log.Info("Starting periodic full reconciliation")
317+
log.Info("starting periodic full reconciliation")
318318
ctx := context.Background()
319319
if _, err := wc.reconcileAllNodes(ctx); err != nil {
320320
log.WithError(err).Error("periodic reconciliation failed")
@@ -366,12 +366,11 @@ func (wc *WorkspaceCountController) workspaceFilter() predicate.Predicate {
366366
func (wc *WorkspaceCountController) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
367367
log.WithField("request", req.NamespacedName.String()).Info("WorkspaceCountController reconciling")
368368

369-
// Process any queued nodes first
369+
// Process any queued nodes first, logging errors (not returning)
370370
select {
371371
case nodeName := <-wc.nodesToReconcile:
372372
if err := wc.reconcileNode(ctx, nodeName); err != nil {
373373
log.WithError(err).WithField("node", nodeName).Error("failed to reconcile node from queue")
374-
return ctrl.Result{}, err
375374
}
376375
default:
377376
// No nodes in queue, continue with regular reconciliation

components/node-labeler/cmd/run_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,20 @@ var _ = BeforeSuite(func() {
136136
}
137137
Expect(k8sClient.Create(ctx, node)).To(Succeed())
138138

139+
err = k8sManager.GetFieldIndexer().IndexField(context.Background(),
140+
&workspacev1.Workspace{},
141+
"status.runtime.nodeName",
142+
func(o client.Object) []string {
143+
ws := o.(*workspacev1.Workspace)
144+
if ws.Status.Runtime == nil {
145+
return nil
146+
}
147+
return []string{ws.Status.Runtime.NodeName}
148+
})
149+
Expect(err).ToNot(HaveOccurred())
150+
139151
By("Setting up workspace controller")
140-
workspaceCtrl, err = NewWorkspaceCountController(k8sClient)
152+
workspaceCtrl, err = NewWorkspaceCountController(k8sManager.GetClient())
141153
Expect(err).NotTo(HaveOccurred())
142154
Expect(workspaceCtrl.SetupWithManager(k8sManager)).To(Succeed())
143155

0 commit comments

Comments
 (0)