Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

fluxd - add ability to pass flags to klog #2407

Closed
cristian-radu opened this issue Aug 27, 2019 · 3 comments · Fixed by #2410
Closed

fluxd - add ability to pass flags to klog #2407

cristian-radu opened this issue Aug 27, 2019 · 3 comments · Fixed by #2410
Labels
blocked-needs-validation Issue is waiting to be validated before we can proceed enhancement

Comments

@cristian-radu
Copy link

Since fluxd uses client-go, which in turn uses klog for logging, it would be beneficial for fluxd to support setting klog flags from the command line, similar to all other kubernetes components.

The log level is particularly useful for troubleshooting since the klog package initializes this to 0.
https://github.com/kubernetes/klog/blob/master/klog.go#L404

fluxd also uses client-go rate-limiting of requests to the kubernetes API server:https://github.com/fluxcd/flux/blob/master/cmd/fluxd/main.go#L375-L376

Doing some research on this, I believe there is currently no means of identifying when requests are in fact being throttled since those messages are logged at verbosity level 4: https://github.com/kubernetes/client-go/blob/master/rest/request.go#L538

I suggest the easiest way to add this functionality is to swap out "github.com/spf13/pflag" with the "flag" package from the standard library. After that, simply calling klog.InitFlags() should add all of its flags to the fluxd flagset.

@cristian-radu cristian-radu added blocked-needs-validation Issue is waiting to be validated before we can proceed enhancement labels Aug 27, 2019
@stefanprodan
Copy link
Member

Switching to flag is not an option since we depend on specific pflag features. But this is not needed to log the rate limit messages. Klog can be initialised inline and we can pass in a fluxd flag to it that sets the verbosity.

@cristian-radu
Copy link
Author

Hmmm, are you referring to https://github.com/fluxcd/flux/blob/master/cmd/fluxd/main.go#L283 as the pflag features flux depends on? @stefanprodan I just noticed those.

I don't have any strong preference for how klog initialization is handled. I didn't have much success with trying to pass it a *flag.FlagSet populated through pflag flags, but maybe there is something I missed.

@stefanprodan
Copy link
Member

Can you please test my PR and see if it works? The fluxd flag is --k8s-verbosity=4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked-needs-validation Issue is waiting to be validated before we can proceed enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants