Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix RemoveSubnetRoute: Always take subnet route as dictionary
RemoveSubnetRoute needs the subnet route as a dictionary (so that revert can work), but it was supplied as a name. Fix RemoveSubnetRoute to take a dictionary and fix usages of RemoveSubnetRoute accordingly. More details: GetExistingSubnetRoutesForNetwork retrieves the existing subnet routes, returning them as list of dictionaries, taken from the device response. This list is passed to the RemoveSubnetRoute task for it to be able to correctly rollback. RemoveSubnetRoute is called in two places - make_remove_selfips_and_subnet_routes_flow (for removing UNNEEDED subnet routes) and make_remove_l2_flow (for removing ALL subnet routes). The make_remove_l2_flow function passes the above-mentioned list of existing subnet routes to RemoveSubnetRoute verbatim, but make_remove_selfips_and_subnet_routes_flow erroneously extracts the names first (via a list comprehension: [r['name'] for r in existing_subnet_routes ...]). - This bug was introduced in 7c0153e (which added GetExistingSubnetRoutesForNetwork). - In 4f78720 I had found the erroneous call in make_remove_selfips_and_subnet_routes_flow and adjusted the RemoveSubnetRoute task to take a name instead of a dictionary, but did not adjust the usage in make_remove_l2_flow, thus "inverting" the bug. Also, I forgot to adjust the RemoveSubnetRoute.revert method, meaning that the execute method now worked with the call in make_remove_selfips_and_subnet_routes_flow but not make_remove_l2_flow, and the other way round for the revert method. - In b16dbc8 I adjusted the RemoveSubnetRoute.revert method as well. Now both the execute and the revert methods work with the call in make_remove_selfips_and_subnet_routes_flow but not make_remove_l2_flow. This commit fixes this error. - Adjust RemoveSubnetRoute.execute and RemoveSubnetRoute.revert to take a subnet route instead of just its name. This makes calling the task easier, since we can fix the erroneous list comprehension (see above). It also makes rollback easier because the revert method now has all the info it needs and doesn't need to infer anything anymore. - make_remove_l2_flow: Supply subnet_route instead of subnet_route_name - make_remove_selfips_and_subnet_routes_flow: Supply subnet_route instead of subnet_route_name and - most importantly - fix list comprehension (to not extract the name). - test_revert_RemoveSubnetRoute: Supply subnet_route instead of subnet_route_name and check that during rollback the subnet route is recreated with its original attributes.
- Loading branch information