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] Allow preview on locked stack #8642

Merged
merged 2 commits into from Dec 29, 2021
Merged

Conversation

lukehoban
Copy link
Member

The httpstate backend allows previews to proceed even while an update is in progress. This is potentially problematic as the preview may be relative to a partial state of the stack, but ensures that previews will not be blocked on stacks that have long running updates (for example, to allow for concurrent PR jobs to preview changes). This behaviour has been consistent ~forever for the httpstate backend.

In the filestate backend, we recently introduced locking, using a quite different (more coarse-grained) approach. As part of this implementation, preview was added to the list of operations that require an exclusive lock on the stack.

For consistency, we should loosen this so that preview behaves the same relative to state locking in the filestate and httpstate backends.

In the future, we may well want to tighten this up for both backends, with some additional user controls. Also, when the update plans feature lands shortly, that will provide some additional helpful guarantees that a previous preview was not accidentally relative to a partial state.

Fixes #8609.

The httpstate backend allows previews to proceed even while an update is in progress.  This is potentially problematic as the preview may be relative to a partial state of the stack, but ensures that previews will not be blocked on stacks that have long running updates (for example, to allow for concurrent PR jobs to preview changes).  This behaviour has been consistent ~forever for the httpstate backend.

In the filestate backend, we recently introduced locking, using a quite different (more coarse-grained) approach. As part of this implementation, preview was added to the list of operations that require an exclusive lock on the stack.

For consistency, we should loosen this so that preview behaves the same relative to state locking in the filestate and httpstate backends.

In the future, we may well want to tighten this up for both backends, with some additional user controls.  Also, when the update plans feature lands shortly, that will provide some additional helpful guarantees that a previous preview was not accidentally relative to a partial state.

Fixes #8609.
@lukehoban lukehoban requested a review from t0yv0 December 28, 2021 22:23
@@ -456,6 +457,25 @@ func TestLocalStateLocking(t *testing.T) {
}
}
}

// Run 10 concurrent previews
Copy link
Member Author

Choose a reason for hiding this comment

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

Added test coverage here - but this test is skipped currently due to #7269. I verified locally that this test correctly fails before the change and succeeds after the change when un-skipped.

@codecov
Copy link

codecov bot commented Dec 28, 2021

Codecov Report

Merging #8642 (20ecc10) into master (5ec0b2f) will decrease coverage by 2.40%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8642      +/-   ##
==========================================
- Coverage   58.80%   56.39%   -2.41%     
==========================================
  Files         634      540      -94     
  Lines       97295    91931    -5364     
  Branches     1383     1383              
==========================================
- Hits        57216    51847    -5369     
- Misses      36823    36878      +55     
+ Partials     3256     3206      -50     
Impacted Files Coverage Δ
pkg/backend/filestate/backend.go 49.55% <ø> (-0.01%) ⬇️
sdk/go/common/workspace/creds.go 39.35% <50.00%> (+0.65%) ⬆️
sdk/nodejs/automation/localWorkspace.ts 5.03% <0.00%> (-69.38%) ⬇️
sdk/python/lib/pulumi/automation/_stack.py 24.19% <0.00%> (-69.36%) ⬇️
sdk/python/lib/pulumi/automation/_cmd.py 27.50% <0.00%> (-67.50%) ⬇️
...dk/python/lib/pulumi/automation/_stack_settings.py 30.23% <0.00%> (-67.45%) ⬇️
sdk/nodejs/automation/cmd.ts 12.82% <0.00%> (-66.67%) ⬇️
sdk/nodejs/automation/server.ts 9.72% <0.00%> (-63.89%) ⬇️
sdk/nodejs/automation/stack.ts 6.22% <0.00%> (-63.33%) ⬇️
...k/python/lib/pulumi/automation/_local_workspace.py 25.70% <0.00%> (-58.10%) ⬇️
... and 146 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f9e23b...20ecc10. Read the comment docs.

Copy link
Member

@t0yv0 t0yv0 left a comment

Choose a reason for hiding this comment

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

🚢

@lukehoban lukehoban merged commit 21037c0 into master Dec 29, 2021
@pulumi-bot pulumi-bot deleted the lukehoban/8609 branch December 29, 2021 16:28
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.

preview fails if state is locked in non-service backend
2 participants