Skip to content

bgp: remember to delete router from db #516

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

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

Conversation

taspelund
Copy link
Contributor

When the delete_router API endpoint was called, the router was not fully being deleted. "mgadm bgp config router list" would still display a router despite returning a 204 No Content indicating the operation was successful:

[trey@zebes:~/git/maghemite on main]
% ./target/debug/mgadm bgp config router list
[
    Router {
        asn: 1,
        graceful_shutdown: false,
        id: 1,
        listen: "[::]:179",
    },
]
[trey@zebes:~/git/maghemite on main]
% ./target/debug/mgadm bgp config router delete 1
[trey@zebes:~/git/maghemite on main]
% ./target/debug/mgadm bgp config router list
[
    Router {
        asn: 1,
        graceful_shutdown: false,
        id: 1,
        listen: "[::]:179",
    },
]

This is because the API handler would remove the router from the BgpContext struct, but not from the persistent sled db.

This change ensures the router is removed from the sled db, not just the in-memory BgpContext data structure. Now the router gets deleted from the sled db, and mgadm properly reflects the running state:

[trey@zebes:~/git/maghemite on trey/fix_router_del]
% ./target/debug/mgadm bgp config router list
[
    Router {
        asn: 1,
        graceful_shutdown: false,
        id: 1,
        listen: "[::]:179",
    },
]
[trey@zebes:~/git/maghemite on trey/fix_router_del]
% ./target/debug/mgadm bgp config router delete 1
[trey@zebes:~/git/maghemite on trey/fix_router_del]
% ./target/debug/mgadm bgp config router list
[]

When the delete_router API endpoint was called, the router was not fully
being deleted. "mgadm bgp config router list" would still display a
router despite returning a 204 No Content indicating the operation was
successful:
```
[trey@zebes:~/git/maghemite on main]
% ./target/debug/mgadm bgp config router list
[
    Router {
        asn: 1,
        graceful_shutdown: false,
        id: 1,
        listen: "[::]:179",
    },
]
[trey@zebes:~/git/maghemite on main]
% ./target/debug/mgadm bgp config router delete 1
[trey@zebes:~/git/maghemite on main]
% ./target/debug/mgadm bgp config router list
[
    Router {
        asn: 1,
        graceful_shutdown: false,
        id: 1,
        listen: "[::]:179",
    },
]
```
This is because the API handler would remove the router from the
BgpContext struct, but not from the persistent sled db.

This change ensures the router is removed from the sled db, not just the
in-memory BgpContext data structure. Now the router gets deleted from
the sled db, and mgadm properly reflects the running state:
```
[trey@zebes:~/git/maghemite on trey/fix_router_del]
% ./target/debug/mgadm bgp config router list
[
    Router {
        asn: 1,
        graceful_shutdown: false,
        id: 1,
        listen: "[::]:179",
    },
]
[trey@zebes:~/git/maghemite on trey/fix_router_del]
% ./target/debug/mgadm bgp config router delete 1
[trey@zebes:~/git/maghemite on trey/fix_router_del]
% ./target/debug/mgadm bgp config router list
[]
```

Signed-off-by: Trey Aspelund <[email protected]>
@taspelund taspelund requested a review from rcgoodfellow June 29, 2025 08:15
@taspelund taspelund self-assigned this Jun 29, 2025
@taspelund taspelund added Bug bgp Border Gateway Protocol labels Jun 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bgp Border Gateway Protocol Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants