-
Notifications
You must be signed in to change notification settings - Fork 156
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
Discard log messages when initializing the provider #4650
Conversation
Messages sent early to the "log" package end up being forwarded to stderr, and Pulumi displays stderr by default to users, which is undesirable. Later in the provider life-cycle, Pulumi Terraform Bridge will reset `log.SetOutput` again to capture and appropriately track diagnostic logs, which should still work with this change. Fixes #4645 A test is added to ensure we do not leak diagnostics again on a simple program.
Does the PR have any schema changes?Looking good! No breaking changes found. Maintainer note: consult the runbook for dealing with any breaking changes. |
provider/resources.go
Outdated
@@ -5876,3 +5877,7 @@ func setupComputedIDs(prov *tfbridge.ProviderInfo) { | |||
return attrWithSeparator(state, ":", "name", "restoreTestingPlanName"), nil | |||
} | |||
} | |||
|
|||
func init() { | |||
log.SetOutput(io.Discard) |
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 test in any way that the bridge actually resets this again in the end? I'm a bit worried that the bridge behavior will be eventually changed and then this here just send everything into the void for aws
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 possibly try testing something like this statement in ACM certificate read:
log.Printf("[WARN] ACM Certificate %s not found, removing from state", arn)
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 couldn't find an existing test for this so constructed one using aws.s3.Bucket and object.
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.
This is very similar to pulumi/pulumi-databricks#474 (comment). If this works, then I don't think it needs to be in init
(I think init
occurs after all dependencies have been loaded, ordering of Go's life before main is largely UB). If you put this at the top of the Provider
function, does it not work? That would give you guaranteed scoping with a defer log.SetOutput(os.Stdout)
.
@@ -30,6 +33,9 @@ import ( | |||
// runtime startup is somewhat performance sensitive. Therefore any modifications undertaken here should complete | |||
// quickly. | |||
func newUpstreamProvider(ctx context.Context) awsShim.UpstreamProvider { | |||
log.SetOutput(io.Discard) // ignore logging from upstream constructors |
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 have moved here @iwahbe @flostadler that still works.
This is not entirely the right thing to do. We need to revisit bridge Main APIs and clean them up. The bridge should be initializing the provider and setting up logging against the Pulumi CLI host before calling into the provider-specific constructors. Then instead of discarding these logs would get the regular log sink.
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.
We can only get so far with that strategy, but we should do it just to clean up the proliferation of Main APIs.
pulumi-databricks hit log statements during variable setup (before main).
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
/release patch |
This PR has been shipped in release v6.56.1. |
This commit changes the log level from plugin stdout&stderr to debug, from info. This change is significant because info is shown by default to users, but debug is not. While this is a change of plugin aesthetics, it does not effect any runtime behavior. All plugins, both component providers and custom resource providers, are effected. > [!IMPORTANT] > This is a breaking change, in that information which used to be displayed to users will > now be hidden by default. > > We will need to share this change with our users before rolling it out. The providers team has met and believe that this is the best approach for our ecosystem. For a full discussion on why this change is necessary, see [this doc](https://docs.google.com/document/d/1yYrwTwsNoayaIzKyG1l5cl0MjJxiHLsH4NqAvZkQN-I/edit?tab=t.0#heading=h.34v61lg1x4kl). Fixes pulumi/pulumi-terraform-bridge#2489 Fixes pulumi/pulumi-cloudngfwaws#23 Fixes pulumi/pulumi-ise#9 Taking this change will allow us to revert: - pulumi/pulumi-databricks#609 - pulumi/pulumi-aws#4650
This commit changes the log level from plugin stdout&stderr to debug, from info. This change is significant because info is shown by default to users, but debug is not. While this is a change of plugin aesthetics, it does not effect any runtime behavior. All plugins, both component providers and custom resource providers, are effected. > [!IMPORTANT] > This is a breaking change, in that information which used to be displayed to users will > now be hidden by default. > > We will need to share this change with our users before rolling it out. The providers team has met and believe that this is the best approach for our ecosystem. For a full discussion on why this change is necessary, see [this doc](https://docs.google.com/document/d/1yYrwTwsNoayaIzKyG1l5cl0MjJxiHLsH4NqAvZkQN-I/edit?tab=t.0#heading=h.34v61lg1x4kl). Fixes pulumi/pulumi-terraform-bridge#2489 Fixes pulumi/pulumi-cloudngfwaws#23 Fixes pulumi/pulumi-ise#9 Taking this change will allow us to revert: - pulumi/pulumi-databricks#609 - pulumi/pulumi-aws#4650
This commit changes the log level from plugin stdout&stderr to debug, from info. This change is significant because info is shown by default to users, but debug is not. While this is a change of plugin aesthetics, it does not effect any runtime behavior. All plugins, both component providers and custom resource providers, are effected. > [!IMPORTANT] > This is a breaking change, in that information which used to be displayed to users will > now be hidden by default. > > We will need to share this change with our users before rolling it out. The providers team has met and believe that this is the best approach for our ecosystem. For a full discussion on why this change is necessary, see [this doc](https://docs.google.com/document/d/1yYrwTwsNoayaIzKyG1l5cl0MjJxiHLsH4NqAvZkQN-I/edit?tab=t.0#heading=h.34v61lg1x4kl). Fixes pulumi/pulumi-terraform-bridge#2489 Fixes pulumi/pulumi-cloudngfwaws#23 Fixes pulumi/pulumi-ise#9 Taking this change will allow us to revert: - pulumi/pulumi-databricks#609 - pulumi/pulumi-aws#4650
This commit changes the log level from plugin stdout&stderr to debug, from info. This change is significant because info is shown by default to users, but debug is not. While this is a change of plugin aesthetics, it does not effect any runtime behavior. All plugins, both component providers and custom resource providers, are effected. > [!IMPORTANT] > This is a breaking change, in that information which used to be displayed to users will > now be hidden by default. > > We will need to share this change with our users before rolling it out. The providers team has met and believe that this is the best approach for our ecosystem. For a full discussion on why this change is necessary, see [this doc](https://docs.google.com/document/d/1yYrwTwsNoayaIzKyG1l5cl0MjJxiHLsH4NqAvZkQN-I/edit?tab=t.0#heading=h.34v61lg1x4kl). Fixes pulumi/pulumi-terraform-bridge#2489 Fixes pulumi/pulumi-cloudngfwaws#23 Fixes pulumi/pulumi-ise#9 Taking this change will allow us to revert: - pulumi/pulumi-databricks#609 - pulumi/pulumi-aws#4650 --- When a provider exists ungracefully, we dump *all* unstructured logs to the user. This allows providers to output stack traces to users (so they can report them) when a provider fails. We do not search for `panic` messages to isolate the stack trace, since we cannot do that effectively in a cross-language way.
This commit changes the log level from plugin stdout&stderr to debug, from info. This change is significant because info is shown by default to users, but debug is not. While this is a change of plugin aesthetics, it does not effect any runtime behavior. All plugins, both component providers and custom resource providers, are effected. > [!IMPORTANT] > This is a breaking change, in that information which used to be displayed to users will > now be hidden by default. > > We will need to share this change with our users before rolling it out. The providers team has met and believe that this is the best approach for our ecosystem. For a full discussion on why this change is necessary, see [this doc](https://docs.google.com/document/d/1yYrwTwsNoayaIzKyG1l5cl0MjJxiHLsH4NqAvZkQN-I/edit?tab=t.0#heading=h.34v61lg1x4kl). Fixes pulumi/pulumi-terraform-bridge#2489 Fixes pulumi/pulumi-cloudngfwaws#23 Fixes pulumi/pulumi-ise#9 Taking this change will allow us to revert: - pulumi/pulumi-databricks#609 - pulumi/pulumi-aws#4650 --- When a provider exists ungracefully, we dump *all* unstructured logs to the user. This allows providers to output stack traces to users (so they can report them) when a provider fails. We do not search for `panic` messages to isolate the stack trace, since we cannot do that effectively in a cross-language way.
This commit changes the log level from plugin stdout&stderr to debug, from info. This change is significant because info is shown by default to users, but debug is not. While this is a change of plugin aesthetics, it does not effect any runtime behavior. All plugins, both component providers and custom resource providers, are effected. > [!IMPORTANT] > This is a breaking change, in that information which used to be displayed to users will > now be hidden by default. > > We will need to share this change with our users before rolling it out. The providers team has met and believe that this is the best approach for our ecosystem. For a full discussion on why this change is necessary, see [this doc](https://docs.google.com/document/d/1yYrwTwsNoayaIzKyG1l5cl0MjJxiHLsH4NqAvZkQN-I/edit?tab=t.0#heading=h.34v61lg1x4kl). Fixes pulumi/pulumi-terraform-bridge#2489 Fixes pulumi/pulumi-cloudngfwaws#23 Fixes pulumi/pulumi-ise#9 Taking this change will allow us to revert: - pulumi/pulumi-databricks#609 - pulumi/pulumi-aws#4650 --- When a provider exists ungracefully, we dump *all* unstructured logs to the user. This allows providers to output stack traces to users (so they can report them) when a provider fails. We do not search for `panic` messages to isolate the stack trace, since we cannot do that effectively in a cross-language way.
This commit changes the log level from plugin stdout&stderr to debug, from info. This change is significant because info is shown by default to users, but debug is not. While this is a change of plugin aesthetics, it does not effect any runtime behavior. All plugins, both component providers and custom resource providers, are effected. > [!IMPORTANT] > This is a breaking change, in that information which used to be displayed to users will > now be hidden by default. > > We will need to share this change with our users before rolling it out. The providers team has met and believe that this is the best approach for our ecosystem. For a full discussion on why this change is necessary, see [this doc](https://docs.google.com/document/d/1yYrwTwsNoayaIzKyG1l5cl0MjJxiHLsH4NqAvZkQN-I/edit?tab=t.0#heading=h.34v61lg1x4kl). Fixes pulumi/pulumi-terraform-bridge#2489 Fixes pulumi/pulumi-cloudngfwaws#23 Fixes pulumi/pulumi-ise#9 Taking this change will allow us to revert: - pulumi/pulumi-databricks#609 - pulumi/pulumi-aws#4650 --- When a provider exists ungracefully, we dump *all* unstructured logs to the user. This allows providers to output stack traces to users (so they can report them) when a provider fails. We do not search for `panic` messages to isolate the stack trace, since we cannot do that effectively in a cross-language way.
This commit changes the log level from plugin stdout&stderr to debug, from info. This change is significant because info is shown by default to users, but debug is not. While this is a change of plugin aesthetics, it does not effect any runtime behavior. All plugins, both component providers and custom resource providers, are effected. > [!IMPORTANT] > This is a breaking change, in that information which used to be displayed to users will > now be hidden by default. > > We will need to share this change with our users before rolling it out. The providers team has met and believe that this is the best approach for our ecosystem. For a full discussion on why this change is necessary, see [this doc](https://docs.google.com/document/d/1yYrwTwsNoayaIzKyG1l5cl0MjJxiHLsH4NqAvZkQN-I/edit?tab=t.0#heading=h.34v61lg1x4kl). Fixes pulumi/pulumi-terraform-bridge#2489 Fixes pulumi/pulumi-cloudngfwaws#23 Fixes pulumi/pulumi-ise#9 Taking this change will allow us to revert: - pulumi/pulumi-databricks#609 - pulumi/pulumi-aws#4650 --- When a provider exists ungracefully, we dump *all* unstructured logs to the user. This allows providers to output stack traces to users (so they can report them) when a provider fails. We do not search for `panic` messages to isolate the stack trace, since we cannot do that effectively in a cross-language way.
This commit changes the log level from plugin stdout&stderr to debug, from info. This change is significant because info is shown by default to users, but debug is not. While this is a change of plugin aesthetics, it does not effect any runtime behavior. All plugins, both component providers and custom resource providers, are effected. > [!IMPORTANT] > This is a breaking change, in that information which used to be displayed to users will > now be hidden by default. > > We will need to share this change with our users before rolling it out. The providers team has met and believe that this is the best approach for our ecosystem. For a full discussion on why this change is necessary, see [this doc](https://docs.google.com/document/d/1yYrwTwsNoayaIzKyG1l5cl0MjJxiHLsH4NqAvZkQN-I/edit?tab=t.0#heading=h.34v61lg1x4kl). Fixes pulumi/pulumi-terraform-bridge#2489 Fixes pulumi/pulumi-cloudngfwaws#23 Fixes pulumi/pulumi-ise#9 Taking this change will allow us to revert: - pulumi/pulumi-databricks#609 - pulumi/pulumi-aws#4650 --- When a provider exists ungracefully, we dump *all* unstructured logs to the user. This allows providers to output stack traces to users (so they can report them) when a provider fails. We do not search for `panic` messages to isolate the stack trace, since we cannot do that effectively in a cross-language way.
This commit changes the log level from plugin stdout&stderr to debug, from info. This change is significant because info is shown by default to users, but debug is not. While this is a change of plugin aesthetics, it does not effect any runtime behavior. All plugins, both component providers and custom resource providers, are effected. > [!IMPORTANT] > This is a breaking change, in that information which used to be displayed to users will > now be hidden by default. > > We will need to share this change with our users before rolling it out. The providers team has met and believe that this is the best approach for our ecosystem. For a full discussion on why this change is necessary, see [this doc](https://docs.google.com/document/d/1yYrwTwsNoayaIzKyG1l5cl0MjJxiHLsH4NqAvZkQN-I/edit?tab=t.0#heading=h.34v61lg1x4kl). Fixes pulumi/pulumi-terraform-bridge#2489 Fixes pulumi/pulumi-cloudngfwaws#23 Fixes pulumi/pulumi-ise#9 Taking this change will allow us to revert: - pulumi/pulumi-databricks#609 - pulumi/pulumi-aws#4650 --- When a provider exists ungracefully, we dump *all* unstructured logs to the user. This allows providers to output stack traces to users (so they can report them) when a provider fails. We do not search for `panic` messages to isolate the stack trace, since we cannot do that effectively in a cross-language way.
Messages sent early to the "log" package end up being forwarded to stderr, and Pulumi displays stderr by default to users, which is undesirable.
Later in the provider life-cycle, Pulumi Terraform Bridge will reset
log.SetOutput
again to capture and appropriately track diagnostic logs, which should still work with this change.Fixes #4645
A test is added to ensure we do not leak diagnostics again on a simple program.