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

Use promise rather than atomic.Value to record step errors. #14612

Merged
merged 1 commit into from
Nov 18, 2023

Conversation

Frassle
Copy link
Member

@Frassle Frassle commented Nov 17, 2023

Description

Fixes #14611.

atomic.Value panics if a second value is written to it which isn't exactly the same type. We were using this to atomically record any errors that happened, although where only interested in saving the first error.

This was fine if no or one error happened, or if multiple errors happened that all were the same error type. But if two errors if different error types happened sync.Value would panic.

Switched to use a promise completion source instead. If any error happens we use it to reject the completion source, we also log if this isn't the first error we've seen (a capabilitiy that sync.Value didn't give us). At the end of the step executor being used when Errored() is called we try to get the result of the completion source.

Checklist

  • I have run make tidy to update any new dependencies
  • I have run make lint to verify my code passes the lint check
    • I have formatted my code using gofumpt
  • I have run make changelog and committed the changelog/pending/<file> documenting my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version

@pulumi-bot
Copy link
Contributor

Changelog

[uncommitted] (2023-11-17)

Bug Fixes

  • [engine] Fix a panic in cancellation.
    #14612

@Frassle Frassle changed the title Use promise rather than sync.Value to record step errors. Use promise rather than atomic.Value to record step errors. Nov 17, 2023
@Frassle Frassle marked this pull request as ready for review November 17, 2023 21:13
Fixes #14611.

`sync.Value` panics if a second value is written to it which isn't
_exactly_ the same type. We were using this to atomicly record any
errors that happened, although where only interested in saving the first
error.

This was fine if no or one error happened, or if multiple errors
happened that all were the same error type. But if two errors if
different error types happened `sync.Value` would panic.

Switched to use a promise completion source instead. If any error
happens we use it to reject the completion source, we also log if this
isn't the first error we've seen (a capabilitiy that `sync.Value` didn't
give us). At the end of the step executor being used when `Errored()` is
called we try to get the result of the completion source.
Copy link
Member

@justinvp justinvp left a comment

Choose a reason for hiding this comment

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

LGTM

@Frassle Frassle added this pull request to the merge queue Nov 18, 2023
Merged via the queue into master with commit ab7ed92 Nov 18, 2023
44 checks passed
@Frassle Frassle deleted the fraser/asyncStore branch November 18, 2023 19:35
github-merge-queue bot pushed a commit that referenced this pull request Nov 30, 2023
### Features

- [cli/config] Include config values from ESC in `pulumi config`
  [#14560](#14560)

- [cli/config] Add commands for managing stack environments
  [#14628](#14628)

- [cli/config] Add a command to create an ESC environment from stack
config
  [#14634](#14634)

- [sdk/go] add optional display name and tag fields to project templates
  [#14587](#14587)

- [cli/plugin] Load policy packs in parallel on startup to reduce
startup time
  [#14495](#14495)

- [sdkgen/{go,nodejs,python}] Resource methods with plain: true outputs
can now return plain values without an Output wrapper. In particular,
this feature enables resource methods to serve as explicit provider
factories by returning preconfigured explicit providers.
  [#13592](#13592)


### Bug Fixes

- [auto/go] Fix a datarace in cloning git repos.
  [#14643](#14643)

- [auto/go] Fixes event stream lag on windows runtime
  [#14659](#14659)

- [engine] Engine now correctly handles any resource name.
  [#14107](#14107)

- [engine] Fix a panic in cancellation.
  [#14612](#14612)

- [engine] Fix root directory passed to langauge plugins when starting
pulumi in a subfolder.
  [#14684](#14684)

- [sdkgen] Schemas now validate that 'urn' and 'id' are not used as
resource output properties.
  [#14637](#14637)

- [sdkgen] Fixes marshalling the "plain" flag from object or resource
properties
  [#14648](#14648)

- [programgen/nodejs] Fix generated readFile function so that it
includes the encoding and returns a string
  [#14633](#14633)

- [sdkgen/{dotnet,go,nodejs,python}] No longer writing out name and
project from alias definitions into SDKs, only type
  [#14625](#14625)

- [sdk/go] Fix optional handling on nested props
  [#14629](#14629)

- [sdkgen/go] Fixes plain and optional properties for generated types
for Go SDKs using generics
  [#14616](#14616)

- [sdkgen/go] Generate non-plain type variants for types used as inputs
inside unions
  [#14679](#14679)

- [sdk/python] Introduces RuntimeError when we detect a cycle upon
adding dependencies to the graph. Additionally adds
"PULUMI_ERROR_ON_DEPENDENCY_CYCLES" as a new environment variable to
control this behavior. Set to `False` to return to the previous
behavior, which could potentially re-introduce infinite hangs for some
programs.
  [#14597](#14597)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic: sync/atomic: store of inconsistently typed value into Value
3 participants