-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
implement "--log_file" and "--log_dir" for klog #9592
implement "--log_file" and "--log_dir" for klog #9592
Conversation
Hi @prezha. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Can one of the admins verify this patch? |
Codecov Report
@@ Coverage Diff @@
## master #9592 +/- ##
==========================================
+ Coverage 29.05% 29.47% +0.42%
==========================================
Files 172 173 +1
Lines 10506 10736 +230
==========================================
+ Hits 3052 3164 +112
- Misses 7029 7123 +94
- Partials 425 449 +24
|
/ok-to-test |
kvm2 Driver |
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.
Thank you very much for fixing this ! I find this bug one of the most difficult to debug.
good job !
do you mind verifiying the other flags of "minikube options" is also supported?
for example
--log_file_max_size=1800: Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited.
minikube options
--add_dir_header=false: If true, adds the file directory to the header of the log messages
--alsologtostderr=false: log to standard error as well as files
-b, --bootstrapper='kubeadm': The name of the cluster bootstrapper that will set up the Kubernetes cluster.
--log_backtrace_at=:0: when logging hits line file:N, emit a stack trace
--log_dir='': If non-empty, write log files in this directory
--log_file='': If non-empty, use this log file
--log_file_max_size=1800: Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited.
--logtostderr=true: log to standard error instead of files
-p, --profile='minikube': The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently.
--skip_headers=false: If true, avoid header prefixes in the log messages
--skip_log_headers=false: If true, avoid headers when opening log files
--stderrthreshold=2: logs at or above this threshold go to stderr
-v, --v=0: number for the log level verbosity
--vmodule=: comma-separated list of pattern=N settings for file-filtered logging
thank you @medyagh, much appreciated! yeah, it was an interesting one yes, i'll also check if it supports the other "minikube options" flags and feedback |
glad that you've asked this @medyagh, as we should probably upgrade to klog v2.4.0 (we're currently using v2.3.0), but that is a separate issue (#9596 & pr #9597); reasoning: i got stuck at the very beginning - with testing after upgrade to klog v2.4.0, i've confirmed in addition to fixing this bug, v2.4.0 introduced 2 new things:
and no other major changes another interesting reason for upgrading to v2.4.0 is the release comment: i haven't tested klog v2.3.0/v2.4.0 further, but, from our side, yes, all of the
in main(), values of go flag and pflag (incl. klog flags) before setFlags() was called:
after setFlags() was called:
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: medyagh, prezha The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
fixes: #9521
as described in the original issue #9521,
--log_file
and--log_dir
command line arguments were not parsed from the flagsso, after going through a bunch of source code and understanding how the things (suppose to) work, i'm sharing the outcomes:
minikube
and:=> externally defined 'global' flags (like klog's
--log_file
and--log_dir
) never got parsed and therefore always ignoredto fix these 'limitations' in our context, in
main()
:pflag
instead offlag
packagepflag.CommandLine.ParseErrorsWhitelist.UnknownFlags
totrue
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
to pickup all flags set in command linepflag.Parse()
flagsimportant to note: flags should be defined and/or initialised but never parsed in init() funcs - parse in (the beginning of) the main() func, after all init() funcs were processed
aob (already reflected in this pr):
--logtostderr
and--alsologtostderr
should be set tofalse
, but don't override user's preferences - if any: now checked/set in main(), but autoset for test runs--log_dir
actually existsk8s.io/minikube/pkg/initflag
/pkg/initflag/initflag.go
not needed/used anymoredetails (debugging)
❯ minikube status --log_file "mqb.log" --profile "pro"
in main(), values of go flag and pflag (incl. klog flags) before
setFlags()
was called:after
setFlags()
was called: