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

Add "antctl get bgppeers" agent command #6689

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

Atish-iaf
Copy link
Contributor

Add antctl get bgppeers agent command to print current status of all BGP peers
of effective BGP policy applied on the local Node.

For #6209

@Atish-iaf Atish-iaf marked this pull request as ready for review September 24, 2024 09:46
@Atish-iaf Atish-iaf added area/component/antctl Issues or PRs releated to the command line interface component area/transit/bgp Issues or PRs related to BGP support. labels Sep 24, 2024
@Atish-iaf Atish-iaf mentioned this pull request Sep 24, 2024
4 tasks
pkg/agent/apiserver/handlers/bgppeer/handler.go Outdated Show resolved Hide resolved
pkg/agent/apiserver/handlers/bgppeer/handler.go Outdated Show resolved Hide resolved
pkg/agent/controller/bgp/controller.go Outdated Show resolved Hide resolved
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())
Copy link
Contributor

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.

@rajnkamr rajnkamr added this to the Antrea v2.2 release milestone Sep 25, 2024
@rajnkamr rajnkamr added the kind/documentation Categorizes issue or PR as related to a documentation. label Sep 25, 2024
@luolanzone luolanzone added the action/release-note Indicates a PR that should be included in release notes. label Sep 25, 2024
@Atish-iaf Atish-iaf removed the kind/documentation Categorizes issue or PR as related to a documentation. label Sep 25, 2024
Copy link
Contributor

@antoninbas antoninbas left a 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

pkg/agent/apiserver/handlers/bgppeer/handler.go Outdated Show resolved Hide resolved
pkg/agent/controller/bgp/controller_test.go Outdated Show resolved Hide resolved
pkg/agent/controller/bgp/controller_test.go Show resolved Hide resolved
pkg/agent/apiserver/handlers/bgppeer/handler.go Outdated Show resolved Hide resolved
pkg/agent/controller/bgp/controller_test.go Outdated Show resolved Hide resolved
Signed-off-by: Kumar Atish <kumar.atish@broadcom.com>
@antrea-bot
Copy link
Collaborator

Can one of the admins verify this patch?

5 similar comments
@antrea-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@antrea-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@antrea-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@antrea-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@antrea-bot
Copy link
Collaborator

Can one of the admins verify this patch?

Copy link
Contributor

@antoninbas antoninbas left a 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

@antoninbas
Copy link
Contributor

/test-all

@Atish-iaf
Copy link
Contributor Author

/test-conformance

@Atish-iaf
Copy link
Contributor Author

/test-kind-conformance

@antoninbas antoninbas merged commit 761104a into antrea-io:main Oct 4, 2024
53 of 59 checks passed
@rajnkamr rajnkamr added the kind/documentation Categorizes issue or PR as related to a documentation. label Oct 21, 2024
hangyan pushed a commit to hangyan/antrea that referenced this pull request Oct 29, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/release-note Indicates a PR that should be included in release notes. area/component/antctl Issues or PRs releated to the command line interface component area/transit/bgp Issues or PRs related to BGP support. kind/documentation Categorizes issue or PR as related to a documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants