From: Redouane Kachach Date: Wed, 31 Jul 2024 11:23:13 +0000 (+0200) Subject: mgr/cephadm: fixing Grafana domain handling X-Git-Tag: v20.0.0~1356^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d95e8511eb606262f8c7bd46ca53dccf52c640c9;p=ceph.git mgr/cephadm: fixing Grafana domain handling it seems that with Grafana 10.4.0 the domain parameter is taken into account while building the final url (earlier versions didn't seem to behave the same way). This change sets the domain to the hostname where Grafana daemon is running instead of '*.lab'. serve_from_sub_path is removed as it's no needed and when add it causes some undesirable redirections that could break monitoring HA. Signed-off-by: Redouane Kachach --- diff --git a/src/pybind/mgr/cephadm/services/monitoring.py b/src/pybind/mgr/cephadm/services/monitoring.py index 3a20bbfe4853..33a986fed7a3 100644 --- a/src/pybind/mgr/cephadm/services/monitoring.py +++ b/src/pybind/mgr/cephadm/services/monitoring.py @@ -97,7 +97,8 @@ class GrafanaService(CephadmService): 'http_port': grafana_port, 'protocol': spec.protocol, 'http_addr': grafana_ip, - 'use_url_prefix': mgmt_gw_enabled + 'use_url_prefix': mgmt_gw_enabled, + 'domain': daemon_spec.host, }) if 'dashboard' in self.mgr.get('mgr_map')['modules'] and spec.initial_admin_password: diff --git a/src/pybind/mgr/cephadm/templates/services/grafana/grafana.ini.j2 b/src/pybind/mgr/cephadm/templates/services/grafana/grafana.ini.j2 index 4d3d11e20831..69569ec7b63f 100644 --- a/src/pybind/mgr/cephadm/templates/services/grafana/grafana.ini.j2 +++ b/src/pybind/mgr/cephadm/templates/services/grafana/grafana.ini.j2 @@ -8,15 +8,14 @@ org_role = 'Viewer' {% endif %} [server] - domain = 'bootstrap.storage.lab' + domain = '{{ domain }}' protocol = {{ protocol }} cert_file = /etc/grafana/certs/cert_file cert_key = /etc/grafana/certs/cert_key http_port = {{ http_port }} http_addr = {{ http_addr }} {% if use_url_prefix %} - root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/ - serve_from_sub_path = true + root_url = %(protocol)s://%(domain)s/grafana/ {% endif %} [snapshots] external_enabled = false diff --git a/src/pybind/mgr/cephadm/tests/test_services.py b/src/pybind/mgr/cephadm/tests/test_services.py index 179f11760595..816d13cb6fad 100644 --- a/src/pybind/mgr/cephadm/tests/test_services.py +++ b/src/pybind/mgr/cephadm/tests/test_services.py @@ -1224,7 +1224,7 @@ class TestMonitoring: org_name = 'Main Org.' org_role = 'Viewer' [server] - domain = 'bootstrap.storage.lab' + domain = 'test' protocol = https cert_file = /etc/grafana/certs/cert_file cert_key = /etc/grafana/certs/cert_key @@ -1332,7 +1332,7 @@ class TestMonitoring: " org_name = 'Main Org.'\n" " org_role = 'Viewer'\n" '[server]\n' - " domain = 'bootstrap.storage.lab'\n" + " domain = 'test'\n" ' protocol = https\n' ' cert_file = /etc/grafana/certs/cert_file\n' ' cert_key = /etc/grafana/certs/cert_key\n' @@ -1394,7 +1394,7 @@ class TestMonitoring: '[users]\n' ' default_theme = light\n' '[server]\n' - " domain = 'bootstrap.storage.lab'\n" + " domain = 'test'\n" ' protocol = https\n' ' cert_file = /etc/grafana/certs/cert_file\n' ' cert_key = /etc/grafana/certs/cert_key\n'