Fix Gitaly up-to-date check for versions with a Git revision suffix

What does this MR do and why?

Since GitLab 19.4, Gitaly built from a shallow clone reports its version as X.Y.Z-g<revision> (gitaly!9173 (merged) falls back to the VERSION file plus the short revision when git describe finds no tag; the Linux package build uses depth: 1). Gitaly::Server#expected_version? only recognised the full git describe form (X.Y.Z-N-g<8 hex>) and only compared the revision against the expected version, which on a tagged release is 19.4.1, not a SHA. As a result Admin > Gitaly servers shows every external Linux-package Gitaly as not up to date, even when it runs exactly the expected version.

This MR replaces SHA_VERSION_REGEX with VERSION_WITH_REVISION_REGEX, which captures both the semantic version (including pre-release labels and the old commit count) and the revision, and makes the check pass when either:

  • the captured version equals GITALY_SERVER_VERSION (tagged releases: 19.4.1 vs 19.4.1-g7985a4e), or
  • GITALY_SERVER_VERSION is a commit SHA that starts with the revision (auto-deploy: 5a2cb57… vs 19.5.0-rc2-g5a2cb57), which is the pre-existing behaviour.

SHA_VERSION_REGEX and matches_sha? had no other callers.

Not changed here: warn_gitaly_out_of_date! in lib/tasks/gitlab/gitaly.rake has the same start_with? assumption, but it only runs from gitlab:gitaly:install (source installs). Happy to fold it in if preferred.

Closes #631560 (closed)

References

How to set up and validate locally

On any instance whose Gitaly reports a revision suffix (a Linux-package 19.4+ external Gitaly, or the current gitlab/gitlab-ee:nightly image):

# gitlab-rails runner
puts "expected=#{Gitlab::GitalyClient.expected_server_version}"
Gitaly::Server.all.each { |s| puts "#{s.storage}: #{s.server_version} -> up_to_date=#{s.up_to_date?}" }

Verified on two Linux-package (Docker) instances, by swapping lib/gitaly/server.rb and re-running the snippet in a fresh gitlab-rails runner:

Tagged release, the customer scenario (gitlab/gitlab-ee:19.4.1-ee.0, bundled Gitaly, no Praefect):

expected=19.4.1
before: default: 19.4.1-g7985a4e -> up_to_date=false   (Admin > Gitaly servers shows "Not enabled")
after:  default: 19.4.1-g7985a4e -> up_to_date=true    (Admin > Gitaly servers shows "Enabled")

Auto-deploy with a pre-release version (gitlab/gitlab-ee:nightly, 19.5.0-pre):

expected=5a2cb573a3ab204375ee8dc0b660116c9bf2c651
before: default: 19.5.0-rc2-g5a2cb57 -> up_to_date=false
after:  default: 19.5.0-rc2-g5a2cb57 -> up_to_date=true

Specs: bundle exec rspec spec/lib/gitaly/server_spec.rb (six new rows in the #expected_version? table).

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading
Loading