Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: fix reload interface deletion #16723

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jklaiber
Copy link

@jklaiber jklaiber commented Sep 2, 2024

Current Behavior

  • When reloading the configuration in FRR, the frr-reload.py script does not allow removing an entire interface context in one step. Instead, it attempts to delete each configuration line individually under the interface context.
  • This line-by-line deletion can cause issues when the interface is already removed from the system.

Specific Issue:

  • If an interface has been removed from the system, trying to delete specific configurations (such as IP addresses) under that interface context fails.
  • For example, if an IP address was configured on an interface that no longer exists, trying to remove that IP address will result in an error because the interface itself is not present.

Impact of the Issue:

  • This behavior leads to errors during the configuration reload process, making it difficult to cleanly manage and synchronize the FRR configuration with the actual state of the network interfaces on the system.
  • Such errors can prevent successful application of configuration changes, disrupt network operations, and require manual intervention to resolve.

Example:
When the interface was removed from the frr.conf and then the reload script is executed the following error is triggered:

~$ frr-reload.py --reload --confdir frrouting/etc frrouting/etc/frr.conf --log-level warning
Failed to execute interface t4_1  no ip address 10.0.0.5 peer 10.0.0.6/32 exit
"interface t4_1 --  no ip address 10.0.0.5 peer 10.0.0.6/32 -- exit" we failed to remove this command

Proposed Solution

  • The proposed change allows the configuration to remove an interface using a single command (no interface <interface-name>).
    • The change affects only the whole removal of interfaces. If there are single lines removed under the interface context the script behaves like before.
  • This command effectively removes all configurations related to the interface in one step, bypassing the need to delete each line individually.

Advantages of the Solution:

  • By allowing the removal of the entire interface context, the solution makes the reloading process more straightforward and reduces the potential for errors.
  • When an interface is already deleted, removing its configuration with a single command avoids errors related to non-existent interface elements like IP addresses.

@frrbot frrbot bot added the tools label Sep 2, 2024
@jklaiber jklaiber changed the title Fix reload interface deletion tools: fix reload interface deletion Sep 2, 2024
@ton31337
Copy link
Member

ton31337 commented Sep 2, 2024

Could you please drop the merge commit?

@@ -1740,10 +1740,12 @@ def compare_context_objects(newconf, running):
delete_bgpd = True
lines_to_del.append((running_ctx_keys, None))

# We cannot do 'no interface' or 'no vrf' in FRR, and so deal with it
elif running_ctx_keys[0].startswith("interface"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If nothing is present under interface context, then it's not printed at all. I'm trying to understand what problem are we solving here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusion, I've updated the description I hope it's more clear now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please put the description into the commit message itself. No-one is going to look at the actual PR in a couple of years. They'll look at the commit via git show...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, shouldn't we check for len(running_ctx_keys) == 1 in this case too? It might be also interface blabla vrf ..., right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not make a difference in my opinion.
Because now it matches everything starting with interface which is under the "global" configuration context.

For example it will match:

interface foo

But it will also match:

interface foo vrf bar

But it will not match something like:

some context
    interface foo

@jklaiber jklaiber force-pushed the fix-reload-interface-deletion branch from 25c40ea to 8c23b84 Compare September 3, 2024 06:45
@jklaiber jklaiber requested a review from ton31337 September 3, 2024 07:32
@jklaiber jklaiber force-pushed the fix-reload-interface-deletion branch from 8c23b84 to 6c3b44a Compare September 3, 2024 11:40
@ton31337
Copy link
Member

ton31337 commented Sep 4, 2024

Could you show how it looks when doing --test --debug in your case?

@jklaiber
Copy link
Author

jklaiber commented Sep 4, 2024

Could you show how it looks when doing --test --debug in your case?

Sure here is the output of the lines that should be deleted before the change. The line with no IP address 10.0.0.5 peer 10.0.0.6/32 is especially important. Because when executing this line and the interface is already deleted frr will return an error.

Lines To Delete
===============
interface t4_1
 no ip address 10.0.0.5 peer 10.0.0.6/32
exit
interface t4_1
 no ip ospf area 0.0.0.0
exit
interface t4_1
 no ip ospf cost 190
exit
interface t4_1
 no ip ospf dead-interval 90
exit
interface t4_1
 no ip ospf hello-interval 15
exit
interface t4_1
 no ipv6 ospf6 area 0.0.0.0
exit
interface t4_1
 no ipv6 ospf6 passive
exit

And here it is with the change:

Lines To Delete
===============
no interface t4_1

You see before it was removing line by line under interface context. Now it just deletes the interface as a whole which allows deleting the interface out of frr even if the interface is already deleted on the system.

@jklaiber
Copy link
Author

jklaiber commented Sep 4, 2024

Closes #15081

@ton31337
Copy link
Member

ton31337 commented Sep 5, 2024

Could you fix the styling?

The frr-reload script currently deletes configurations
line-by-line under an interface context, if the interface was removed.
This approach fails when the interface has already been removed from the system.

This change enables whole interface removal using a single command
(no interface <interface-name>), simplifying the reload process and
reducing reload errors.

Signed-off-by: Julian Klaiber <[email protected]>
@jklaiber jklaiber force-pushed the fix-reload-interface-deletion branch from 6c3b44a to 0513050 Compare September 5, 2024 12:18
@github-actions github-actions bot added size/S and removed size/XS labels Sep 5, 2024
@jklaiber
Copy link
Author

@ton31337 any updates on this PR? Please let me know if you need some changes or information from me.

@ton31337
Copy link
Member

@donaldsharp any objections here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants