Incorrect KAS address when running GitLab on a relative URL
Summary
When running GitLab on a relative URL, e.g. http://example.org/gitlab
, attempts to connect a cluster agent tell the user to install their agent with a kasAddress
of ws://example.org//gitlab-/kubernetes-agent/
. Note the //
after the host name and the missing /
in the subpath.
Steps to reproduce
- run GitLab on a relative URL
- connect a cluster agent
What is the current bug behavior?
The popup tells the user to deploy an agent to the cluster with
helm upgrade --install gitlab-agent gitlab/gitlab-agent \
--namespace gitlab-agent \
--create-namespace \
--set config.token=[REDACTED] \
--set config.kasAddress=ws://example.org//gitlab-/kubernetes-agent/
What is the expected correct behavior?
helm upgrade --install gitlab-agent gitlab/gitlab-agent \
--namespace gitlab-agent \
--create-namespace \
--set config.token=[REDACTED] \
--set config.kasAddress=ws://example.org/gitlab/-/kubernetes-agent/
Relevant logs
N/A
Details of package version
Running the gitlab/gitlab-ce:15.0.0-ce.0
Docker image.
Environment details
Running the gitlab/gitlab-ce:15.0.0-ce.0
Docker image.
Configuration details
Using GITLAB_OMNIBUS_CONFIG
to specify my configuration, /etc/gitlab/gitlab.rb
is a copy of the template.
My GITLAB_OMNIBUS_CONFIG
has
external_url "http://example.org/gitlab"
Fix
diff --git a/files/gitlab-cookbooks/gitlab-kas/libraries/gitlab_kas.rb b/files/gitlab-cookbooks/gitlab-kas/libraries/gitlab_kas.rb
index 31ad1942b..aa31b71b6 100644
--- a/files/gitlab-cookbooks/gitlab-kas/libraries/gitlab_kas.rb
+++ b/files/gitlab-cookbooks/gitlab-kas/libraries/gitlab_kas.rb
@@ -63,7 +63,7 @@ module GitlabKas
raise "external_url scheme should be 'http' or 'https', got '#{gitlab_uri.scheme}"
end
- Gitlab['gitlab_rails'][key] = "#{scheme}://#{gitlab_uri.host}#{port}/#{gitlab_uri.path}-/kubernetes-agent/"
+ Gitlab['gitlab_rails'][key] = "#{scheme}://#{gitlab_uri.host}#{port}#{gitlab_uri.path}/-/kubernetes-agent/"
end
def parse_gitlab_kas_internal_url