Skip to content

Commit 55db7a1

Browse files
jlebonalicefr
authored andcommitted
controller: include newly created BootcNodes in ownedSet
Ouch, this is a pretty obvious bug. The effect wasn't disastrous (we just waste one reconcile), but still... Thankfully new tests I'm working on caught it. Assisted-by: Pi (Claude Opus 4.6)
1 parent e8e5159 commit 55db7a1

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

internal/controller/bootcnodepool_controller.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ func (r *BootcNodePoolReconciler) syncMembership(ctx context.Context, pool *boot
380380
} else {
381381
// New match: create BootcNode and label the node.
382382
log.Info("Creating BootcNode for new match", "node", nodeName)
383-
if err := r.createBootcNode(ctx, pool, node); err != nil {
383+
bn, err := r.createBootcNode(ctx, pool, node)
384+
if err != nil {
384385
if !apierrors.IsAlreadyExists(err) {
385386
return nil, fmt.Errorf("creating BootcNode for %s: %w", nodeName, err)
386387
}
@@ -390,6 +391,8 @@ func (r *BootcNodePoolReconciler) syncMembership(ctx context.Context, pool *boot
390391
conflicting[owner.Name] = true
391392
}
392393
}
394+
} else {
395+
ownedSet[nodeName] = bn
393396
}
394397
}
395398
}
@@ -484,7 +487,7 @@ func desiredImageFromPool(pool *bootcv1alpha1.BootcNodePool) string {
484487

485488
// createBootcNode creates a BootcNode for a node joining the pool and
486489
// labels the node as managed.
487-
func (r *BootcNodePoolReconciler) createBootcNode(ctx context.Context, pool *bootcv1alpha1.BootcNodePool, node *corev1.Node) error {
490+
func (r *BootcNodePoolReconciler) createBootcNode(ctx context.Context, pool *bootcv1alpha1.BootcNodePool, node *corev1.Node) (*bootcv1alpha1.BootcNode, error) {
488491
bn := &bootcv1alpha1.BootcNode{
489492
ObjectMeta: metav1.ObjectMeta{
490493
Name: node.Name,
@@ -503,19 +506,19 @@ func (r *BootcNodePoolReconciler) createBootcNode(ctx context.Context, pool *boo
503506
// Set ownerReference so the BootcNode is cleaned up if the pool is
504507
// deleted and so the Owns() watch routes BootcNode events to this pool.
505508
if err := controllerutil.SetControllerReference(pool, bn, r.Scheme); err != nil {
506-
return fmt.Errorf("setting owner reference: %w", err)
509+
return nil, fmt.Errorf("setting owner reference: %w", err)
507510
}
508511

509512
if err := r.Create(ctx, bn); err != nil {
510-
return fmt.Errorf("creating BootcNode: %w", err)
513+
return nil, fmt.Errorf("creating BootcNode: %w", err)
511514
}
512515

513516
// Label the node as managed.
514517
if err := r.ensureManagedLabel(ctx, node, true); err != nil {
515-
return fmt.Errorf("labeling node: %w", err)
518+
return nil, fmt.Errorf("labeling node: %w", err)
516519
}
517520

518-
return nil
521+
return bn, nil
519522
}
520523

521524
// ensureManagedLabel adds or removes the bootc.dev/managed label on a Node.

0 commit comments

Comments
 (0)