Skip to content

Add backwards compatibility to nested job log sections

What does this MR do?

This addresses the missing backwards compatibility found during the rollout of the new infinitely nested collapsible sections feature flag (infinitely_collapsible_sections)

#335297 (closed)

Screenshots or Screencasts (strongly suggested)

How to setup and validate locally (strongly suggested)

This was detected in an older job log in the gitlab kramdown project

https://gitlab.com/gitlab-org/gitlab_kramdown/-/jobs/323304022#L9

What I did to test this older trace was the following

  1. Open the browser developer tools and go to the network tab.
  2. Look for the trace.json endpoint response.
  3. Copy the response to a mock_data.js file inside the app/assets/javascripts/jobs directory.
Click to expand
const traceOld = {
  id: 323304022,
  status: 'success',
  complete: true,
  state:
    'eyJvZmZzZXQiOjU5NjIsInN0eWxlIjp7ImZnIjpudWxsLCJiZyI6bnVsbCwibWFzayI6MH0sIm9wZW5fc2VjdGlvbnMiOnt9fQ==',
  append: false,
  truncated: false,
  offset: 0,
  size: 5967,
  total: 5967,
  lines: [
    {
      offset: 0,
      content: [
        {
          text: 'Running with gitlab-runner 12.4.0-rc1 (d72c2ef7)',
        },
      ],
    },
    {
      offset: 53,
      content: [
        {
          text: '  on prm-com-gitlab-org bd091556',
        },
      ],
    },
    {
      offset: 100,
      content: [
        {
          text: 'Using Docker executor with image ruby:2.6 ...',
        },
      ],
      section: 'prepare-executor',
      section_header: true,
    },
    {
      offset: 196,
      content: [
        {
          text: 'Pulling docker image ruby:2.6 ...',
        },
      ],
      section: 'prepare-executor',
    },
    {
      offset: 239,
      content: [
        {
          text: 'Using docker image sha256:62808f8a7cd27b79e6bd74522b89c58a3285662bde5bf55f90d2ecbdb6c97f02 for ruby:2.6 ...',
        },
      ],
      section: 'prepare-executor',
    },
    {
      offset: 361,
      content: [],
      section: 'prepare-executor',
      section_duration: '00:27',
    },
    {
      offset: 405,
      content: [
        {
          text: 'Running on runner-bd091556-project-5647182-concurrent-0 via runner-bd091556-prm-1571284228-329df97c...',
        },
      ],
      section: 'prepare-script',
      section_header: true,
    },
    {
      offset: 552,
      content: [],
      section: 'prepare-script',
      section_duration: '00:03',
    },
    {
      offset: 594,
      content: [
        {
          text: 'Fetching changes...',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'get-sources',
      section_header: true,
    },
    {
      offset: 667,
      content: [
        {
          text: 'Initialized empty Git repository in /builds/gitlab-org/gitlab_kramdown/.git/',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 744,
      content: [
        {
          text: 'Created fresh repository.',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 782,
      content: [
        {
          text: 'From https://gitlab.com/gitlab-org/gitlab_kramdown',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 833,
      content: [
        {
          text: ' * [new ref]         refs/pipelines/89379608 -> refs/pipelines/89379608',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 905,
      content: [
        {
          text: ' * [new branch]      12-support-task-lists-checkboxes-to-align-docs-with-gitlab -> origin/12-support-task-lists-checkboxes-to-align-docs-with-gitlab',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1054,
      content: [
        {
          text: ' * [new branch]      gem-metadata-urls       -> origin/gem-metadata-urls',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1127,
      content: [
        {
          text: ' * [new branch]      labels                  -> origin/labels',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1189,
      content: [
        {
          text: ' * [new branch]      master                  -> origin/master',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1251,
      content: [
        {
          text: ' * [new tag]         v0.1.0                  -> v0.1.0',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1306,
      content: [
        {
          text: ' * [new tag]         v0.2.0                  -> v0.2.0',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1361,
      content: [
        {
          text: ' * [new tag]         v0.3.0                  -> v0.3.0',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1416,
      content: [
        {
          text: ' * [new tag]         v0.4.0                  -> v0.4.0',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1471,
      content: [
        {
          text: ' * [new tag]         v0.4.1                  -> v0.4.1',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1526,
      content: [
        {
          text: ' * [new tag]         v0.4.2                  -> v0.4.2',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1581,
      content: [
        {
          text: ' * [new tag]         v0.5.0                  -> v0.5.0',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1636,
      content: [
        {
          text: ' * [new tag]         v0.6.0                  -> v0.6.0',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1691,
      content: [
        {
          text: ' * [new tag]         v0.7.0                  -> v0.7.0',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1746,
      content: [
        {
          text: ' * [new tag]         v0.8.0                  -> v0.8.0',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1801,
      content: [
        {
          text: ' * [new tag]         v0.9.0                  -> v0.9.0',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1856,
      content: [
        {
          text: 'Checking out 74197fa5 as 12-support-task-lists-checkboxes-to-align-docs-with-gitlab...',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1956,
      content: [
        {
          text: 'Skipping Git submodules setup',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'get-sources',
    },
    {
      offset: 1998,
      content: [],
      section: 'get-sources',
      section_duration: '00:01',
    },
    {
      offset: 2037,
      content: [
        {
          text: 'Checking cache for ruby2.6...',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'restore-cache',
      section_header: true,
    },
    {
      offset: 2122,
      content: [
        {
          text: 'Downloading cache.zip from https://storage.googleapis.com/gitlab-com-runners-cache/project/5647182/ruby2.6',
        },
        {
          text: ' ',
        },
      ],
      section: 'restore-cache',
    },
    {
      offset: 2235,
      content: [
        {
          text: 'Successfully extracted cache',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'restore-cache',
    },
    {
      offset: 2276,
      content: [],
      section: 'restore-cache',
      section_duration: '00:04',
    },
    {
      offset: 2365,
      content: [],
      section: 'download-artifacts',
      section_duration: '00:01',
    },
    {
      offset: 2411,
      content: [
        {
          text: '$ ruby -v',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'build-script',
      section_header: true,
    },
    {
      offset: 2475,
      content: [
        {
          text: 'ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 2533,
      content: [
        {
          text: '$ gem install bundler  --no-document',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 2582,
      content: [
        {
          text: 'Successfully installed bundler-2.0.2',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 2619,
      content: [
        {
          text: '1 gem installed',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 2635,
      content: [
        {
          text: '$ bundle install -j $(nproc) --path vendor',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 2690,
      content: [
        {
          text: 'Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 2891,
      content: [
        {
          text: 'Using rake 12.3.2',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 2909,
      content: [
        {
          text: 'Using public_suffix 3.0.3',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 2935,
      content: [
        {
          text: 'Using addressable 2.6.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 2959,
      content: [
        {
          text: 'Using asciidoctor 2.0.10',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 2984,
      content: [
        {
          text: 'Using asciidoctor-plantuml 0.0.9',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3017,
      content: [
        {
          text: 'Using ast 2.4.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3033,
      content: [
        {
          text: 'Using benchmark-ips 2.7.2',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3059,
      content: [
        {
          text: 'Using builder 3.2.3',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3079,
      content: [
        {
          text: 'Using bundler 1.17.2',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3100,
      content: [
        {
          text: 'Using thread_safe 0.3.6',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3124,
      content: [
        {
          text: 'Using descendants_tracker 0.0.4',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3156,
      content: [
        {
          text: 'Using diff-lcs 1.3',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3175,
      content: [
        {
          text: 'Using docile 1.3.1',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3194,
      content: [
        {
          text: 'Using multipart-post 2.0.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3221,
      content: [
        {
          text: 'Using faraday 0.15.4',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3242,
      content: [
        {
          text: 'Using git 1.5.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3258,
      content: [
        {
          text: 'Using hashie 3.6.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3277,
      content: [
        {
          text: 'Using jwt 2.1.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3293,
      content: [
        {
          text: 'Using multi_json 1.13.1',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3317,
      content: [
        {
          text: 'Using multi_xml 0.6.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3339,
      content: [
        {
          text: 'Using rack 2.0.7',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3356,
      content: [
        {
          text: 'Using oauth2 1.4.1',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3375,
      content: [
        {
          text: 'Using github_api 0.18.2',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3399,
      content: [
        {
          text: 'Using highline 2.0.2',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3420,
      content: [
        {
          text: 'Using jaro_winkler 1.5.2',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3445,
      content: [
        {
          text: 'Using json 1.8.6',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3462,
      content: [
        {
          text: 'Using mini_portile2 2.4.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3488,
      content: [
        {
          text: 'Using nokogiri 1.10.4',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3510,
      content: [
        {
          text: 'Using rdoc 3.12.2',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3528,
      content: [
        {
          text: 'Using semver 1.0.1',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3547,
      content: [
        {
          text: 'Using juwelier 2.1.3',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3568,
      content: [
        {
          text: 'Using kramdown 1.16.2',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3590,
      content: [
        {
          text: 'Using parallel 1.17.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3612,
      content: [
        {
          text: 'Using parser 2.6.2.1',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3633,
      content: [
        {
          text: 'Using psych 3.1.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3651,
      content: [
        {
          text: 'Using rainbow 3.0.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3671,
      content: [
        {
          text: 'Using rouge 3.3.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3689,
      content: [
        {
          text: 'Using rspec-support 3.8.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3715,
      content: [
        {
          text: 'Using rspec-core 3.8.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3738,
      content: [
        {
          text: 'Using rspec-expectations 3.8.2',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3769,
      content: [
        {
          text: 'Using rspec-mocks 3.8.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3793,
      content: [
        {
          text: 'Using rspec 3.8.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3811,
      content: [
        {
          text: 'Using rspec_junit_formatter 0.4.1',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3845,
      content: [
        {
          text: 'Using ruby-progressbar 1.10.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3875,
      content: [
        {
          text: 'Using unicode-display_width 1.5.0',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3909,
      content: [
        {
          text: 'Using rubocop 0.67.2',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3930,
      content: [
        {
          text: 'Using simplecov-html 0.10.2',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3958,
      content: [
        {
          text: 'Using simplecov 0.16.1',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 3981,
      content: [
        {
          text: 'Bundle complete! 12 Gemfile dependencies, 48 gems now installed.',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 4046,
      content: [
        {
          text: 'Bundled gems are installed into `./vendor`',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 4089,
      content: [
        {
          text: '$ bundle exec rake spec',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 4125,
      content: [
        {
          text: '/usr/local/bin/ruby -w -I/builds/gitlab-org/gitlab_kramdown/vendor/ruby/2.6.0/gems/rspec-core-3.8.0/lib:/builds/gitlab-org/gitlab_kramdown/vendor/ruby/2.6.0/gems/rspec-support-3.8.0/lib /builds/gitlab-org/gitlab_kramdown/vendor/ruby/2.6.0/gems/rspec-core-3.8.0/exe/rspec --pattern spec/\\*\\*\\{,/\\*/\\*\\*\\}/\\*_spec.rb --color --format progress --format RspecJunitFormatter --out rspec.xml',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 4511,
      content: [
        {
          text: '/builds/gitlab-org/gitlab_kramdown/lib/gitlab_kramdown/parser/autolink.rb:22: warning: character class has duplicated range',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 4635,
      content: [
        {
          text: '.../builds/gitlab-org/gitlab_kramdown/vendor/ruby/2.6.0/gems/asciidoctor-plantuml-0.0.9/lib/asciidoctor-plantuml/plantuml.rb:226: warning: URI.regexp is obsolete',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 4797,
      content: [
        {
          text: '....../builds/gitlab-org/gitlab_kramdown/vendor/ruby/2.6.0/gems/kramdown-1.16.2/lib/kramdown/parser/kramdown.rb:226: warning: character class has duplicated range',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 4960,
      content: [
        {
          text: '...',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 4965,
      content: [
        {
          text: 'Finished in 0.19853 seconds (files took 0.37581 seconds to load)',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 5030,
      content: [
        {
          text: '12 examples, 0 failures',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 5055,
      content: [
        {
          text: 'Coverage report generated for RSpec to /builds/gitlab-org/gitlab_kramdown/coverage. 5458 / 13842 LOC (39.43%) covered.',
        },
      ],
      section: 'build-script',
    },
    {
      offset: 5174,
      content: [],
      section: 'build-script',
      section_duration: '00:04',
    },
    {
      offset: 5256,
      content: [],
      section: 'after-script',
      section_duration: '00:01',
    },
    {
      offset: 5296,
      content: [
        {
          text: 'Creating cache ruby2.6...',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'archive-cache',
      section_header: true,
    },
    {
      offset: 5377,
      content: [
        {
          text: 'vendor/ruby: found 4944 matching files            ',
        },
        {
          text: ' ',
        },
      ],
      section: 'archive-cache',
    },
    {
      offset: 5434,
      content: [
        {
          text: 'Uploading cache.zip to https://storage.googleapis.com/gitlab-com-runners-cache/project/5647182/ruby2.6',
        },
        {
          text: ' ',
        },
      ],
      section: 'archive-cache',
    },
    {
      offset: 5543,
      content: [
        {
          text: 'Created cache',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'archive-cache',
    },
    {
      offset: 5569,
      content: [],
      section: 'archive-cache',
      section_duration: '00:12',
    },
    {
      offset: 5610,
      content: [
        {
          text: 'Uploading artifacts...',
          style: 'term-fg-l-green term-bold',
        },
      ],
      section: 'upload-artifacts-on-success',
      section_header: true,
    },
    {
      offset: 5702,
      content: [
        {
          text: 'rspec.xml: found 1 matching files                 ',
        },
        {
          text: ' ',
        },
      ],
      section: 'upload-artifacts-on-success',
    },
    {
      offset: 5759,
      content: [
        {
          text: 'Uploading artifacts to coordinator... ok          ',
        },
        {
          text: '  id',
        },
        {
          text: '=323304022 responseStatus',
        },
        {
          text: '=201 Created token',
        },
        {
          text: '=R9w-JWWM',
        },
      ],
      section: 'upload-artifacts-on-success',
    },
    {
      offset: 5886,
      content: [],
      section: 'upload-artifacts-on-success',
      section_duration: '00:03',
    },
    {
      offset: 5941,
      content: [
        {
          text: 'Job succeeded',
          style: 'term-fg-l-green term-bold',
        },
      ],
    },
  ],
};
  1. Import traceOld mocked data to app/assets/javascripts/jobs/store/mutations.js
  2. Replace line 52 of the aforementioned file with the following
diff --git a/app/assets/javascripts/jobs/store/mutations.js b/app/assets/javascripts/jobs/store/mutations.js
index 4045d8a0c16..3b1b7cdad32 100644
--- a/app/assets/javascripts/jobs/store/mutations.js
+++ b/app/assets/javascripts/jobs/store/mutations.js
@@ -50,7 +50,8 @@ export default {
       // will be set to `null`

       if (infinitelyCollapsibleSectionsFlag) {
-        const parsedResult = logLinesParser(log.lines);
+        // const parsedResult = logLinesParser(log.lines);
+        const parsedResult = logLinesParser(traceOld.lines);
         state.trace = parsedResult.parsedLines;
         state.auxiliaryPartialTraceHelpers = parsedResult.auxiliaryPartialTraceHelpers;
       } else {

The job trace should render

Does this MR meet the acceptance criteria?

Conformity

Edited by Jose Ivan Vargas

Merge request reports