From 836aecfbd3e4df2a886b5d58154bfbfbcf1dd098 Mon Sep 17 00:00:00 2001 From: Brad House Date: Mon, 3 Nov 2025 12:05:17 -0500 Subject: [PATCH] Python exception processing static routes static routes that don't reference a private gateway don't have an ip_address and therefore will throw a key error: ``` root@r-359-VM:/var/cache/cloud# update_config.py ip_associations.json.7407b8bd-21c6-4d99-aae0-f2193412650c Traceback (most recent call last): File "/opt/cloud/bin/update_config.py", line 147, in process_file() File "/opt/cloud/bin/update_config.py", line 57, in process_file finish_config() File "/opt/cloud/bin/update_config.py", line 42, in finish_config returncode = configure.main(sys.argv) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/cloud/bin/configure.py", line 1647, in main config.address().process() File "/opt/cloud/bin/cs/CsAddress.py", line 138, in process ip.configure(address) File "/opt/cloud/bin/cs/CsAddress.py", line 348, in configure self.post_configure(address) File "/opt/cloud/bin/cs/CsAddress.py", line 370, in post_configure self.post_config_change("add") File "/opt/cloud/bin/cs/CsAddress.py", line 824, in post_config_change self.fw_vpcrouter() File "/opt/cloud/bin/cs/CsAddress.py", line 606, in fw_vpcrouter if static_route['ip_address'] == self.address['public_ip'] and not static_route['revoke']: ~~~~~~~~~~~~^^^^^^^^^^^^^^ KeyError: 'ip_address' ``` Example static routes: ``` root@r-359-VM:/var/cache/cloud# cat /etc/cloudstack/staticroutes.json { "10.10.48.0/20": { "gateway": "10.252.240.10", "network": "10.10.48.0/20", "revoke": false }, "10.250.0.0/16": { "gateway": "10.252.240.10", "network": "10.250.0.0/16", "revoke": false }, "id": "staticroutes" } ``` --- systemvm/debian/opt/cloud/bin/cs/CsAddress.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemvm/debian/opt/cloud/bin/cs/CsAddress.py b/systemvm/debian/opt/cloud/bin/cs/CsAddress.py index 3b4ad3d74723..c7dac4df47ea 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsAddress.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsAddress.py @@ -603,7 +603,7 @@ def fw_vpcrouter(self): if item == "id": continue static_route = static_routes.get_bag()[item] - if static_route['ip_address'] == self.address['public_ip'] and not static_route['revoke']: + if 'ip_address' in static_route and static_route['ip_address'] == self.address['public_ip'] and not static_route['revoke']: self.fw.append(["mangle", "", "-A PREROUTING -m state --state NEW -i %s -s %s ! -d %s/32 -j ACL_OUTBOUND_%s" % (self.dev, static_route['network'], static_route['ip_address'], self.dev)])