Conversation
dca38af to
df264d2
Compare
a4e9552 to
359f585
Compare
As for helm v4. We want to migrate logs to slog. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
``` helmClient.Log = NewSlogAdapter(slog.Default()) ``` Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
See: helm#30698 (comment) Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
0edab58 to
b238072
Compare
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
6e684c8 to
bf3d011
Compare
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
bf3d011 to
710770e
Compare
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
87846ec to
0c85456
Compare
robertsirc
left a comment
There was a problem hiding this comment.
First let me thank you for all your hard work on this. Where we are calling logging looks good but how we implement the logging i think needs to change. Rather than passing around a logger Log as to just call slog directly. Would love to setup some time to disucss if you are up to it.
pkg/cli/logger.go
Outdated
| } | ||
|
|
||
| // Create a handler that removes timestamps | ||
| handler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ |
There was a problem hiding this comment.
I am more curious why add the logger rather than just use slog directly? I thought I mentioned that on another PR.
So we should use dynamic handler to set the log level after. With this patch we can clearly see the output. Before we were always stuck in log level "info" and not seeing debug log level ``` bin/helm upgrade --install --debug --wait frontend \ --namespace test \ --set replicaCount=2 \ --set backend=http://backend-podinfo:9898/echo \ podinfo/podinfo level=DEBUG msg="getting history for release" release=frontend level=DEBUG msg="preparing upgrade" name=frontend level=DEBUG msg="performing update" name=frontend level=DEBUG msg="creating upgraded release" name=frontend level=DEBUG msg="checking resources for changes" resources=2 level=DEBUG msg="no changes detected" kind=Service name=frontend-podinfo level=DEBUG msg="patching resource" kind=Deployment name=frontend-podinfo namespace=test level=DEBUG msg="waiting for resources" count=2 timeout=5m0s level=DEBUG msg="waiting for resource" name=frontend-podinfo kind=Deployment expectedStatus=Current actualStatus=Unknown level=DEBUG msg="updating status for upgraded release" name=frontend Release "frontend" has been upgraded. Happy Helming! NAME: frontend LAST DEPLOYED: Thu Apr 10 09:56:25 2025 NAMESPACE: test STATUS: deployed REVISION: 6 DESCRIPTION: Upgrade complete ``` Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
I will ping you on Slack. ;) |
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
| settings.AddFlags(flags) | ||
| addKlogFlags(flags) | ||
|
|
||
| logger := logging.NewLogger(func() bool { return settings.Debug }) |
There was a problem hiding this comment.
We need to be dynamic with the settings because it is set later. Maybe we could simplify, if you have an idea maybe.
Some ideas here: https://www.reddit.com/r/golang/comments/15nwnkl/achieve_lshortfile_with_slog/ Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
|
After a quick call with @robertsirc I removed all mention of
Current output example: » bin/helm upgrade --install --debug --wait frontend --namespace test --set replicaCount=2 --set backend=http://backend-podinfo:9898/echo podinfo/podinfo
level=DEBUG msg="getting history for release" release=frontend
level=DEBUG msg="getting release history" name=frontend
level=DEBUG msg="preparing upgrade" name=frontend
level=DEBUG msg="getting last revision" name=frontend
....Sorry again for the size of the PR. |
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
7bcf82a to
c05bcbd
Compare
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
robertsirc
left a comment
There was a problem hiding this comment.
LGTM, there are some issues that we are going to want to follow up with another PR to fix but since this is part of Helm4, we have some liberties.
| if err := i.cfg.KubeClient.IsReachable(); err != nil { | ||
| i.cfg.Log(fmt.Sprintf("ERROR: Cluster reachability check failed: %v", err)) | ||
| slog.Error(fmt.Sprintf("cluster reachability check failed: %v", err)) | ||
| return nil, errors.Wrap(err, "cluster reachability check failed") |
There was a problem hiding this comment.
So, we log this as an error here but then return the error below it, it will be logged again. It could make sense to change this but let me bring this back others before you change anything.
| if err != nil { | ||
| return errors.Errorf("Failed to close reader for pod: %s, container: %s", podName, containerName) | ||
| } |
There was a problem hiding this comment.
Note, this was unreachable code so it's safe to remove.
What this PR does / why we need it:
tl;dr : migrate packages and cmd from
logtoslogfor logsWhile trying to implement #30689 but for V4. It was mentionned that I should use
slog. So I tried to make a first try in#30685, but it requires a change accross packages and cmd.
This PR migrates packages and cmd to
slog.slogkey-value, with everything in Debug, except logs that start withwarning:This code still need to be fully manually tested but first I would like to get some feedbacks.
cc @robertsirc @TerryHowe
Close: #30698
Special notes for your reviewer:
If applicable:
docs neededlabel should be applied if so)