Add ability to update BGPSession status
Closed this issue · 2 comments
After initially creating a BGP session, its status may/will likely show as down. Until you hit the discover endpoint (/devices/<uuid>/bgp/discover
) or wait for the auto-update interval to pass ( 6 hours or so), the status doesn't appear to get updated automatically to reflect that actual state of the session.
It would be nice have something like a .GetStatus(), .Discover() function that allowed for triggering this update. Even if this functionality just got wrapped up into a Get() or List() function this would be helpful. The other behavior I've noticed here is that if you're polling for the state of the session (i.e. waiting for the BGPSession to be up), it doesn't necessarily represent the latest state. Some behavior I've seen looks something like:
- Create BGPSession
- See state is down
- Hit Discover Endpoint
- Session still reports down, start polling for state every 30 seconds
- BGP seems fine and established while checking on actual servers, but polling still shows state as down
- ~5 minutes pass and then status is reflected as up.
This is a feature of the API utilized by console.equinix.com.
POST /projects/{ID}/bgp/discover
(no body)
The response looks like:
{"updated_at":"2022-02-02T19:01:03.943Z"}
This endpoint is not included in the documented spec.
Seeing the state of the BGP service is something that must be aggregated from the session status today: client.BGPSessions.Get($device_id)
.
One would check all sessions for Status "up" or "up,up". This requires iterating all device ids in the BGP configuration.
As pointed out in the description, a List()
function can be implemented. Today the Get()
method requires an ID, but by not providing an ID in the request, a list would be returned. The console uses the following request: /projects/{id}/bgp/sessions?include=device&exclude=
The format of the response is {"bgp_sessions":[...]}
where each item in the array matches the BGPSession
type in packngo today. Packngo does not account for the CreatedAt and UpdatedAt fields present in the API response: created_at: "2022-01-26T21:10:23Z"
(and updated_at
with the same format).