Skip job request and warn when runner token is empty
What does this MR do?
When the runner token is empty or whitespace-only in config.toml, the runner is silently skipped during job polling (no log spam), and a single operator-facing warning is emitted once per config load.
Why was this MR needed?
When token is missing from a [[runners]] entry in config.toml (by mistake or misconfiguration), the runner was still sending a job request on every poll. GitLab rejected each one with 400 Bad Request. The logged errors did not surface the root cause, forcing operators to cross-reference failures against config.toml to discover the token was missing.
Root cause: There was no guard for an empty token before a runner was fed into the workers channel, so invalid runners reached processRunner and triggered network calls.
Fix — two concerns, two places:
-
feedRunner(silent gate): Whenrunner.Tokenis empty or whitespace-only,feedRunnerincrementsrunnerWorkersFeedFailuresand returns immediately — no log. This matches the existingisHealthygate exactly and keeps the invalid runner out of the worker pipeline without producing log spam on every poll cycle. -
reloadConfig(once-per-load warning): The operator-facing warning is emitted in the per-runner loop insidereloadConfig(), alongside the existingWarnOnLegacyCIURL()call. This fires exactly once at startup and once on each config reload — when the misconfiguration is actionable. Nosync.Mapor per-runner dedup state is needed: the config-version boundary is the natural throttle.
What is the best way to test this MR?
- Add a
[[runners]]entry toconfig.tomlwith an empty or missingtokenfield. - Start the runner and observe that:
- No job requests are sent to GitLab for that runner.
- A warning is logged once at startup (and once on each reload).
- No repeated warnings appear during normal polling.
- Run the unit tests:
go test -run TestFeedRunner_EmptyToken|TestReloadConfig_EmptyTokenWarning ./commands/
What are the relevant issue numbers?
Closes #39495