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
Dynamically configure verbose logging #4311
Dynamically configure verbose logging #4311
Conversation
prow/config.yaml
Outdated
@@ -1,6 +1,7 @@ | |||
plank: | |||
job_url_template: 'https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/{{if eq .Spec.Type "presubmit"}}pr-logs/pull{{else if eq .Spec.Type "batch"}}pr-logs/pull{{else}}logs{{end}}{{if ne .Spec.Refs.Org ""}}{{if ne .Spec.Refs.Org "kubernetes"}}/{{.Spec.Refs.Org}}_{{.Spec.Refs.Repo}}{{else if ne .Spec.Refs.Repo "kubernetes"}}/{{.Spec.Refs.Repo}}{{end}}{{end}}{{if eq .Spec.Type "presubmit"}}/{{with index .Spec.Refs.Pulls 0}}{{.Number}}{{end}}{{else if eq .Spec.Type "batch"}}/batch{{end}}/{{.Spec.Job}}/{{.Status.BuildID}}/' | |||
report_template: '[Full PR test history](https://k8s-gubernator.appspot.com/pr/{{if eq .Spec.Refs.Org "kubernetes"}}{{if eq .Spec.Refs.Repo "kubernetes"}}{{else}}{{.Spec.Refs.Repo}}/{{end}}{{else}}{{.Spec.Refs.Org}}_{{.Spec.Refs.Repo}}/{{end}}{{with index .Spec.Refs.Pulls 0}}{{.Number}}{{end}}). [Your PR dashboard](https://k8s-gubernator.appspot.com/pr/{{with index .Spec.Refs.Pulls 0}}{{.Author}}{{end}}). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/{{.Spec.Refs.Org}}/{{.Spec.Refs.Repo}}/issues?q=is:issue+is:open) when you hit one in your PR.' | |||
enable_verbose_log: false |
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.
I think it can just be called "verbose_log"
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.
fixed
prow/config/config.go
Outdated
@@ -57,6 +57,8 @@ type Tide struct { | |||
// These must be valid GitHub search queries. They should not overlap, | |||
// which is to say two queries should never return the same PR. | |||
Queries []string `json:"queries,omitempty"` | |||
// EnableVerboseLog enables verbose logging for tide dynamically. | |||
EnableVerboseLog bool `json:"enable_verbose_log,omitempty"` |
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.
Do we want one "verbose_log" config option for all of prow, or an individual option for each component?
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.
Good question, I thought about this and don't feel strong in any way.
Single option:
- We don't bloat the config.
- Easy to use when you want to debug an event e2e.
Each component has its own:
- Finer-grained logging. We may want to run hook with high verbosity and jenkins-operator turned off.
I am willing to try out the single option now that I have layed out my thoughts on the pros of each side. Looking back at hook logging, it feels to me that high verbosity on it is not necessary by default.
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.
Hrm, re hook it's not possible to force it update its client w/o hacking in it a bit more so it's left on by default for now.
@spxtr any more comments here? |
I have mixed feelings about this one. Reaching in and setting the clients' I haven't thought up a better way, though. |
It's not any different from today, is it? Rewritting the client is going to break any option that is set during initialization. I think this is the simplest and cleanest solution we can get right now for dynamic logging and I would really like to have it as an option when things go south. Related discussion in kubernetes/kubernetes#39758. |
I guess one alternative is to have everything use the standard logger instead of setting I'm okay with this PR as well, though. Just not super excited about it. |
We don't use different log levels as much today and I am more interested in disabling logging altogether, or more precisely enable logging when I want to debug something. Or we could change the client loggers to always print in debugging mode. Then, your suggestion makes sense. Thoughts? |
@spxtr updated as per your suggestion. Feels cleaner indeed. |
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.
Nice, this looks great. Minor comments.
prow/config/config.go
Outdated
@@ -53,6 +54,10 @@ type Config struct { | |||
// Defaults to "default". | |||
PodNamespace string `json:"pod_namespace,omitempty"` | |||
|
|||
// LogLevel enables dynamically updating the log level of the | |||
// standard logger that is used by all prow components. | |||
LogLevel string `json:"log_level,omitempty"` |
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.
Somehow indicate that it must be one of these. Maybe just explicitly list them here?
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.
done
prow/config/config.go
Outdated
|
||
level := logrus.InfoLevel | ||
if lvl, err := logrus.ParseLevel(c.LogLevel); err != nil { | ||
logrus.Warningf("Cannot parse log level, will default to 'info': %v", err) |
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.
Propagate up the error rather than allowing it by, and special-case empty string to mean logrus.InfoLevel
.
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.
done
logger := logrus.StandardLogger() | ||
kc.Logger = logger.WithField("client", "kube") | ||
jc.Logger = logger.WithField("client", "jenkins") | ||
ghc.Logger = logger.WithField("client", "github") |
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.
It may be worth putting gc.logger = logrus.StandardLogger().WithField("client", "github")
into github.NewClient
. The Logger
field doesn't really need to be public, and this helps make sure that things are consistent going forward.
I'd be okay with that happening in a separate PR.
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.
Yeah, separate PR.
Great stuff, thanks. /lgtm |
@Kargakis: I updated Prow config for you! In response to this:
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. |
Unify enabling verbose logging across the main prow
workhorses and add missing logging calls in Jenkins
and Slack clients.
Tested this with tide and it works like a charm.
/assign spxtr