Skip to content
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

0.13 cherrypick logger changes #3601

Merged
merged 6 commits into from
Jan 27, 2023
Merged

0.13 cherrypick logger changes #3601

merged 6 commits into from
Jan 27, 2023

Conversation

stefreak
Copy link
Member

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

stefreak and others added 5 commits January 26, 2023 15:20
This commit makes it harder to forget sending verbose logs (mostly tool
output) to both Garden Cloud and to the CLI logs.

To accomplish that, this commit

1. Fixed the type assertions in the PluginEventBroker. Now typescript
   will actually verify the types for the events in `emit` and in `on`
   etc.
2. Added two additional parameters to the `log` event, origin and log.
   Log is supposed to be a LogEntry placeholder with verbose log level.
3. Make sure that we use the `ctx.events.emit` in the plugin
   implementations to stream logs to Garden Cloud and CLI
This essentially reverts a change that was made in
#3576
(commit: b52e9b2).

The type has always been 'number' but we were in fact sending
strings to Garden Cloud which is the payload it expects.

Garden Cloud (version >= 1.360) now supports numbers but we need to
continue sending strings for backwards compatibility.

We can tighten the type to just 'number' once all Cloud instances are
up to date.
This event was introduced awhile ago but isn't used by any client at the
moment.

It was made into its own event type by mistake, it should've just been a
normal event with the name 'serverReady'. This fixes that.
Actually stream helm module outputs to CLI and Garden Cloud; the
log context was in the wrong place before.
@stefreak stefreak requested a review from Walther January 26, 2023 14:34
params.events.on("log", ({ timestamp, data }) => {
params.events.on("log", ({ timestamp, data, origin, log }) => {
// stream logs to CLI
log.setState(renderOutputStream(data.toString(), origin))
Copy link
Member Author

Choose a reason for hiding this comment

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

For some reason, in 0.13, the "log" handlers are not being called. I tried to understand why, but couldn't find the culprit. My guess is that the events instance in the plugin is a different instance than here.

This means that once this PR is merged, some logs won't appear in the CLI anymore until this "unrelated" problem has been fixed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is as you suspect, a different instance (params.events vs. ctx.events). We may want to drop one of them actually to avoid that confusion going forward. I can take that on.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've added a commit that ensures the same event broker is passed along through the plugin router, which should fix this issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you!

@stefreak stefreak requested a review from eysi09 January 26, 2023 14:42
@edvald edvald force-pushed the 0.13-cherrypick-logger-changes branch from fd337e4 to e305f16 Compare January 26, 2023 23:14
@edvald edvald merged commit 23da54c into 0.13 Jan 27, 2023
@edvald edvald deleted the 0.13-cherrypick-logger-changes branch January 27, 2023 06:36
@stefreak stefreak added the 0.13 label Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants