Skip to content

Commit 6135783

Browse files
committed
Expand ownership check for profile bundle controller
The controller previously only watched ProfileBundle objects. When the profileparser Deployment's pods changed state, the controller was never notified. Adding Owns means any change to the owned Deployment triggers a reconciliation of the parent ProfileBundle, so the controller is responsive to pod lifecycle events. Also, once the controller found an existing pod with no startup error, it exited the controller reconcilation loop without requeue — regardless of whether the ProfileBundle was still in PENDING state. If the profileparser hadn't finished (or never ran due to a rollout delay), the controller would never check again. This commit also updates the profile bundle controller to requeues every 10 seconds while the status is still DataStreamPending, ensuring the controller keeps monitoring until the profileparser either succeeds (sets VALID) or fails (sets INVALID / pod startup error detected). This should improve the resilience of profile bundle parsing, especially in testing, where we delete deployments after modifying the profile bundle image to simulate operator updates. Assisted-By: Opus 4.6
1 parent 2bae8b1 commit 6135783

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/controller/profilebundle/profilebundle_controller.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ var oneReplica int32 = 1
4242
func (r *ReconcileProfileBundle) SetupWithManager(mgr ctrl.Manager) error {
4343
return ctrl.NewControllerManagedBy(mgr).
4444
For(&compliancev1alpha1.ProfileBundle{}).
45+
Owns(&appsv1.Deployment{}).
4546
Complete(r)
4647
}
4748

@@ -67,6 +68,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
6768
return ctrl.NewControllerManagedBy(mgr).
6869
Named("profilebundle-controller").
6970
For(&compliancev1alpha1.ProfileBundle{}).
71+
Owns(&appsv1.Deployment{}).
7072
Complete(r)
7173
}
7274

@@ -252,6 +254,15 @@ func (r *ReconcileProfileBundle) Reconcile(ctx context.Context, request reconcil
252254
// Pod already exists and its init container at least ran - don't requeue
253255
reqLogger.Info("Skip reconcile: Workload already up-to-date", "Deployment.Namespace", found.Namespace, "Deployment.Name", found.Name)
254256

257+
// If the ProfileBundle is still pending, the profileparser hasn't
258+
// finished updating the status yet. Requeue so we can detect if
259+
// it fails without updating the status (e.g., pod crash, rollout
260+
// delay, API connectivity issues).
261+
if instance.Status.DataStreamStatus == compliancev1alpha1.DataStreamPending {
262+
reqLogger.Info("ProfileBundle still pending, requeueing to check status")
263+
return reconcile.Result{Requeue: true, RequeueAfter: 10 * time.Second}, nil
264+
}
265+
255266
// Handle upgrades
256267
if instance.Status.DataStreamStatus == compliancev1alpha1.DataStreamValid &&
257268
instance.Status.Conditions.GetCondition("Ready") == nil {

0 commit comments

Comments
 (0)