Skip to content

Commit 836aecf

Browse files
committed
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 <module> 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" } ```
1 parent 2dbc86a commit 836aecf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

systemvm/debian/opt/cloud/bin/cs/CsAddress.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ def fw_vpcrouter(self):
603603
if item == "id":
604604
continue
605605
static_route = static_routes.get_bag()[item]
606-
if static_route['ip_address'] == self.address['public_ip'] and not static_route['revoke']:
606+
if 'ip_address' in static_route and static_route['ip_address'] == self.address['public_ip'] and not static_route['revoke']:
607607
self.fw.append(["mangle", "",
608608
"-A PREROUTING -m state --state NEW -i %s -s %s ! -d %s/32 -j ACL_OUTBOUND_%s" %
609609
(self.dev, static_route['network'], static_route['ip_address'], self.dev)])

0 commit comments

Comments
 (0)