Skip to content

Migrate ready checks to slog#30698

Closed
benoittgt wants to merge 7 commits intohelm:mainfrom
benoittgt:migrate-ready-to-slog
Closed

Migrate ready checks to slog#30698
benoittgt wants to merge 7 commits intohelm:mainfrom
benoittgt:migrate-ready-to-slog

Conversation

@benoittgt
Copy link
Copy Markdown
Contributor

@benoittgt benoittgt commented Mar 21, 2025

What this PR does / why we need it:

While working on #30685 it was mentioned that we should migrate to slog following this work #30603. To simplify the initial contribution, I think it's a good idea to first migrate ready.go to slog, then do the contribution.
This is a first attempt to migrate. I am not sure what do you want to do with log level. Everything as debug log ?

Special notes for your reviewer:

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 21, 2025
@benoittgt benoittgt changed the title Migrate ready to slog Migrate ready checks to slog Mar 21, 2025
@benoittgt benoittgt marked this pull request as ready for review March 21, 2025 11:55
return true
}
}
c.log("Pod is not ready: %s/%s", pod.GetNamespace(), pod.GetName())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I choose a capital letter for the first letter because it represent the resource.

@benoittgt benoittgt force-pushed the migrate-ready-to-slog branch from 8ee9bb3 to 91df876 Compare March 23, 2025 15:52
@robertsirc
Copy link
Copy Markdown
Member

first thank you for the PR, I do have a question it isn't directed at you but to everyone else reviewing if it makes sense to change "name" to "Job" or the respective object. I am sure @mattfarina and @TerryHowe have opinions. For future reference please tag me in any PR when it comes to logging, it is my goal to get this in for Helm 4.

@benoittgt
Copy link
Copy Markdown
Contributor Author

benoittgt commented Mar 24, 2025

it makes sense to change "name" to "Job" or the respective object

I tink it's a good idea, but I am wondering how it could render on classic helm debug logs with similar line starting content. How it will be formatted?

For future reference please tag me in any PR when it comes to logging, it is my goal to get this in for Helm 4.

Yes ! For sure. 🙏

@robertsirc
Copy link
Copy Markdown
Member

Like if someone was searching for the structured log for a job named "blah" it might make sense to call this for what it is not just a name.

@benoittgt
Copy link
Copy Markdown
Contributor Author

benoittgt commented Mar 25, 2025

Hello @robertsirc

We are using the helm-sdk and we are consuming debug log by having a custom DebugLog here. I'm wondering how this will work with slog ?
DebugLog was interesting because we could pipe logs of a specific upgrade with dedicated informations, like the original request uuid.

We should probably keep the log setup but instead having a custom interface that accept slog. So we could pass a custom one if needed to keep the same behavior. I think my proposal is not correct.

Thanks 😊

@benoittgt benoittgt marked this pull request as draft March 25, 2025 11:09
Copy link
Copy Markdown
Contributor

@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, just wondered what people thought about updating the log message content a bit.

Comment on lines +290 to +294
slog.Debug("Deployment is not ready: observedGeneration does not match spec generation",
"namespace", dep.Namespace,
"name", dep.Name,
"observedGeneration", dep.Status.ObservedGeneration,
"specGeneration", dep.ObjectMeta.Generation)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the customer's perspective, I wonder if something like this would make more sense:

Suggested change
slog.Debug("Deployment is not ready: observedGeneration does not match spec generation",
"namespace", dep.Namespace,
"name", dep.Name,
"observedGeneration", dep.Status.ObservedGeneration,
"specGeneration", dep.ObjectMeta.Generation)
slog.Debug("Deployment generation not updated",
"namespace", dep.Namespace,
"name", dep.Name,
"actualGeneration", dep.Status.ObservedGeneration,
"expectedGeneration", dep.ObjectMeta.Generation)

Comment on lines +300 to +304
slog.Debug("Deployment is not ready: not enough pods ready",
"namespace", dep.Namespace,
"name", dep.Name,
"readyReplicas", rs.Status.ReadyReplicas,
"expectedReplicas", expectedReady)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, from the customer perspective, I wonder if this would make more sense

Suggested change
slog.Debug("Deployment is not ready: not enough pods ready",
"namespace", dep.Namespace,
"name", dep.Name,
"readyReplicas", rs.Status.ReadyReplicas,
"expectedReplicas", expectedReady)
slog.Debug("Deployment does not have enough pods ready",
"namespace", dep.Namespace,
"name", dep.Name,
"readyReplicas", rs.Status.ReadyReplicas,
"expectedReplicas", expectedReady)

benoittgt added a commit to benoittgt/helm that referenced this pull request Mar 25, 2025
@benoittgt benoittgt mentioned this pull request Mar 25, 2025
3 tasks
benoittgt added a commit to benoittgt/helm that referenced this pull request Mar 25, 2025
See: helm#30698 (comment)
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
@robertsirc
Copy link
Copy Markdown
Member

Hello @robertsirc

We are using the helm-sdk and we are consuming debug log by having a custom DebugLog here. I'm wondering how this will work with slog ? DebugLog was interesting because we could pipe logs of a specific upgrade with dedicated informations, like the original request uuid.

We should probably keep the log setup but instead having a custom interface that accept slog. So we could pass a custom one if needed to keep the same behavior. I think my proposal is not correct.

Thanks 😊

So, we would like to remove how we are doing this logging with DebugLog and just use slog statically.

@benoittgt
Copy link
Copy Markdown
Contributor Author

benoittgt commented Apr 7, 2025

Thanks @robertsirc for your answer.

I will adapt my work to follow your choice.

DebugLog was interesting because we could pipe logs of a specific upgrade with dedicated informations, like the original request uuid.

I think it will still be possible to a custom handler function passed 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>
@benoittgt benoittgt force-pushed the migrate-ready-to-slog branch from 91df876 to ef03e2b Compare April 7, 2025 13:01
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
@benoittgt benoittgt force-pushed the migrate-ready-to-slog branch from 4eff8b3 to 28305b5 Compare April 7, 2025 13:13
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
benoittgt added a commit to benoittgt/helm that referenced this pull request Apr 7, 2025
See: helm#30698 (comment)
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
@benoittgt
Copy link
Copy Markdown
Contributor Author

In my attempt to make changes suggested in #30698 (comment), to have a fully functionning code I had to go much much further. So I've updated the migrated pull request. See: #30708

cc @robertsirc

Shaps pushed a commit to Shaps/helm that referenced this pull request Sep 27, 2025
See: helm#30698 (comment)
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
@benoittgt benoittgt deleted the migrate-ready-to-slog branch December 5, 2025 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants