Job log is not show immediately after cancel/retry job action
Problem
We recently stopped unnecessary polling on the job trace endpoint. Trace polling was kicked off before a job was started and if visibility was hidden. This caused a great deal of strain on Redis. This has now been fixed. Although it introduced a UI regression where if you cancel a job and then retry it, the job trace is not fetched immediately. The user will have to refresh the UI one time to get the job trace and kick off polling. This can be seen in the below video.
Bug Theory
We now check a jobs state before kicking off trace polling. Meaning if the job has not started or does not have a trace, we do not start trace polling. When you cancel a job then retry a job you are redirected to the same view (current implementation). Most likely on that redirect your job will be in a pending state, which means we will not kick off trace polling (because the job has not started). I suspect the previous implementation of always trace polling no matter the jobs state was to prevent issues like this but we don't want to do that because of the server resources it will eat up.
Related MRs up to this point
Potential solution
Let's revert the work done in !48516 (merged) && !49752 (merged) and move back to polling the trace endpoint all the time to prevent race conditions. Let's make the trace endpoint return a 204
if the job has not started or does not have a trace.