diff --git a/compose/network.py b/compose/network.py index 4aeff2d1e..ea6f49631 100644 --- a/compose/network.py +++ b/compose/network.py @@ -158,8 +158,8 @@ def check_remote_ipam_config(remote, local): if sorted(lc.get('AuxiliaryAddresses')) != sorted(rc.get('AuxiliaryAddresses')): raise NetworkConfigChangedError(local.full_name, 'IPAM config aux_addresses') - remote_opts = remote_ipam.get('Options', {}) - local_opts = local.ipam.get('options', {}) + remote_opts = remote_ipam.get('Options') or {} + local_opts = local.ipam.get('options') or {} for k in set.union(set(remote_opts.keys()), set(local_opts.keys())): if remote_opts.get(k) != local_opts.get(k): raise NetworkConfigChangedError(local.full_name, 'IPAM option "{}"'.format(k)) diff --git a/tests/unit/network_test.py b/tests/unit/network_test.py index a325f1948..d1cf2ccf9 100644 --- a/tests/unit/network_test.py +++ b/tests/unit/network_test.py @@ -100,6 +100,44 @@ class NetworkTest(unittest.TestCase): {'Driver': 'overlay', 'Options': None}, net ) + def test_check_remote_network_config_null_remote_ipam_options(self): + ipam_config = { + 'driver': 'default', + 'config': [ + {'subnet': '172.0.0.1/16', }, + { + 'subnet': '156.0.0.1/25', + 'gateway': '156.0.0.1', + 'aux_addresses': ['11.0.0.1', '24.25.26.27'], + 'ip_range': '156.0.0.1-254' + } + ] + } + net = Network( + None, 'compose_test', 'net1', 'bridge', ipam=ipam_config, + ) + + check_remote_network_config( + { + 'Driver': 'bridge', + 'Attachable': True, + 'IPAM': { + 'Driver': 'default', + 'Config': [{ + 'Subnet': '156.0.0.1/25', + 'Gateway': '156.0.0.1', + 'AuxiliaryAddresses': ['24.25.26.27', '11.0.0.1'], + 'IPRange': '156.0.0.1-254' + }, { + 'Subnet': '172.0.0.1/16', + 'Gateway': '172.0.0.1' + }], + 'Options': None + }, + }, + net + ) + def test_check_remote_network_labels_mismatch(self): net = Network(None, 'compose_test', 'net1', 'overlay', labels={ 'com.project.touhou.character': 'sakuya.izayoi'