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

[backend/filestate] Don't unwrap go-cloud errors #8455

Merged
merged 4 commits into from
Nov 19, 2021

Conversation

praneetloke
Copy link
Contributor

@praneetloke praneetloke commented Nov 19, 2021

Description

Pulumi CLI fails with the following error when running pulumi stack select dev2 -c to select a stack but first creating it, if it does not exist already.

pulumi stack select dev2 -c --cwd C:\GitHub\temp-pulumi-stacks\pr-test\
error: failed to load checkpoint: blob (key ".pulumi/stacks/dev2.json") (code=NotFound): CreateFile C:\temp\.pulumi\stacks\dev2.json: The system cannot find the file specified.

Fixes #8461 (Related to #8406)

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the CHANGELOG-PENDING file with my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Service API version

@@ -323,7 +323,7 @@ func (b *localBackend) GetStack(ctx context.Context, stackRef backend.StackRefer
snapshot, path, err := b.getStack(stackName)

switch {
case gcerrors.Code(drillError(err)) == gcerrors.NotFound:
case gcerrors.Code(err) == gcerrors.NotFound:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem seems to be that we are passing the unwrapped error to go-cloud's Code func which tries to find a matching error that it can assign as gcerr.Error. So when it is passed an already-unwrapped error, it fails return the error code that we expect to compare against.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, gcerrors itself is wrapping errors, so when we unwrap the chain, it prevents gcerrors.Code from finding its wrapped error. This is my bad, I had suggested unwrapping the full chain to @iwahbe since we are also wrapping, not realizing that gcerrors itself is wrapping and relying on it. Sorry about that @iwahbe.

@praneetloke
Copy link
Contributor Author

I didn't update the changelog, but I think this PR does warrant an entry.

Copy link
Member

@iwahbe iwahbe left a comment

Choose a reason for hiding this comment

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

Test without fix correctly show failure and this fixes the problem on my machine. I'm happy here.

@iwahbe iwahbe merged commit 2c25c3f into master Nov 19, 2021
@pulumi-bot pulumi-bot deleted the praneetloke/fix-error-unwrapping branch November 19, 2021 20:21
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.

--create flag does not work with pulumi stack select with a filestate backend in v3.18.0
3 participants