Skip to content

Fix FF `ci_includes_count_duplicates` condition to check variable type

Leaminn Ma requested to merge 391517-fix-ci_includes_count_duplicates into master

What does this MR do and why?

Upon rolling out the FF ci_includes_count_duplicates introduced by Update CI includes counting structure to includ... (!111726 - merged), an incident occurred, which was due to mismatching Feature Flag project actors. This is explained in more detail here.

The specific error that arose was due to .add being called on an Array. This MR prevents this issue by implementing a variable type check. This change will only be necessary until ci_includes_count_duplicates is removed.

Related corrective action issue: https://gitlab.com/gitlab-com/gl-infra/reliability/-/issues/17420

How to reproduce the error locally

With the current master branch checked out:

  1. Create 2 projects Project 1 and Project 2.
  2. In Project 1, create a file template1.yml with the following content:
template1-job:
  script: echo 'test'
  1. In Project 1, update the .gitlab-ci.yml file with the following content:
include:
  - local: template1.yml
  - local: template1.yml
  1. In Project 2, update the .gitlab-ci.yml to include Project 1. Example:
include:
  - project: group-a/project-1
    file: .gitlab-ci.yml
  1. Enable FF ci_includes_count_duplicates for only Project 2.
Feature.disable(:ci_includes_count_duplicates) # Ensure it is off globally first
Feature.enable(:ci_includes_count_duplicates, Project.find_by(name: 'Project 2'))
  1. Run the pipeline in Project 2. Observe that you get the following error:

Screenshot_2023-02-15_at_2.34.25_PM

How to set up and validate locally

Check out this MR's branch, follow steps 1-6 above and observe that there is no error in Step 6.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #391517 (closed)

Edited by Leaminn Ma

Merge request reports