]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add log warn when unable to infer mon ip addr
authorMichael Fritch <mfritch@suse.com>
Fri, 11 Jun 2021 03:22:56 +0000 (21:22 -0600)
committerSebastian Wagner <sewagner@redhat.com>
Thu, 17 Jun 2021 08:47:02 +0000 (10:47 +0200)
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>
(cherry picked from commit ae7271d47da01dfeb90ed643da2cba91fc8fa2ce)

src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py

index 1dfbd39cf9b0d3321bc5bf8299a78c9997901078..c6f1efc4a32ebffe1415e3e96bf0b5e684bc6cd4 100755 (executable)
@@ -3477,19 +3477,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 c3ba3bed246e3b168e46afcb10602c5fed29867c..e9aece8b2282fe4e20d212af74b57678aa992c7d 100644 (file)
@@ -1045,7 +1045,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)
 
@@ -1112,8 +1112,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: