-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Add Istio user agent to kube-client used in istioctl and other binaries #33120
Conversation
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.
looks good
@@ -443,7 +444,7 @@ type ExecClient interface { | |||
|
|||
// NewClient is the constructor for the client wrapper | |||
func NewClient(kubeconfig, configContext string) (*Client, error) { | |||
config, err := defaultRestConfig(kubeconfig, configContext) | |||
config, err := kube.DefaultRestConfig(kubeconfig, configContext) |
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.
seems simpler change but should it be in another 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.
Oh nevermind, i see we are setting user agent at a very low level
2287196
to
f64f24e
Compare
63e41b3
to
41299a5
Compare
/test gencheck_istio |
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.
LGTM except comments on the vklog stuff. I think its awesome but may need some tweaks
istioctl/cmd/istioctl/main.go
Outdated
// EnableKlogWithCobra enables klog to work with cobra / pflags. | ||
// k8s libraries like client-go use klog. | ||
func EnableKlogWithCobra() { | ||
klog.InitFlags(nil) |
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.
does passing nil (which then uses goflag.CommandLine) cause any issues here in help messages, etc? Should we create a dedicated FlagSet for this so it doesn't unexpectedly leak out?
istioctl/cmd/istioctl/main.go
Outdated
Usage: gf.Usage + ". Like -v flag. ex: --vklog=9", | ||
})) | ||
|
||
klog.SetLogger(nil) |
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.
If I understand the situation correctly:
Today we can enable "debug" logs from klog with --log_output_level=klog:debug
. This uses our logging system (json, stackdriver, etc). But it uses the default klog verbosity level which is not 9.
This pr allows setting the klog verbosity, but it doesn't use our logging system. I think if you remove this line it will allow --vklog to work, but it also requires --log_output_level=klog:debug. It seems preferable to use our logging system, but maybe we can improve the UX
I feel like this is something that is generally useful outside of istioctl - I have often wanted this in istiod. Maybe we should make it so it can be configured as part of istio/pkg? Not sure the UX we want here though (new flag, --log_output_level=klog:debug for most cases and env var to tune -v level, etc).
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, once we have it in istioctl, we will add it to add binaries.
In a previous version of the PR I had enabled it by mistake on istiod and is spews logs, but it is very useful.
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.
Can we at least remove klog.SetLogger(nil)
so it uses our logging system?
istioctl/cmd/istioctl/main.go
Outdated
Usage: gf.Usage + ". Like -v flag. ex: --vklog=9", | ||
})) | ||
|
||
klog.SetLogger(nil) |
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.
Can we at least remove klog.SetLogger(nil)
so it uses our logging system?
@howardjohn I removed a bunch of code and now setting |
@esnible @therealmitchconnors for UX. |
/test integ-security-multicluster-tests_istio |
Add istio-user-agent string to api server calls from istio for auditability.
resolves #28231
pkg/version
to generation version string for user-agent.-v=x
option cannot be used because we use it elsewhere. istioctl renames the option, and makes it a long form option with--vklog
.--
Following is output with
--vkog=9
. This flag was also added as part of this PR. shows-H "User-Agent: istioctl/1.11-dev"