Blame SOURCES/cephadm-16.2.4-5.patch

bd0ffd
diff --git a/SOURCES/cephadm b/SOURCES/cephadm
bd0ffd
index a7b664c..107f705 100644
bd0ffd
--- a/SOURCES/cephadm
bd0ffd
+++ b/SOURCES/cephadm
bd0ffd
@@ -279,7 +279,6 @@ class Monitoring(object):
bd0ffd
             'args': [
bd0ffd
                 '--config.file=/etc/prometheus/prometheus.yml',
bd0ffd
                 '--storage.tsdb.path=/prometheus',
bd0ffd
-                '--web.listen-address=:{}'.format(port_map['prometheus'][0]),
bd0ffd
             ],
bd0ffd
             'config-json-files': [
bd0ffd
                 'prometheus.yml',
bd0ffd
@@ -310,7 +309,6 @@ class Monitoring(object):
bd0ffd
             'cpus': '2',
bd0ffd
             'memory': '2GB',
bd0ffd
             'args': [
bd0ffd
-                '--web.listen-address=:{}'.format(port_map['alertmanager'][0]),
bd0ffd
                 '--cluster.listen-address=:{}'.format(port_map['alertmanager'][1]),
bd0ffd
             ],
bd0ffd
             'config-json-files': [
bd0ffd
@@ -1473,6 +1471,16 @@ def call_timeout(ctx, command, timeout):
bd0ffd
 ##################################
bd0ffd
 
bd0ffd
 
bd0ffd
+def json_loads_retry(cli_func):
bd0ffd
+    for sleep_secs in [1, 4, 4]:
bd0ffd
+        try:
bd0ffd
+            return json.loads(cli_func())
bd0ffd
+        except json.JSONDecodeError:
bd0ffd
+            logger.debug('Invalid JSON. Retrying in %s seconds...' % sleep_secs)
bd0ffd
+            time.sleep(sleep_secs)
bd0ffd
+    return json.loads(cli_func())
bd0ffd
+
bd0ffd
+
bd0ffd
 def is_available(ctx, what, func):
bd0ffd
     # type: (CephadmContext, str, Callable[[], bool]) -> None
bd0ffd
     """
bd0ffd
@@ -2111,6 +2119,17 @@ def get_daemon_args(ctx, fsid, daemon_type, daemon_id):
bd0ffd
     elif daemon_type in Monitoring.components:
bd0ffd
         metadata = Monitoring.components[daemon_type]
bd0ffd
         r += metadata.get('args', list())
bd0ffd
+        # set ip and port to bind to for nodeexporter,alertmanager,prometheus
bd0ffd
+        if daemon_type != 'grafana':
bd0ffd
+            ip = ''
bd0ffd
+            port = Monitoring.port_map[daemon_type][0]
bd0ffd
+            if 'meta_json' in ctx and ctx.meta_json:
bd0ffd
+                meta = json.loads(ctx.meta_json) or {}
bd0ffd
+                if 'ip' in meta and meta['ip']:
bd0ffd
+                    ip = meta['ip']
bd0ffd
+                if 'ports' in meta and meta['ports']:
bd0ffd
+                    port = meta['ports'][0]
bd0ffd
+            r += [f'--web.listen-address={ip}:{port}']
bd0ffd
         if daemon_type == 'alertmanager':
bd0ffd
             config = get_parm(ctx.config_json)
bd0ffd
             peers = config.get('peers', list())  # type: ignore
bd0ffd
@@ -2907,15 +2926,7 @@ class Firewalld(object):
bd0ffd
 def update_firewalld(ctx, daemon_type):
bd0ffd
     # type: (CephadmContext, str) -> None
bd0ffd
     firewall = Firewalld(ctx)
bd0ffd
-
bd0ffd
     firewall.enable_service_for(daemon_type)
bd0ffd
-
bd0ffd
-    fw_ports = []
bd0ffd
-
bd0ffd
-    if daemon_type in Monitoring.port_map.keys():
bd0ffd
-        fw_ports.extend(Monitoring.port_map[daemon_type])  # prometheus etc
bd0ffd
-
bd0ffd
-    firewall.open_ports(fw_ports)
bd0ffd
     firewall.apply_rules()
bd0ffd
 
bd0ffd
 
bd0ffd
@@ -4009,14 +4020,15 @@ def command_bootstrap(ctx):
bd0ffd
 
bd0ffd
     image_ver = CephContainer(ctx, ctx.image, 'ceph', ['--version']).run().strip()
bd0ffd
     logger.info(f'Ceph version: {image_ver}')
bd0ffd
-    image_release = image_ver.split()[4]
bd0ffd
-    if (
bd0ffd
-        not ctx.allow_mismatched_release
bd0ffd
-        and image_release not in [DEFAULT_IMAGE_RELEASE, LATEST_STABLE_RELEASE]
bd0ffd
-    ):
bd0ffd
-        raise Error(
bd0ffd
-            f'Container release {image_release} != cephadm release {DEFAULT_IMAGE_RELEASE}; please use matching version of cephadm (pass --allow-mismatched-release to continue anyway)'
bd0ffd
-        )
bd0ffd
+
bd0ffd
+    if not ctx.allow_mismatched_release:
bd0ffd
+        image_release = image_ver.split()[4]
bd0ffd
+        if image_release not in \
bd0ffd
+                [DEFAULT_IMAGE_RELEASE, LATEST_STABLE_RELEASE]:
bd0ffd
+            raise Error(
bd0ffd
+                f'Container release {image_release} != cephadm release {DEFAULT_IMAGE_RELEASE};'
bd0ffd
+                ' please use matching version of cephadm (pass --allow-mismatched-release to continue anyway)'
bd0ffd
+            )
bd0ffd
 
bd0ffd
     logger.info('Extracting ceph user uid/gid from container image...')
bd0ffd
     (uid, gid) = extract_uid_gid(ctx)
bd0ffd
@@ -4089,15 +4101,6 @@ def command_bootstrap(ctx):
bd0ffd
                  '-i', '/var/lib/ceph/user.conf'],
bd0ffd
                 {tmp.name: '/var/lib/ceph/user.conf:z'})
bd0ffd
 
bd0ffd
-    def json_loads_retry(cli_func):
bd0ffd
-        for sleep_secs in [1, 4, 4]:
bd0ffd
-            try:
bd0ffd
-                return json.loads(cli_func())
bd0ffd
-            except json.JSONDecodeError:
bd0ffd
-                logger.debug('Invalid JSON. Retrying in %s seconds...' % sleep_secs)
bd0ffd
-                time.sleep(sleep_secs)
bd0ffd
-        return json.loads(cli_func())
bd0ffd
-
bd0ffd
     # wait for mgr to restart (after enabling a module)
bd0ffd
     def wait_for_mgr_restart():
bd0ffd
         # first get latest mgrmap epoch from the mon.  try newer 'mgr
bd0ffd
@@ -4316,9 +4319,6 @@ def command_deploy(ctx):
bd0ffd
     elif daemon_type in Monitoring.components:
bd0ffd
         # monitoring daemon - prometheus, grafana, alertmanager, node-exporter
bd0ffd
         # Default Checks
bd0ffd
-        if not ctx.reconfig and not redeploy:
bd0ffd
-            daemon_ports.extend(Monitoring.port_map[daemon_type])
bd0ffd
-
bd0ffd
         # make sure provided config-json is sufficient
bd0ffd
         config = get_parm(ctx.config_json)  # type: ignore
bd0ffd
         required_files = Monitoring.components[daemon_type].get('config-json-files', list())
bd0ffd
@@ -8131,18 +8131,15 @@ def _parse_args(av):
bd0ffd
     return args
bd0ffd
 
bd0ffd
 
bd0ffd
-def cephadm_init_ctx(args: List[str]) -> Optional[CephadmContext]:
bd0ffd
-
bd0ffd
+def cephadm_init_ctx(args: List[str]) -> CephadmContext:
bd0ffd
     ctx = CephadmContext()
bd0ffd
     ctx.set_args(_parse_args(args))
bd0ffd
     return ctx
bd0ffd
 
bd0ffd
 
bd0ffd
-def cephadm_init(args: List[str]) -> Optional[CephadmContext]:
bd0ffd
-
bd0ffd
+def cephadm_init(args: List[str]) -> CephadmContext:
bd0ffd
     global logger
bd0ffd
     ctx = cephadm_init_ctx(args)
bd0ffd
-    assert ctx is not None
bd0ffd
 
bd0ffd
     # Logger configuration
bd0ffd
     if not os.path.exists(LOG_DIR):
bd0ffd
@@ -8167,10 +8164,6 @@ def cephadm_init(args: List[str]) -> Optional[CephadmContext]:
bd0ffd
             if handler.name == 'console':
bd0ffd
                 handler.setLevel(logging.DEBUG)
bd0ffd
 
bd0ffd
-    if not ctx.has_function():
bd0ffd
-        sys.stderr.write('No command specified; pass -h or --help for usage\n')
bd0ffd
-        return None
bd0ffd
-
bd0ffd
     return ctx
bd0ffd
 
bd0ffd
 
bd0ffd
@@ -8185,7 +8178,8 @@ def main():
bd0ffd
     av = sys.argv[1:]
bd0ffd
 
bd0ffd
     ctx = cephadm_init(av)
bd0ffd
-    if not ctx:  # error, exit
bd0ffd
+    if not ctx.has_function():
bd0ffd
+        sys.stderr.write('No command specified; pass -h or --help for usage\n')
bd0ffd
         sys.exit(1)
bd0ffd
 
bd0ffd
     try: