Skip to content

Allow YamlProcessor to use project as actor in feature flag checks

Fabio Pitino requested to merge ci-yaml-processor-with-ff-actor into master

What does this MR do and why?

Related to #366315 (closed)

In this MR we are adding a functionality inside Gitlab::Ci::YamlProcessor that allows feature flag checks to be used with a project as actor. Prior to this change it wasn't possible to use actors in feature flag checks within Gitlab::Ci::Config or any entry classes. We could not enable the feature flag incrementally because using percentage of actors wasn't possible and using percentage of time would produce inconsistent and dangerous results.

Instead of passing a project object to all objects inside Ci::Config we set a thread local variable and have a wrapper of Feature.enabled? that would use the cached actor.

In !91281 (closed) it's demonstrated how this could be used.

Gitlab::Ci::YamlProcessor::FeatureFlags.with_actor(project) do
  # process yaml
end

# somewhere inside an object instantiated by `Ci::Config`:
Gitlab::Ci::YamlProcessor::FeatureFlags.enabled?(:my_feature_flag)

MR acceptance checklist

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

Edited by Fabio Pitino

Merge request reports