Skip to content

Add "antctl get bgproutes" agent command#6734

Merged
antoninbas merged 1 commit into
antrea-io:mainfrom
Atish-iaf:antctl-get-bgproutes
Oct 23, 2024
Merged

Add "antctl get bgproutes" agent command#6734
antoninbas merged 1 commit into
antrea-io:mainfrom
Atish-iaf:antctl-get-bgproutes

Conversation

@Atish-iaf
Copy link
Copy Markdown
Contributor

@Atish-iaf Atish-iaf commented Oct 11, 2024

Add antctl get bgproutes agent command to print the advertised BGP routes on the local Node.

The command is implemented using a new HTTP endpoint (/bgproutes), which will return a 404 Not Found error if no BGPPolicy has been applied on the Node.

For #6209

@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 Oct 11, 2024
@Atish-iaf Atish-iaf mentioned this pull request Oct 11, 2024
4 tasks
@Atish-iaf Atish-iaf marked this pull request as ready for review October 11, 2024 09:55
@Atish-iaf Atish-iaf marked this pull request as draft October 11, 2024 10:37
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch from 63b5cb3 to d2d575c Compare October 11, 2024 11:02
@Atish-iaf Atish-iaf marked this pull request as ready for review October 11, 2024 11:06
Copy link
Copy Markdown
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.

Not done reviewing it yet, but at a high-level I do not think we should be handling "received routes" at the moment. Unless I am mistaken, this is not a concept which is really relevant to the (current) Antrea BGP implementation.

Comment thread docs/antctl.md Outdated
Comment on lines +793 to +794
# Get the list of all received bgp routes
$ antctl get bgproutes --in
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we do not handle "received routes" in the Antrea BGP implementation, so I think this may be misleading to users
cc @hongliangl

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we do not handle "received routes" in the Antrea BGP implementation

Exactly. At least right now, we don't care about the "received routes" from remote peers. In current implementation of BGPPolicy controller, we only advertise routes, for the "received routes", we do nothing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@hongliangl
To track, better to create a separate issue to support received routes for future use-case , as received routes can be important for scenarios involving multiple BGP peers, dynamic route management, or multi-cluster setups,
as of now for basic CNI and Kubernetes networking, the focus is primarily on what the cluster advertises !

Comment thread pkg/agent/apiserver/handlers/bgproute/handler.go Outdated
Comment thread docs/antctl.md Outdated
Comment on lines +793 to +794
# Get the list of all received bgp routes
$ antctl get bgproutes --in
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we do not handle "received routes" in the Antrea BGP implementation

Exactly. At least right now, we don't care about the "received routes" from remote peers. In current implementation of BGPPolicy controller, we only advertise routes, for the "received routes", we do nothing.

Comment thread pkg/agent/controller/bgp/controller.go Outdated
Comment thread pkg/agent/controller/bgp/controller.go Outdated
Comment thread pkg/agent/controller/bgp/controller.go Outdated
Comment thread pkg/agent/controller/bgp/controller_test.go Outdated
Comment thread pkg/agent/controller/bgp/controller_test.go
Comment thread pkg/agent/controller/bgp/controller_test.go Outdated
@luolanzone luolanzone added the action/release-note Indicates a PR that should be included in release notes. label Oct 12, 2024
Comment thread pkg/agent/apiserver/handlers/bgproute/handler.go Outdated
Comment thread pkg/agent/apiserver/handlers/bgproute/handler.go
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch from d2d575c to 6b5c93d Compare October 15, 2024 09:21
@Atish-iaf Atish-iaf added this to the Antrea v2.2 release milestone Oct 15, 2024
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch 2 times, most recently from 84cd772 to 345ee83 Compare October 15, 2024 09:55
Comment thread pkg/agent/controller/bgp/controller.go Outdated
Comment thread docs/antctl.md
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch from 345ee83 to 15d64cb Compare October 16, 2024 07:11
@Atish-iaf Atish-iaf requested a review from antoninbas October 16, 2024 08:47
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch 3 times, most recently from f38c39d to 2aea77b Compare October 17, 2024 05:33
@Atish-iaf
Copy link
Copy Markdown
Contributor Author

/test-all

Comment thread docs/antctl.md Outdated
Comment thread pkg/agent/controller/bgp/controller.go Outdated
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch from 2aea77b to 671bba8 Compare October 17, 2024 09:06
Comment thread docs/antctl.md Outdated
Comment thread pkg/agent/controller/bgp/controller.go Outdated
Comment thread pkg/querier/querier.go Outdated
Comment thread pkg/agent/controller/bgp/controller.go
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch from 671bba8 to 2f06d8d Compare October 18, 2024 01:41
@Atish-iaf Atish-iaf requested a review from antoninbas October 18, 2024 01:46
Comment thread docs/antctl.md Outdated
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch from 2f06d8d to ccc048d Compare October 18, 2024 05:42
Copy link
Copy Markdown
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.

only a handful of nits, otherwise LGTM

Comment thread pkg/agent/apiserver/handlers/bgproute/handler.go Outdated
Comment thread pkg/agent/apiserver/handlers/bgproute/handler_test.go
Comment thread pkg/agent/controller/bgp/controller.go Outdated
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch 2 times, most recently from 996bfa1 to 633f3bf Compare October 19, 2024 03:42
@Atish-iaf Atish-iaf requested a review from antoninbas October 19, 2024 03:51
@rajnkamr rajnkamr added the kind/documentation Categorizes issue or PR as related to a documentation. label Oct 21, 2024
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch from 633f3bf to 6f72e75 Compare October 21, 2024 07:35
@Atish-iaf Atish-iaf removed the kind/documentation Categorizes issue or PR as related to a documentation. label Oct 21, 2024
Comment thread pkg/agent/apiserver/handlers/bgproute/handler.go Outdated
Comment thread pkg/antctl/antctl.go Outdated
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch from 6f72e75 to b289d98 Compare October 21, 2024 22:15
Comment thread pkg/agent/apiserver/handlers/bgproute/handler_test.go Outdated
Comment thread pkg/agent/apiserver/handlers/bgproute/handler_test.go Outdated
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch from b289d98 to 61be307 Compare October 21, 2024 22:38
Copy link
Copy Markdown
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.

one last comment, otherwise lgtm

Comment on lines +39 to +58
var ipv4Routes, ipv6Routes = false, false
rawQuery := r.URL.RawQuery
switch rawQuery {
case "ipv4-only=":
ipv4Routes = true
case "ipv6-only=":
ipv6Routes = true
case "":
ipv4Routes = true
ipv6Routes = true
default:
http.Error(w, "invalid query", http.StatusBadRequest)
return
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's use this variation:

		values := r.URL.Query()
		var ipv4Only, ipv6Only bool
		if values.Has("ipv4-only") {
				if values.Get("ipv4-only") != "" {
						// bad request
				}
				ipv4Only = true
		}
		if values.Has("ipv6-only") {
				if values.Get("ipv6-only") != "" {
						// bad request
				}
				ipv6Only = true
		}
		if ipv4Only && ipv6Only {
				// bad request
		}
		// ...
		bgpRoutes, err := bq.GetBGPRoutes(r.Context(), !ipv6Only, !ipv4Only)

I feel like the current validation is a bit too restrictive / low-level. We should accept both ipv4-only= and ipv4-only for example.

@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch from 61be307 to 9a0f84e Compare October 22, 2024 06:25
@Atish-iaf Atish-iaf requested a review from antoninbas October 22, 2024 06:38
@Atish-iaf
Copy link
Copy Markdown
Contributor Author

/test-all

Comment thread pkg/agent/apiserver/handlers/bgproute/handler.go Outdated
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch from 9a0f84e to 446a7e2 Compare October 22, 2024 16:59
Add `antctl get bgproutes` agent command to print the advertised BGP routes.

The command is implemented using a new HTTP endpoint (`/bgproutes`),
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>
@Atish-iaf Atish-iaf force-pushed the antctl-get-bgproutes branch from 446a7e2 to 93df0aa Compare October 22, 2024 17:42
@antoninbas
Copy link
Copy Markdown
Contributor

/test-all

@XinShuYang
Copy link
Copy Markdown
Contributor

/test-e2e
/test-conformance

@XinShuYang
Copy link
Copy Markdown
Contributor

/test-conformance

@XinShuYang
Copy link
Copy Markdown
Contributor

/test-all-features-conformance

@antoninbas antoninbas merged commit aeb03b0 into antrea-io:main Oct 23, 2024
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants