pulumi / pulumi-dotnet

.NET support for Pulumi
Apache License 2.0
28 stars 25 forks source link

Consider setting PULUMI_SKIP_UPDATE_CHECK internally for Automation API #133

Open klyse opened 1 year ago

klyse commented 1 year ago

What happened?

I'm using the pulumi dotnet automation API to deploy infrastructure on demand. I'm using the callbacks OnStandardOutput and OnStandardError on the UpAsync method:

await stack.UpAsync(new UpOptions
{
    OnStandardError = error => Logger.Warning("Pulumi up error on VirtualMachineId {VirtualMachineId} Error: {Error}", vm.Id, error),
    OnStandardOutput = msg => Logger.Debug("Pulumi up output on VirtualMachineId {VirtualMachineId} Message: {Message}", vm.Id, msg)
}, token);

I'm getting output on the OnStandardError when pulumi is outdated:

[10:11:39 WRN] Pulumi up error on VirtualMachineId 6f5cecf3-40e5-464e-92f0-5befd240f584 Error: warning: A new version of Pulumi is available. To upgrade from version '3.60.0' to '3.61.0', run  => Application.CloudRendering.CloudProvider
[10:11:39 WRN] Pulumi up error on VirtualMachineId 6f5cecf3-40e5-464e-92f0-5befd240f584 Error:    $ brew update && brew upgrade pulumi => Application.CloudRendering.CloudProvider
[10:11:39 WRN] Pulumi up error on VirtualMachineId 6f5cecf3-40e5-464e-92f0-5befd240f584 Error: or visit https://pulumi.com/docs/reference/install/ for manual instructions and release notes. => Application.CloudRendering.CloudProvider

Expected Behavior

Add option to suppress update warnings or send them on stdout instead of stderr as it is not an error.

Steps to reproduce

Use the snipped above, add a stack and adjust logging.

Output of pulumi about

CLI Version 3.60.0 Go Version go1.20.2 Go Compiler gc

Host OS darwin Version 13.3 Arch arm64

Backend Name pulumi.com URL xxx User xxx Organizations xxx

Pulumi locates its logs in xxx by default warning: Failed to read project: no Pulumi.yaml project file found (searching upwards from xxx). If you have not created a project yet, use pulumi new to do so: no project file found warning: Failed to get information about the current stack: no Pulumi.yaml project file found (searching upwards from xxx). If you have not created a project yet, use pulumi new to do so: no project file found warning: A new version of Pulumi is available. To upgrade from version '3.60.0' to '3.61.0', run $ brew update && brew upgrade pulumi or visit https://pulumi.com/docs/reference/install/ for manual instructions and release notes.

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

dixler commented 1 year ago

Hey again. Thanks for filing. There's an environment variable you can set via export PULUMI_SKIP_UPDATE_CHECK=1 which should disable the warning.

klyse commented 1 year ago

Thanks for the very fast answer. This indeed seems to work.

Can I access this somehow through the C# SDK? By access I mean setting this as configuration in the UpAsync etc. methods. Setting the env variable works, but it has to be done for the whole dotnet process if I'm not misunderstanding something.

justinvp commented 5 months ago

Can I access this somehow through the C# SDK?

Not currently. You can set it as the configuration to UpAsync.

We should consider setting this by default for Automation API to keep the stderr output clean. I've turned this into an kind/enhancement and updated the title to reflect that.