]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add log warn when unable to infer mon ip addr 41820/head
authorMichael Fritch <mfritch@suse.com>
Fri, 11 Jun 2021 03:22:56 +0000 (21:22 -0600)
committerMichael Fritch <mfritch@suse.com>
Sun, 13 Jun 2021 22:30:39 +0000 (16:30 -0600)
fixup for `--mon-ip` bootstrap test (introduced b3e2c43):
  ValueError: 'eth0' does not appear to be an IPv4 or IPv6 address

Signed-off-by: Michael Fritch <mfritch@suse.com>
src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py

index 26fd130dce25441f8a0c57b91c0dd328d3e8e746..597483bc94bf4857af4db69b1934fdb2d243e179 100755 (executable)
@@ -3501,19 +3501,21 @@ def prepare_mon_addresses(
     if not ctx.skip_mon_network:
         # make sure IP is configured locally, and then figure out the
         # CIDR network
+        errmsg = f'Cannot infer CIDR network for mon IP `{base_ip}`'
         for net, ifaces in list_networks(ctx).items():
             ips: List[str] = []
             for iface, ls in ifaces.items():
                 ips.extend(ls)
-            if ipaddress.ip_address(unwrap_ipv6(base_ip)) in \
-                    [ipaddress.ip_address(ip) for ip in ips]:
-                mon_network = net
-                logger.info('Mon IP %s is in CIDR network %s' % (base_ip,
-                                                                 mon_network))
-                break
+            try:
+                if ipaddress.ip_address(unwrap_ipv6(base_ip)) in \
+                        [ipaddress.ip_address(ip) for ip in ips]:
+                    mon_network = net
+                    logger.info(f'Mon IP `{base_ip}` is in CIDR network `{mon_network}`')
+                    break
+            except ValueError as e:
+                logger.warning(f'{errmsg}: {e}')
         if not mon_network:
-            raise Error('Failed to infer CIDR network for mon ip %s; pass '
-                        '--skip-mon-network to configure it later' % base_ip)
+            raise Error(f'{errmsg}: pass --skip-mon-network to configure it later')
 
     return (addr_arg, ipv6, mon_network)
 
index 0dc33aa7b992fccea7e363c465b928b4591ffea0..7fcde238fd382dbf5a2adbe255939cc2cda3989e 100644 (file)
@@ -1065,7 +1065,7 @@ class TestBootstrap(object):
         cmd = self._get_cmd('--mon-ip', '192.168.1.1')
 
         with with_cephadm_ctx(cmd, list_networks={}) as ctx:
-            msg = r'Failed to infer CIDR network'
+            msg = r'--skip-mon-network'
             with pytest.raises(cd.Error, match=msg):
                 cd.command_bootstrap(ctx)
 
@@ -1132,8 +1132,8 @@ class TestBootstrap(object):
     def test_mon_ip(self, mon_ip, list_networks, result, cephadm_fs):
         cmd = self._get_cmd('--mon-ip', mon_ip)
         if not result:
-            with with_cephadm_ctx(cmd, list_networks={}) as ctx:
-                msg = r'Failed to infer CIDR network'
+            with with_cephadm_ctx(cmd, list_networks=list_networks) as ctx:
+                msg = r'--skip-mon-network'
                 with pytest.raises(cd.Error, match=msg):
                     cd.command_bootstrap(ctx)
         else: