Allow GitLab-hosted Dedicated runners for trusted flows

Problem

Foundational flows marked gitlab_hosted_runner_only run only on GitLab-hosted runners, and today that means GitLab.com only. On GitLab Dedicated they can't run at all, even on the hosted runners GitLab operates for the instance. Their job image also follows the instance's configurable image registry setting.

Change

  • For these flows, also accept GitLab-hosted runners on Dedicated: instance runners created by GitLab (dedicated_gitlab_hosted?). Runners registered by customers stay refused.
  • These flows always use the image from registry.gitlab.com, whatever duo_workflows_default_image_registry is set to. Other flows are unchanged.

Impact

Today With this MR
GitLab.com GitLab-hosted instance runners only unchanged
Dedicated, GitLab-hosted instance runner refused accepted
Dedicated, customer-registered runner refused refused
Dedicated, GitLab-hosted group runner refused refused
Image for hosted-runner-only flows follows the instance registry setting always registry.gitlab.com

Tests

  • runner_validator_spec.rb: on Dedicated, a GitLab-hosted instance runner is accepted; a customer-registered instance runner and a GitLab-hosted group runner are refused.
  • start_workflow_service_spec.rb: with the registry setting configured, hosted-runner-only flows still use registry.gitlab.com, and other flows use the setting.

How to set up and validate

Tested on its own: this MR at 7be6d060f6ae merged into master 2e006563edd4; AI gateway and Duo Workflow Service on plain main. Checked through rails runner (no flow reaches a Dedicated runner without the other MRs).

Runner (Dedicated) master this MR
Instance runner registered by GitLab (Admin Bot) refused accepted
Instance runner registered by a customer admin refused refused
Project runner refused refused
Group runner registered by GitLab refused refused
Instance runner registered by GitLab, on Self-Managed refused refused
  • Image: with duo_workflows_default_image_registry set to a custom registry, the hosted-runner-only flow uses registry.gitlab.com/...; another flow keeps the custom registry.
  • Specs (its 2 spec files): 206 examples, 0 failures.

Validated together with Add available_on to foundational flows, with pe... (!262262 - merged), Enable BLSA per instance on GitLab Dedicated (!262270 - merged), Allow GitLab-hosted Dedicated runners for trust... (!262250 - merged) and fix(dws): restrict models rather than flows for... (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!7474 - merged), in a GDK set up as GitLab Dedicated. The bl_security_analyzer flag stayed off throughout, so the instance AI beta setting did all the gating.

Steps to reproduce

Prepare the GDK

  1. Check out a gitlab branch that contains Add available_on to foundational flows, with pe... (!262262 - merged), Enable BLSA per instance on GitLab Dedicated (!262270 - merged) and Allow GitLab-hosted Dedicated runners for trust... (!262250 - merged). Run the Duo Workflow Service from fix(dws): restrict models rather than flows for... (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!7474 - merged) (restricted-model-not-flow).
  2. Use an Ultimate license with GitLab Duo Agent Platform. Don't simulate SaaS: GITLAB_SIMULATE_SAAS unset or 0.
  3. Simulate Dedicated in gdk rails console, keeping the flag off:
    ApplicationSetting.current.update!(gitlab_dedicated_instance: true)
    Gitlab::Dedicated.feature_available?(:ai_flows_via_beta_setting) # => true
    Feature.enabled?(:bl_security_analyzer)                           # => false
  4. Turn the instance AI beta setting on or off in Admin area > GitLab Duo > Configuration > Feature preview (Turn on experiment and beta GitLab Duo features). Settings are cached for about a minute; wait or restart rails-web.

Run BLSA

  1. Create a group and a project with a small app. Open an MR that adds a business-logic bug, such as a refund endpoint that doesn't check the order's owner.
  2. In the group's GitLab Duo settings, turn on foundational flows and select the Business Logic Security Analyzer flow.
  3. Apply a Business logic scan profile in Project > Secure > Security configuration, with the Merge Request Pipelines trigger on.
  4. Register an instance runner (docker executor, gitlab--duo tag) whose creator is the GitLab Admin Bot, which is how Dedicated's GitLab-hosted runners are registered. Admin area > CI/CD > Runners shows "Created by GitLab Admin Bot".
  5. Give the MR a passing pipeline. When it passes, a Duo Agent Platform pipeline starts with one workload job: that's the BLSA run.
  6. Also register two customer runners with the gitlab--duo tag: an instance runner created from Admin area > CI/CD > Runners ("Created by Administrator") and a project runner. Keep only one runner unpaused per run, so you know which one picks up the job.

What to look for

Runner BLSA job
Instance runner registered by GitLab (Admin Bot) Passed
Instance runner created by an administrator Failed, duo_workflow_not_allowed, no trace
Project runner Failed, duo_workflow_not_allowed, no trace

The job image is registry.gitlab.com/gitlab-org/duo-workflow/default-docker-image/workflow-generic-image.

Screenshots

Runners

Runners and who registered them

Job on the GitLab-registered instance runner: passed

Job passed on the GitLab-registered runner

Job on a project runner: refused

Job refused on a project runner

Job on an administrator-created instance runner: refused

Job refused on an admin-created instance runner

Log evidence
job 434  success  runner #32 instance_type, created by GitLab Admin Bot
job 436  failed   failure_reason=duo_workflow_not_allowed  runner #33 project_type, created by Administrator
job 438  failed   failure_reason=duo_workflow_not_allowed  runner #34 instance_type, created by Administrator
Jobs 436 and 438 have no trace: the runner is refused before the job starts.

Not in this MR

  • On Dedicated, the check relies on how the runner was registered (an instance runner GitLab created). It doesn't verify the machine that runs the job.

  • Making a flow available on Dedicated (separate MR).

  • Any token or model changes.

Context

Part of https://gitlab.com/gitlab-org/gitlab/-/work_items/633832+.

Edited by Meir Benayoun

Merge request reports

Loading
Loading