-
Notifications
You must be signed in to change notification settings - Fork 807
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 support for JSON logging #1467
Conversation
@@ -112,6 +112,7 @@ fullnameOverride: | |||
controller: | |||
additionalArgs: [] | |||
sdkDebugLog: false | |||
loggingFormat: text |
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.
Not now, but we should consider making JSON the default sometime in the future.
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.
Looking at the proposal, they seem to have text as default. Do we want to have this changed prematurely, considering that this will render the divergence between the default formats for core k8s and CSI driver's logs, which may not be a good customer experience?
My feeling is that we should keep the parity with k8s on that. When they change the default setting, it will make sense for us to do the same.
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.
In my opinion, we should keep the same default as k8s unless we have a strong reason not to do so.
44ea899
to
f310cf4
Compare
5d4903b
to
20a5fe7
Compare
20a5fe7
to
5d0b388
Compare
5d0b388
to
d41be12
Compare
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.
Some minor nits. Largely lgtm other than fixing the known helm chart bug.
@@ -56,20 +57,19 @@ func TestGetOptions(t *testing.T) { | |||
}, additionalArgs...) | |||
|
|||
if withServerOptions { | |||
args = append(args, "-"+endpointFlagName+"="+endpoint) | |||
args = append(args, "--"+endpointFlagName+"="+endpoint) |
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 the previous versions not work anymore? Do we care about this theoretically breaking change?
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.
To provide some context, this change was introduced as a result of migrating to the pflag
package which is a "drop-in replacement for Go's flag package". This flag type is used to add the component-based flags: https://pkg.go.dev/k8s.io/component-base/logs/api/v1#AddFlags.
Unlike Go's standard flag package, when using the pflag
package, a single dash before an option means something different than a double dash. Single dashes signify a series of shorthand letters for flags. Hence this change.
The new behavior for using the "shorthand flags" -
is as follows:
$ ./aws-ebs-csi-driver -aws-sdk-debug-log=true
unknown shorthand flag: 'a' in -aws-sdk-debug-log=true
It is common convention to use a single hyphen -
to specify a single character flag, and a double hyphen --
to specify a keyword flag so I don't believe this change is particularly dangerous but if it is a concern we could theoretically support shorthand flags as well.
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 this is an acceptable justification, but we MUST make sure to call this out in the changelog.
d41be12
to
cdf7c53
Compare
"k8s.io/component-base/metrics/legacyregistry" | ||
|
||
"k8s.io/klog/v2" | ||
) | ||
|
||
func main() { | ||
fs := flag.NewFlagSet("aws-ebs-csi-driver", flag.ExitOnError) | ||
|
||
if err := logsapi.RegisterLogFormat(logsapi.JSONLogFormat, json.Factory{}, logsapi.LoggingBetaOptions); err != 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 we go with the default logging format, e.g. text
, do we still need to register json log format?
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.
Similar to other K8s components such as Kubelet we register supported log formats as early possible and before the flag is set, as this information needs to be known in advance:
https://github.com/kubernetes/component-base/blob/33f62c7b28186a591e1b25e900fe573ed296e181/logs/api/v1/options.go#L186 (names of registered log formats retrieved) -> https://github.com/kubernetes/component-base/blob/33f62c7b28186a591e1b25e900fe573ed296e181/logs/api/v1/options.go#L187 (logging-format
flag is added, listing permitted formats).
c198b38
to
edddc1f
Compare
ae59c6c
to
a58eb8c
Compare
@@ -56,20 +57,19 @@ func TestGetOptions(t *testing.T) { | |||
}, additionalArgs...) | |||
|
|||
if withServerOptions { | |||
args = append(args, "-"+endpointFlagName+"="+endpoint) | |||
args = append(args, "--"+endpointFlagName+"="+endpoint) |
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 this is an acceptable justification, but we MUST make sure to call this out in the changelog.
a58eb8c
to
ab6b587
Compare
Introduce logging-format driver option for the controller and node pods to set the log format. Permitted formats: text (default), json. Migrate to Structured Logging. Deprecate logtostderr flag. Signed-off-by: Eddie Torres <[email protected]>
ab6b587
to
ad25982
Compare
/lgtm If there are no additional comments/issues brought up, I will be approving this PR for merge at the end of Friday, January 20th. |
/lgtm |
@vkuzniet: changing LGTM is restricted to collaborators 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. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ConnorJC3 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 |
It has been deprecated upstream, kubernetes-sigs/aws-ebs-csi-driver#1467
Is this a bug fix or adding new feature?
What is this PR about? / Why do we need it?
logging-format
driver option for the controller and node pods to set the log format. Permitted formats:text
(default),json
.logtostderr
flag. For more information see: KEP-2845: Deprecate klog specific flags in Kubernetes Components.What testing is done?
loggingFormat: text
->loggingFormat: json
incharts/aws-ebs-csi-driver/values.yaml
.helm upgrade --install aws-ebs-csi-driver --namespace kube-system ./charts/aws-ebs-csi-driver --values ./charts/aws-ebs-csi-driver/values.yaml
.Testing logs
text
):json
):json
) | logLevel:6
.Signed-off-by: Eddie Torres [email protected]