Prefix rails-metrics proxy_pass with the relative URL

What does this MR do?

When external_url has a path (for example http://gitlab.example.com/gitlab), the NGINX status location /rails-metrics returned HTTP 404. The template proxied to http://gitlab-workhorse/-/metrics without the relative URL, and Workhorse does not send paths outside that prefix to Puma.

!9929 (merged) already fixed the Prometheus scrape job for this case. This MR uses the same Prometheus.rails_metrics_path helper so /rails-metrics proxies to /gitlab/-/metrics (and still to /-/metrics when there is no relative URL).

Closes #10221 (closed)

How to test

  1. Set external_url 'http://gitlab.example.com/gitlab' and reconfigure.

  2. On the node:

    curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8060/rails-metrics

    This should return 200, and the rendered file under extra_metrics_conf should contain proxy_pass http://gitlab-workhorse/gitlab/-/metrics;.

Locally: bundle exec rspec spec/chef/cookbooks/nginx/recipes/nginx_spec.rb (112 examples, 0 failures), including examples for the default path and a relative URL. bundle exec rubocop on the touched Ruby files reported no offenses.

Checklist

  • MR title and description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • Tests added.
  • Latest Merge Result pipeline is green.
  • When ready for review, MR is marked as ready (not a draft) and a reviewer is requested.
Edited by Priyanshu Jha

Merge request reports

Loading
Loading