fix(junos): trying to clean route-map still being used #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
AFK autogenerates policies per relevant SAFIs. A SAFI is relevant only if at least one BGP session uses in this SAFI.
Before this PR, we were always deleting autogenerated policies for all SAFIs, including non relevant SAFIs..
The purpose of the deletion is to start from a clean slate when recreating a policy (to avoid extra terms/options in the policy).
note: the goal is not to remove extra policies, which must be done in a dedicated step.
The issue is that we push routing_policy update before BGP. The result is that if the BGP session disappears from openconfig, the SAFI becomes relevant and by side effect was removed (as we delete for all SAFIs), while the BGP session was not yet removed from the config yet, resulting in configuration failure.
We should never remove a policy which is still in use (this is why the cleaning must be done in a dedicated step).
In this context, we now only delete policies we still maintain (so which will be recreated right after the deletion).