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

Revert "Lock inside filestate.apply instead of Update/Delete/Import (#8806)" #8995

Merged
merged 2 commits into from Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions CHANGELOG_PENDING.md
Expand Up @@ -16,12 +16,15 @@
- [cli/go] - Fix git initialization in util_test.go
[#8924](https://github.com/pulumi/pulumi/pull/8924)

- [sdk/nodejs] - Fix nodejs function serialization module path to comply with package.json
- [sdk/nodejs] - Fix nodejs function serialization module path to comply with package.json
exports if exports is specified.
[#8893](https://github.com/pulumi/pulumi/pull/8893)

- [cli/python] - Parse a larger subset of PEP440 when guessing Pulumi package versions.
[#8958](https://github.com/pulumi/pulumi/pull/8958)

- [sdk/nodejs] - Allow disabling TypeScript typechecking
- [sdk/nodejs] - Allow disabling TypeScript typechecking
[#8981](https://github.com/pulumi/pulumi/pull/8981)

- [cli/backend] - Revert a change to file state locking that was causing stacks to stay locked.
[#8995](https://github.com/pulumi/pulumi/pull/8995)
37 changes: 28 additions & 9 deletions pkg/backend/filestate/backend.go
Expand Up @@ -467,22 +467,50 @@ func (b *localBackend) Preview(ctx context.Context, stack backend.Stack,

func (b *localBackend) Update(ctx context.Context, stack backend.Stack,
op backend.UpdateOperation) (engine.ResourceChanges, result.Result) {

err := b.Lock(ctx, stack.Ref())
if err != nil {
return nil, result.FromError(err)
}
defer b.Unlock(ctx, stack.Ref())

return backend.PreviewThenPromptThenExecute(ctx, apitype.UpdateUpdate, stack, op, b.apply)
}

func (b *localBackend) Import(ctx context.Context, stack backend.Stack,
op backend.UpdateOperation, imports []deploy.Import) (engine.ResourceChanges, result.Result) {

err := b.Lock(ctx, stack.Ref())
if err != nil {
return nil, result.FromError(err)
}
defer b.Unlock(ctx, stack.Ref())

op.Imports = imports
return backend.PreviewThenPromptThenExecute(ctx, apitype.ResourceImportUpdate, stack, op, b.apply)
}

func (b *localBackend) Refresh(ctx context.Context, stack backend.Stack,
op backend.UpdateOperation) (engine.ResourceChanges, result.Result) {

err := b.Lock(ctx, stack.Ref())
if err != nil {
return nil, result.FromError(err)
}
defer b.Unlock(ctx, stack.Ref())

return backend.PreviewThenPromptThenExecute(ctx, apitype.RefreshUpdate, stack, op, b.apply)
}

func (b *localBackend) Destroy(ctx context.Context, stack backend.Stack,
op backend.UpdateOperation) (engine.ResourceChanges, result.Result) {

err := b.Lock(ctx, stack.Ref())
if err != nil {
return nil, result.FromError(err)
}
defer b.Unlock(ctx, stack.Ref())

return backend.PreviewThenPromptThenExecute(ctx, apitype.DestroyUpdate, stack, op, b.apply)
}

Expand Down Expand Up @@ -512,15 +540,6 @@ func (b *localBackend) apply(
colors.SpecHeadline+"%s (%s):"+colors.Reset+"\n"), actionLabel, stackRef)
}

// Take a lock unless this is just a preview
if kind != apitype.PreviewUpdate {
err := b.Lock(ctx, stack.Ref())
if err != nil {
return nil, nil, result.FromError(err)
}
defer b.Unlock(ctx, stack.Ref())
}

// Start the update.
update, err := b.newUpdate(stackName, op)
if err != nil {
Expand Down