Skip to content

Toggle ActiveContext::Code project indexing behind a feature flag

What does this MR do and why?

Currently, the ActiveContext Code processes allows per-namespace rollout by specifying NAMESPACE_IDS in the SaasInitialIndexingEventWorker.

We need to support rollout specific to the gitlab-org/gitlab project so that we can do initial indexing on staging/production. This would make it easier to monitor the initial rollout.

References

Screenshots or screen recordings

N/A

How to set up and validate locally

With no projects enabled for active_context_code_index_project FF

  1. Follow the state management testing guide up to "Run saas_initial_indexing task". Ensure that the Ai::ActiveContext::Code::EnabledNamespace record's state is pending.

  2. With the Ai::ActiveContext::Code::EnabledNamespace record created in Step 1, run the ProcessPendingEnabledNamespaceEventWorker synchronously:

    Ai::ActiveContext::Code::ProcessPendingEnabledNamespaceEventWorker.new.handle_event("")
  3. Verify that no Ai::ActiveContext::Code::Repository records for the namespace were created:

    ::Ai::ActiveContext::Code::Repository.where(enabled_namespace_id: <id of namespace from step 1>)
    => []

With the active_context_code_index_project FF for certain projects

  1. Follow the state management testing guide up to "Run saas_initial_indexing task". Ensure that the Ai::ActiveContext::Code::EnabledNamespace record's state is pending.

  2. Pick a project under the code_embeddings-enabled namespace and enable the FF for it:

    Feature.enable(:active_context_code_index_project, <the project>)
  3. With the Ai::ActiveContext::Code::EnabledNamespace record created in Step 1, run the ProcessPendingEnabledNamespaceEventWorker synchronously:

    Ai::ActiveContext::Code::ProcessPendingEnabledNamespaceEventWorker.new.handle_event("")
  4. Verify that there is Ai::ActiveContext::Code::Repository record for the project you selected:

    ::Ai::ActiveContext::Code::Repository.where(enabled_namespace_id: <id of namespace from step 1>)
    => [#<Ai::ActiveContext::Code::Repository:0x000000031c817800...<details>]

MR acceptance checklist

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

Related to #555558 (closed)

Edited by Pam Artiaga

Merge request reports

Loading