diff options
author | Tatjana Dehler <tdehler@suse.com> | 2022-07-25 18:04:58 +0200 |
---|---|---|
committer | Tatjana Dehler <tdehler@suse.com> | 2022-09-07 11:18:55 +0200 |
commit | 2e15f0f0d2df55bf0c4bc1673a3b7a4b3862d7e2 (patch) | |
tree | 4847b869d45a9f0ef7f6ab978cc7c822dfc40bca /src/pybind/mgr/dashboard/module.py | |
parent | Merge pull request #46741 from Matan-B/wip-matanb-docker-debug (diff) | |
download | ceph-2e15f0f0d2df55bf0c4bc1673a3b7a4b3862d7e2.tar.xz ceph-2e15f0f0d2df55bf0c4bc1673a3b7a4b3862d7e2.zip |
mgr/dashboard: add option to resolve ip addr
Add the option `redirect_resolve_ip_addr` to the dashboard module.
If the option is set to `True`, try to resolve the IP address before
redirecting from the passive to the active mgr instance.
If the option is set to `False`, follow the already known behavior.
Fixes: https://tracker.ceph.com/issues/56699
Signed-off-by: Tatjana Dehler <tdehler@suse.com>
Diffstat (limited to 'src/pybind/mgr/dashboard/module.py')
-rw-r--r-- | src/pybind/mgr/dashboard/module.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 946c853f880..c82df154136 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -6,12 +6,14 @@ import collections import errno import logging import os +import socket import ssl import sys import tempfile import threading import time from typing import TYPE_CHECKING, Optional +from urllib.parse import urlparse if TYPE_CHECKING: if sys.version_info >= (3, 8): @@ -268,7 +270,8 @@ class Module(MgrModule, CherryPyConfig): Option(name='standby_behaviour', type='str', default='redirect', enum_allowed=['redirect', 'error']), Option(name='standby_error_status_code', type='int', default=500, - min=400, max=599) + min=400, max=599), + Option(name='redirect_resolve_ip_addr', type='bool', default=False) ] MODULE_OPTIONS.extend(options_schema_list()) for options in PLUGIN_MANAGER.hook.get_options() or []: @@ -525,6 +528,13 @@ class StandbyModule(MgrStandbyModule, CherryPyConfig): return None if active_uri: + if module.get_module_option('redirect_resolve_ip_addr'): + p_result = urlparse(active_uri) + hostname = str(p_result.hostname) + fqdn_netloc = p_result.netloc.replace( + hostname, socket.getfqdn(hostname)) + active_uri = p_result._replace(netloc=fqdn_netloc).geturl() + module.log.info("Redirecting to active '%s'", active_uri) raise cherrypy.HTTPRedirect(active_uri) else: |