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

Support get/set log verbosity level by antctl and controller/agent API #1340

Merged
merged 1 commit into from
Oct 5, 2020

Conversation

jianjuns
Copy link
Contributor

@jianjuns jianjuns commented Oct 4, 2020

Add antctl log-level command that calls controller or agent /loglevel
API to get/set the log verbosity level of controller or agent in the
runtime.
Change antctl to allow an empty response of an controller or agent
call.

@antrea-bot
Copy link
Collaborator

Thanks for your PR.
Unit tests and code linters are run automatically every time the PR is updated.
E2e, conformance and network policy tests can only be triggered by a member of the vmware-tanzu organization. Regular contributors to the project should join the org.

The following commands are available:

  • /test-e2e: to trigger e2e tests.
  • /skip-e2e: to skip e2e tests.
  • /test-conformance: to trigger conformance tests.
  • /skip-conformance: to skip conformance tests.
  • /test-whole-conformance: to trigger all conformance tests on linux.
  • /skip-whole-conformance: to skip all conformance tests on linux.
  • /test-networkpolicy: to trigger networkpolicy tests.
  • /skip-networkpolicy: to skip networkpolicy tests.
  • /test-windows-conformance: to trigger windows conformance tests.
  • /skip-windows-conformance: to skip windows conformance tests.
  • /test-windows-networkpolicy: to trigger windows networkpolicy tests.
  • /skip-windows-networkpolicy: to skip windows networkpolicy tests.
  • /test-hw-offload: to trigger ovs hardware offload test.
  • /skip-hw-offload: to skip ovs hardware offload test.
  • /test-all: to trigger all tests (except whole conformance).
  • /skip-all: to skip all tests (except whole conformance).

@jianjuns
Copy link
Contributor Author

jianjuns commented Oct 4, 2020

I feel very useful to allow changing log level in the runtime.

@codecov-commenter
Copy link

codecov-commenter commented Oct 4, 2020

Codecov Report

Merging #1340 into master will decrease coverage by 0.16%.
The diff coverage is 21.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1340      +/-   ##
==========================================
- Coverage   64.63%   64.47%   -0.17%     
==========================================
  Files         157      159       +2     
  Lines       12626    12657      +31     
==========================================
- Hits         8161     8160       -1     
- Misses       3620     3645      +25     
- Partials      845      852       +7     
Flag Coverage Δ
#integration-tests 44.76% <ø> (-0.08%) ⬇️
#kind-e2e-tests 50.58% <32.00%> (-0.23%) ⬇️
#unit-tests 42.12% <0.00%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/antctl/antctl.go 100.00% <ø> (ø)
pkg/antctl/command_definition.go 41.96% <0.00%> (-0.44%) ⬇️
pkg/antctl/command_list.go 31.48% <0.00%> (-1.22%) ⬇️
pkg/log/log_level.go 10.00% <10.00%> (ø)
pkg/apiserver/handlers/loglevel/handler.go 38.46% <38.46%> (ø)
pkg/agent/apiserver/apiserver.go 66.12% <100.00%> (+0.55%) ⬆️
pkg/apiserver/apiserver.go 84.33% <100.00%> (+0.19%) ⬆️
pkg/controller/networkpolicy/tier.go 90.00% <0.00%> (-10.00%) ⬇️
pkg/apiserver/certificate/certificate.go 71.05% <0.00%> (-6.58%) ⬇️
pkg/ovs/openflow/ofctrl_bridge.go 70.35% <0.00%> (-1.59%) ⬇️
... and 3 more

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, I think we should mention the command in the antctl documentation (with the limitation that it only supports local execution).

if err != nil {
return err
}
klog.Infof("Change log level from %s to %s", oldLevel, level)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "Changed" or "Changing"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to "Changed"

@@ -50,6 +50,7 @@ rules:
verbs:
- get
- nonResourceURLs:
- /loglevel
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought these were kept in alphabetical order on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Changed.

"github.com/vmware-tanzu/antrea/pkg/log"
)

// HandleFunc returns the function which can handle the /log-level API request.
Copy link
Contributor

Choose a reason for hiding this comment

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

You used /loglevel for the APIU endpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like to follow the kubectl (and other antctl commands) style which use "-" to connect two words in command names, like cluster-info, port-forward, api-resources.

Copy link
Contributor

Choose a reason for hiding this comment

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

I undertand and I'm not suggesting you changed the antctl command name. But you are referring to the API endpoint here, for which you used /loglevel not /log-level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. I think we want not connectors in API path?

Copy link
Contributor

Choose a reason for hiding this comment

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

We haven't been using them so far, so I was really just suggesting fixing the comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Sorry for being misunderstanding your comments.
Changed to /loglevel.

@jianjuns jianjuns force-pushed the loglevel-cmd branch 2 times, most recently from f14e3c0 to 8f5766b Compare October 5, 2020 19:48
@jianjuns
Copy link
Contributor Author

jianjuns commented Oct 5, 2020

LGTM, I think we should mention the command in the antctl documentation (with the limitation that it only supports local execution).

Added the command to antctl.md.

Add antctl log-level command that calls controller or agent /loglevel
API to get/set the log verbosity level of controller or agent in the
runtime.
Change antctl to allow an empty response of an controller or agent
call.
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

@jianjuns
Copy link
Contributor Author

jianjuns commented Oct 5, 2020

/test-all

@jianjuns jianjuns merged commit 9c106b2 into antrea-io:master Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants