Skip to content

Fix duplicate "Job succeeded lines"

Stan Hu requested to merge sh-fix-duplicate-job-succeede-lines into master

What does this MR do and why?

Projects::JobsController#trace reads the last 512 kilobytes of a CI job trace and attempts to parse it. Previously if the last part of this trace omitted the begin_section marker, the end_section marker detected that the section was not open and skipped it, without incrementing the offset of the state. Subsequent lines would then have the incorrect offset, causing the returned state to be short the characters that were skipped. As a result, requests to Projects::JobsController#trace would request an offset that preceded the last line, causing duplicate lines to appear.

To fix this, if we detect an end_section marker that does not have a matching begin_section, we just skip over it and advance the offset.

Relates to #452097 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. Create a CI job that generates more than 512k of tests. Sample:
test:
  image: ruby:3.2
  script:
    - ruby -e "1000.times { puts ('hello world ' * 100) }"
  1. View the job log, scroll to the bottom, and keep the window open.
  2. On master, it will show:

image

  1. On this branch, it should say Job succeeded without duplication:

image

Edited by Stan Hu

Merge request reports