-
Notifications
You must be signed in to change notification settings - Fork 373
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
Add "antctl get bgppeers" agent command #6689
Conversation
c6670c5
to
a965cc5
Compare
if c.bgpPolicyState == nil { | ||
return nil, fmt.Errorf("failed to get bgp peers: there is no effective bgp policy applied to the Node") | ||
} | ||
peers, err := c.bgpPolicyState.bgpServer.GetPeers(context.TODO()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
holding a read lock while calling this function may be bit overkill. In the case of gobgp at least, all these operations are asynchronous (so there can be some delay, hence the context parameter) and all the server functions can be called concurrently as far as I know.
so the following would probably be correct:
getBgpServer := func() bgp.Interface {
c.bgpPolicyStateMutex.RLock()
defer c.bgpPolicyStateMutex.RUnlock()
if c.bgpPolicyState == nil {
return nil
}
return c.bgpPolicyState.bgpServer
}
bgpServer := getBgpServer()
if bgpServer == nil {
// return error
}
peers, err := bgpServer.GetPeers(ctx)
This way we don't hold the read lock for a potentially expensive async operation.
That means that we have to guarantee that all bgp.Interface
implementations (at the moment we only have gobgp) support concurrent function calls. Probably worth double checking that this assumption holds for gobgp, but it seems to me that all API calls get serialized to a channel.
a965cc5
to
56c2249
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a couple of nit comments, otherwise lgtm
Signed-off-by: Kumar Atish <kumar.atish@broadcom.com>
56c2249
to
7d1f69c
Compare
Can one of the admins verify this patch? |
5 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for making the requested changes
/test-all |
/test-conformance |
/test-kind-conformance |
Add `antctl get bgppeers` agent command to to print current status of all BGP peers of effective BGP policy applied on the local Node. The command is implemented using a new HTTP endpoint (`/bgppeers`), which will return a `404 Not Found` error if no BGPPolicy has been applied on the Node. Signed-off-by: Kumar Atish <kumar.atish@broadcom.com>
Add
antctl get bgppeers
agent command to print current status of all BGP peersof effective BGP policy applied on the local Node.
For #6209