<p><strong>Situation:</strong>
I've got a CronJob that often fails (this is expected at the moment). Due to the fact that the container performing the job, has a side-car, the dependencies are between the containers are expressed through bash scripts and common mounts of <code>emptyDir</code> in <code>/etc/liveness</code> folder:</p>
<pre><code>        spec:
          containers:
          - args:
            - -c
            - set -x;
              ...
              ./process; # execute the main process
              rc=$?;
              rm /etc/liveness; # clean-up
              exit $rc;
            command:
            - /bin/bash
</code></pre>
<p><strong>Problem:</strong>
In the scenarios, where the job fails, I see the following in the logs:</p>
<pre><code>+ rc=255
+ rm /etc/liveness
+ exit 255
</code></pre>
<p>With <code>retryPolicy</code> set to <code>never</code>, the failed pod enters the <code>Completed</code> status, which is misleading:</p>
<pre><code>scheduler-1594015200-wl9xc   0/2     Completed     0          24m
</code></pre>

<blockquote>
<p>A Pod's status field is a PodStatus object, which has a phase field.</p>
</blockquote>
<p>Ref: <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase</a></p>
<p>Status and Phase is not the same. So I learned, that what happens above is that my pods end up in status <code>Completed</code> and phase <code>Failed</code>.</p>
