Skip the scheduled version check when version check is disabled

What does this MR do and why?

With Enable version check cleared, Gitlab::Version::VersionCheckCronWorker still requests version.gitlab.com daily, because it never reads that setting. This MR returns early from perform when the setting is off, as VersionCheckHelper#show_version_check? does.

Where the setting applies

flowchart TD
    cron["config/schedule.yml<br/>version_version_check_cron, 00:00 UTC"] --> within["Gitlab::Scheduling::ScheduleWithinWorker<br/>random delay up to 24 hours"]
    within --> worker["Gitlab::Version::VersionCheckCronWorker#perform"]
    worker -->|"GET /check.json?gitlab_info=..."| vgc(["version.gitlab.com"])
    worker -->|"Rails.cache.write"| cache[("version check cache")]
    setting{{"version_check_enabled<br/>Enable version check"}} -->|"gates"| helper["VersionCheckHelper#show_version_check?"]
    setting -.->|"gates, with this MR"| worker
    helper -->|"reads"| cache
    helper -->|"perform_async on a cache miss"| worker
    helper --> readers["SidebarsHelper<br/>Admin::VersionCheckController"]

References

Screenshots or screen recordings

Not applicable: no UI change.

How to set up and validate locally

  1. In Admin > Settings > Metrics and profiling, expand Usage statistics, clear Enable version check, and select Save changes.
  2. While capturing outbound traffic, run Gitlab::Version::VersionCheckCronWorker.new.perform in a Rails console.

An AI coding assistant helped prepare this MR. The assistant wrote the change, checked each claim here against the source it cites, and ran these checks on test VMs:

  • On a self-managed 19.4.1 instance with outbound traffic captured and the box cleared, the worker opened one connection to version.gitlab.com without the guard line and none with it. With the box checked, the guarded worker still connected once.
  • On a GitLab source checkout at master 70f44614, RuboCop is clean and the worker spec passes (9 examples, 0 failures). Without the guard, the new context fails.

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.

Merge request reports

Loading
Loading