<p>I'm building an app that spawns Jobs (batch/v1), I need to update my Custom Resource status with the Job status.</p>
<p>I setup the controller with the following:</p>
<pre class="lang-golang prettyprint-override"><code>func (r *JobsManagedByRequestedBackupActionObserver) SetupWithManager(mgr ctrl.Manager) error {
    return ctrl.NewControllerManagedBy(mgr).
        For(&amp;riotkitorgv1alpha1.RequestedBackupAction{}).
        Owns(&amp;batchv1.Job{}).
        Owns(&amp;batchv1.CronJob{}).
        WithEventFilter(predicate.Funcs{
            DeleteFunc: func(e event.DeleteEvent) bool {
                return false
            },
        }).
        Complete(r)
}
</code></pre>
<p>During the <code>Reconcile(ctx context.Context, req ctrl.Request)</code> I fetch my RequestedBackupAction object (basing on &quot;req&quot;) and then I fetch Jobs from API using a dedicated tracking label.</p>
<pre class="lang-golang prettyprint-override"><code>list, err := kj.client.Jobs(namespace).List(ctx, metav1.ListOptions{LabelSelector: v1alpha1.LabelTrackingId + &quot;=&quot; + trackingId})
</code></pre>
<p>When I iterate over objects with:</p>
<pre class="lang-golang prettyprint-override"><code>for _, job := range list.Items {
        logrus.Errorf(&quot;[++++++++++++] JOB name=%s, failed=%v, active=%v, succeeded=%v&quot;, job.Name, job.Status.Failed, job.Status.Active, job.Status.Succeeded)
}

</code></pre>
<p>Then I get multiple entries like this:</p>
<pre class="lang-bash prettyprint-override"><code>time=&quot;2022-12-12T20:00:55Z&quot; level=error msg=&quot;[++++++++++++] JOB name=app1-backup-vmqrp, failed=0, active=1, succeeded=0&quot;
</code></pre>
<p>But I don't finally get an entry, where there should be: failed=1, active=0, succeeded=0
even if the Job actually finished - the point is that the controller is not being notified.</p>
<p>That's the final Job status:</p>
<pre class="lang-yaml prettyprint-override"><code>  status:
    conditions:
    - lastProbeTime: &quot;2022-12-12T20:00:56Z&quot;
      lastTransitionTime: &quot;2022-12-12T20:00:56Z&quot;
      message: Job has reached the specified backoff limit
      reason: BackoffLimitExceeded
      status: &quot;True&quot;
      type: Failed
    failed: 1
    ready: 0
    startTime: &quot;2022-12-12T20:00:50Z&quot;
    uncountedTerminatedPods: {}
</code></pre>
<p>What could be wrong?</p>

Krzysztof Wesołowski
<p>The solution was really dead simple - when the object is not ready, then requeue it, wich for Job means to wait until it will be finished. Still I don't understand why the controller is not notified about a state change from: active=1 to active=0 and from failed=0 to failed=1</p>
<p><strong>Example:</strong></p>
<pre class="lang-golang prettyprint-override"><code>if healthStatus.Running {
    return ctrl.Result{Requeue: true}, nil
}
</code></pre>
