bhouse-nexthop commented on code in PR #12859:
URL: https://github.com/apache/cloudstack/pull/12859#discussion_r3086358024
##########
systemvm/debian/opt/cloud/bin/cs/CsStaticRoutes.py:
##########
@@ -31,13 +32,46 @@ def process(self):
continue
self.__update(self.dbag[item])
+
+
def __update(self, route):
+ network = route['network']
+ gateway = route['gateway']
+
if route['revoke']:
- command = "ip route del %s via %s" % (route['network'],
route['gateway'])
+ # Delete from main table
+ command = "ip route del %s via %s" % (network, gateway)
CsHelper.execute(command)
+
+ # Delete from PBR table if applicable
+ device = CsHelper.find_device_for_gateway(self.config, gateway)
+ if device:
+ cs_route = CsRoute()
+ table_name = cs_route.get_tablename(device)
+ command = "ip route del %s via %s table %s" % (network,
gateway, table_name)
+ CsHelper.execute(command)
+ logging.info("Deleted static route %s via %s from PBR table
%s" % (network, gateway, table_name))
else:
- command = "ip route show | grep %s | awk '{print $1, $3}'" %
route['network']
+ # Add to main table (existing logic)
+ command = "ip route show | grep %s | awk '{print $1, $3}'" %
network
result = CsHelper.execute(command)
if not result:
- route_command = "ip route add %s via %s" % (route['network'],
route['gateway'])
+ route_command = "ip route add %s via %s" % (network, gateway)
CsHelper.execute(route_command)
+ logging.info("Added static route %s via %s to main table" %
(network, gateway))
+
+ # Add to PBR table if applicable
+ device = CsHelper.find_device_for_gateway(self.config, gateway)
+ if device:
+ cs_route = CsRoute()
+ table_name = cs_route.get_tablename(device)
+ # Check if route already exists in the PBR table
+ check_command = "ip route show table %s | grep %s | awk
'{print $1, $3}'" % (table_name, network)
Review Comment:
I'll opt not to fix the the mentioned possible issue as the audit of the
code has raise that same pattern elsewhere so fixing it in this one location
won't solve the overall issue. Plus it would require more testing. The
current patch with no changes I've been running in production since this PR was
filed without issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]