Trust only hosted registrations for Dedicated GitLab-hosted runners

Problem

The trusted-runtime runner check from Allow GitLab-hosted Dedicated runners for trust... (!262250 - merged) counts a GitLab Dedicated instance runner as GitLab-hosted based on signals an instance admin can set (raised in !262250 (comment 4057522487)). It is not reachable while BLSA is offered on GitLab.com only, but it must be fixed before BLSA is offered on Dedicated (Enable BLSA per instance on GitLab Dedicated (!262270 - merged)).

Change

  • Ai::DuoWorkflow::RunnerValidator#gitlab_hosted_runner?: on Dedicated, a runner counts as GitLab-hosted only if it is an instance runner with a hosted registration (Ci::HostedRunner).
    • Only GitLab's runner provisioning writes a hosted registration (EE CreateRunnerService with hosted_runner: true, which itself requires Dedicated). Neither REST POST /user/runners nor GraphQL runnerCreate creates one.
    • It no longer uses Ci::Runner#dedicated_gitlab_hosted? (a runner created by the Admin Bot, once the gitlab_dedicated_instance setting is on). That method is unchanged, because Dedicated minutes billing uses it.
  • This check tells which runners GitLab provisioned. Keeping those runners under GitLab's control also needs Prevent admin token resets on Dedicated hosted ... (!262278 - merged), which stops instance admins from resetting a hosted runner's authentication token. Enable BLSA per instance on GitLab Dedicated (!262270 - merged) is blocked by both MRs.
  • The duo_workflow_not_allowed job message now says that some flows run only on GitLab-hosted runners. It used to say only "instance wide or top level group runners", which misled when an instance runner was refused.
  • GitLab.com is unchanged (dot_com_gitlab_hosted?).
  • Self-Managed instances are refused upstream by the per-instance flow allowlist (Add available_on to foundational flows, with pe... (!262262 - merged)).

Impact

Runner Before After
Dedicated instance runner with a hosted registration (GitLab-provisioned) trusted trusted
Dedicated instance runner created by the Admin Bot, no hosted registration trusted refused
Dedicated instance runner created by an admin; project or group runner refused refused
GitLab.com hosted runner trusted trusted

Trade-offs:

  • A hosted runner provisioned on Dedicated stays trusted if the gitlab_dedicated_instance setting is later turned off. Self-Managed is still refused by the flow allowlist.
  • A Dedicated hosted runner provisioned without a hosted registration (there is no backfill) is refused, so it can't run BLSA. To confirm with the Dedicated team before enabling a tenant.

How to set up and validate

Tested on its own on 2026-10-21 at fe2f1daa6fcc; dc77144c3c56 then changes only the job message and locale/gitlab.pot. Runner checks below at fe2f1daa6fcc, against its base 9f060271b16c on master. The script creates each runner through Ci::Runners::CreateRunnerService, on a GDK set up as Dedicated (gitlab_dedicated_instance on, not GitLab.com), and prints what the trusted-runtime check decides.

Runner Before (9f060271b16c) After (fe2f1daa6fcc)
Admin Bot instance runner with hosted_runner: true (GitLab-provisioned) trusted trusted
Admin Bot instance runner, no hosted registration trusted refused
Instance runner created by an admin refused refused
Project runner refused refused
Self-Managed, hosted_runner: true no hosted registration written; refused same
Check at fe2f1daa6fcc Result
runner_validator_spec.rb, hosted_runner_spec.rb 31 examples, 0 failures
The new spec without the change (also require an Admin Bot creator) fails
RuboCop on the changed files no offenses
At dc77144c3c56: commit_status_presenter_spec.rb; ee/spec/services/ci/register_job_service_spec.rb -e duo; gettext:updated_check and gettext:lint 64 and 3 examples, 0 failures; pot up to date and valid
CI see the pipeline on this head

Evidence

Before: base 9f060271b16c
HEAD=9f060271b16c Gitlab.com?=false
Dedicated: gitlab_dedicated_instance=true feature_available?(:hosted_runners)=true
(a) admin bot, instance, hosted_runner: true | hosted_registration=true | gitlab_hosted_runner?=true
(b) admin bot, instance, no hosted registration | hosted_registration=false | gitlab_hosted_runner?=true
(c) regular admin, instance | hosted_registration=false | gitlab_hosted_runner?=false
(d) project runner | hosted_registration=false | gitlab_hosted_runner?=false
Self-Managed: gitlab_dedicated_instance=false
(a) admin bot, instance, hosted_runner: true | hosted_registration=false | gitlab_hosted_runner?=false
cleanup: runners_left=0 hosted_left=0 gitlab_dedicated_instance=false
After: this MR at fe2f1daa6fcc
HEAD=fe2f1daa6fcc Gitlab.com?=false
Dedicated: gitlab_dedicated_instance=true feature_available?(:hosted_runners)=true
(a) admin bot, instance, hosted_runner: true | hosted_registration=true | gitlab_hosted_runner?=true
(b) admin bot, instance, no hosted registration | hosted_registration=false | gitlab_hosted_runner?=false
(c) regular admin, instance | hosted_registration=false | gitlab_hosted_runner?=false
(d) project runner | hosted_registration=false | gitlab_hosted_runner?=false
Self-Managed: gitlab_dedicated_instance=false
(a) admin bot, instance, hosted_runner: true | hosted_registration=false | gitlab_hosted_runner?=false
cleanup: runners_left=0 hosted_left=0 gitlab_dedicated_instance=false
Script

Run with GITLAB_SIMULATE_SAAS=0 bin/rails runner -e development <script> on a GDK. For each case it creates a runner with Ci::Runners::CreateRunnerService (as the Admin Bot, an admin, or for a project), then prints Ai::DuoWorkflow::RunnerValidator.new(runner, nil).send(:gitlab_hosted_runner?), and deletes what it created.

Context

🤖 Generated with Claude Code

Edited by Meir Benayoun

Merge request reports

Loading
Loading