Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
antoninbas committed Oct 30, 2020
1 parent 023ea20 commit ec4a75c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
15 changes: 10 additions & 5 deletions docs/antctl.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,7 @@ results:

Antctl can run as a reverse proxy for the Antrea API (Controller or arbitrary
Agent). Usage is very similar to `kubectl proxy` and the implementation is
essentially the same. One thing to keep in mind is that the TLS connection
between the proxy and the Antrea Agent or Controller will not be secure (no
certificate verification), and the proxy should be used for debugging only.
essentially the same.

To run a reverse proxy for the Antrea Controller API, use:

Expand All @@ -408,8 +406,15 @@ on Node <TARGET_NODE>, use:
$ antctl proxy --agent-node
```

You can then access the API at `127.0.0.1:8001`. To see the full list of
supported options, run `antctl proxy --help`.
You can then access the API at `127.0.0.1:8001`. To implement this
functionality, antctl retrieves the Node IP address and API server port for the
Antrea Controller or for the specified Agent from the K8s API, and it proxies
all the requests received on `127.0.0.1:8001` directly to that IP / port. One
thing to keep in mind is that the TLS connection between the proxy and the
Antrea Agent or Controller will not be secure (no certificate verification), and
the proxy should be used for debugging only.

To see the full list of supported options, run `antctl proxy --help`.

This feature is useful if one wants to use the Go
[pprof](https://golang.org/pkg/net/http/pprof/) tool to collect runtime
Expand Down
7 changes: 3 additions & 4 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,9 @@ commands.

The easiest way to profile the Antrea components is to use the Go
[pprof](https://golang.org/pkg/net/http/pprof/) tool. Both the Antrea Agent and
the Antrea Controller use the k8s apiserver library to server their API, and
this library enables the pprof HTTP server by default. In order to access it
without having to worry about authentication, you can use the antctl proxy
function.
the Antrea Controller use the K8s apiserver library to serve their API, and this
library enables the pprof HTTP server by default. In order to access it without
having to worry about authentication, you can use the antctl proxy function.

For example, this is what you would do to look at a 30-second CPU profile for
the Antrea Controller:
Expand Down
20 changes: 12 additions & 8 deletions pkg/antctl/command_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func (cl *commandList) ApplyToRootCommand(root *cobra.Command) {
for _, groupCommand := range groupCommands {
root.AddCommand(groupCommand)
}
for i := range cl.definitions {
def := cl.definitions[i]
for i, _ := range cl.definitions {
def := &cl.definitions[i]
if (runtime.Mode == runtime.ModeAgent && def.agentEndpoint == nil) ||
(runtime.Mode == runtime.ModeController && def.controllerEndpoint == nil) {
continue
Expand Down Expand Up @@ -106,8 +106,7 @@ func (cl *commandList) validate() []error {
// are used for debugging purpose.
func (cl *commandList) GetDebugCommands(mode string) [][]string {
var allCommands [][]string
for i := range cl.definitions {
def := cl.definitions[i]
for _, def := range cl.definitions {
// TODO: incorporate query commands into e2e testing once proxy access is implemented
if def.commandGroup == query {
continue
Expand All @@ -126,10 +125,15 @@ func (cl *commandList) GetDebugCommands(mode string) [][]string {
allCommands = append(allCommands, currentCommand)
}
}
for i := range cl.rawCommands {
if mode == runtime.ModeController && cl.rawCommands[i].supportController ||
mode == runtime.ModeAgent && cl.rawCommands[i].supportAgent {
allCommands = append(allCommands, strings.Split(cl.rawCommands[i].cobraCommand.Use, " ")[:1])
for _, cmd := range cl.rawCommands {
if cmd.cobraCommand.Use == "proxy" {
// proxy will keep running until interrupted so it
// cannot be used as is in e2e tests.
continue
}
if mode == runtime.ModeController && cmd.supportController ||
mode == runtime.ModeAgent && cmd.supportAgent {
allCommands = append(allCommands, strings.Split(cmd.cobraCommand.Use, " ")[:1])
}
}
return allCommands
Expand Down

0 comments on commit ec4a75c

Please sign in to comment.