-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: Re-add project support #12437
Conversation
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
3a44ed4
to
c8e2e2c
Compare
d0ac7aa
to
90e2493
Compare
Changelog[uncommitted] (2023-03-31)Features
Miscellaneous
|
c8e2e2c
to
2ecb991
Compare
90e2493
to
d2ff37e
Compare
2ecb991
to
91168d9
Compare
d2ff37e
to
0b0ca33
Compare
91168d9
to
1314f3c
Compare
0b0ca33
to
e6140fc
Compare
1314f3c
to
0417219
Compare
6aeb938
to
76497ac
Compare
Switching back to draft to make some changes. |
76497ac
to
1398e85
Compare
We want the filestate backend to support project-scoped stacks, but we can't make the change as-is because it would break old states with new CLIs. To differentiate between old and new states, we've decided to introduce the concept of state metadata. This is a file under the path .pulumi/Pulumi.yaml that tracks metadata necessary for the filestate backend to operate. Initially, this contains just one field: `version`, with the initial value of 0 representing non-project or "legacy mode". This changes the filestate layout to track such a file, creating it if it doesn't exist with the default value of 0. In a future change, we'll introduce "version 1", which adds support for project-scoped stacks. If we ever need to make breaking changes to the layout, the version in this file will help the CLI decide whether it's allowed to handle that state bucket without corrupting it. Note that this differs slightly from the initial implementation of this functionality in #12134. Particularly, this idempotently ensures that a Pulumi.yaml exists, allowing `version: 0` to indicate legacy mode, versus the original implementation that treated absence of the file in a non-empty bucket as legacy mode. This drops the bucket.IsAccessible check from filestate.New because accessibility is now verified when we try to read the metadata file. Extracted from #12437
bfa7954
to
83fa36c
Compare
- type: feat | ||
scope: backend/filestate | ||
description: | | ||
Add support for project-scoped stacks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a comment here that write access to the root of the bucket is now needed to write "meta.yaml"
@@ -65,6 +66,28 @@ import ( | |||
// to enable gzip compression when using the filestate backend. | |||
const PulumiFilestateGzipEnvVar = "PULUMI_SELF_MANAGED_STATE_GZIP" | |||
|
|||
// This section contains names of environment variables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// This section contains names of environment variables | |
// TODO[pulumi/issues/12539]: This section contains names of environment variables |
// | ||
// These must all be registered in common/env so that they're available | ||
// with the 'pulumi env' command. | ||
// However, we don't currently use env.Value() to access their values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh we should overhaul the idea of "env" so we can inject it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #12548 to track
6d584f1
to
55449d2
Compare
The filestate backend now defaults to using project mode for new stores. This has a side effect of migrating stores in all existing tests to project mode. As a result of this, we lost some of the legacy test. To get around this, create legacy copies of affected tests. We run them in legacy mode by ensuring that the bucket is non-empty with a marker file.
This re-adds project support back to the filestate backend by implementing a new referenceStore: projectReferenceStore. We will use this reference store for all new filestate stores. Existing states will continue to use the legacyReferenceStore. To accomplish this, and to plan for the future, we introduce a 'meta.yaml' file inside the .pulumi directory. This file contains metadata about the storage state. Currently, this only holds a version number: # .pulumi/meta.yaml version: 1 Version 1 is the number we've chosen for the initial release of project support. If we ever need to make breaking changes to the storage protocol we can bump the format version. Notes: - Stack references produced by filestate will shorten to just the stack name if the project name for the stack matches the currently selected project. This required turning currentProject on localBackend into an atomic pointer because otherwise SetCurrentProject and localBackendReference.String may race. Extracted from #12134 Co-authored-by: Abhinav Gupta <abhinav@pulumi.com>
It's possible to end up in a mixed state where some stacks are project-scoped and others aren't. For instance, imagine the scenario: - *User A* sets up a new state with the latest version of the CLI and brings up a new stack - *User B* brings up a stack in that state using an older version; the older version doesn't know about the .pulumi/meta.yaml so it doesn't explode and writes a legacy stack file At this point, the state is in mixed state. To help users detect (and eventually resolve) this issue, we'll print a warning when the backend is initialized. It'll find and warn users about any legacy files. They can opt out of this check by setting an environment variable. This will help transition users to project-scoped stacks until we're ready to delete this environment variable and the check.
With project support added, filestate will default to project-scoped stacks for all newly initialized buckets. This is desirable long-term, but for the initial release, we'd like users to have an escape hatch to go back to the old layout until they've had a change to migrate. This adds the ability for users to opt-out of this feature by setting an environment variable. Note that this only applies to new buckets. You cannot opt out of this feature for a bucket that is already using project-scoped stacks.
55449d2
to
20e8917
Compare
bors merge |
12437: backend/filestate: Re-add project support r=abhinav a=abhinav This re-adds project support back to the filestate backend by implementing a new referenceStore: projectReferenceStore. We will use this reference store for all new filestate stores. Existing states will continue to use the legacyReferenceStore. To accomplish this, and to plan for the future, we introduce a 'meta.yaml' file inside the .pulumi directory. This file contains metadata about the storage state. Currently, this only holds a version number: # .pulumi/meta.yaml version: 1 Version 1 is the number we've chosen for the initial release of project support. If we ever need to make breaking changes to the storage protocol we can bump the format version. Notes: - Stack references produced by filestate will shorten to just the stack name if the project name for the stack matches the currently selected project. Testing: Besides included unit tests, we duplicate some existing tests that operate on fresh stores to also run for legacy stores by emulating a pre-existing store. Environment variables: This adds two new environment variables that affect behavior: - PULUMI_SELF_MANAGED_STATE_NO_LEGACY_WARNING: Suppresses the warning printed if a bucket contains both, project-scoped and legacy stack files. - PULUMI_SELF_MANAGED_STATE_LEGACY_LAYOUT: Uses the legacy layout for new buckets even if they're empty instead of project-scoped stacks. Extracted from #12134 --- **Commits are split for reviewability.** Co-authored-by: Abhinav Gupta <abhinav@pulumi.com> Co-authored-by: Fraser Waters <fraser@pulumi.com>
Build failed: |
This looks like a transient failure. |
bors retry |
12437: backend/filestate: Re-add project support r=abhinav a=abhinav This re-adds project support back to the filestate backend by implementing a new referenceStore: projectReferenceStore. We will use this reference store for all new filestate stores. Existing states will continue to use the legacyReferenceStore. To accomplish this, and to plan for the future, we introduce a 'meta.yaml' file inside the .pulumi directory. This file contains metadata about the storage state. Currently, this only holds a version number: # .pulumi/meta.yaml version: 1 Version 1 is the number we've chosen for the initial release of project support. If we ever need to make breaking changes to the storage protocol we can bump the format version. Notes: - Stack references produced by filestate will shorten to just the stack name if the project name for the stack matches the currently selected project. Testing: Besides included unit tests, we duplicate some existing tests that operate on fresh stores to also run for legacy stores by emulating a pre-existing store. Environment variables: This adds two new environment variables that affect behavior: - PULUMI_SELF_MANAGED_STATE_NO_LEGACY_WARNING: Suppresses the warning printed if a bucket contains both, project-scoped and legacy stack files. - PULUMI_SELF_MANAGED_STATE_LEGACY_LAYOUT: Uses the legacy layout for new buckets even if they're empty instead of project-scoped stacks. Extracted from #12134 --- **Commits are split for reviewability.** Co-authored-by: Abhinav Gupta <abhinav@pulumi.com> Co-authored-by: Fraser Waters <fraser@pulumi.com>
bors cancel |
Canceled. |
Failed again. Digging.
|
Are the lock files project scoped? |
Integration tests for filestate fail on Windows because the stack reference path is a mix of `/` and `\\` symbols. e.g. ``` want: .pulumi/locks/organization/testing-config/testing/640b9586-d794-4cce-a586-9ab58549d3d3.json got: .pulumi/locks/organization\testing-config\testing/640b9586-d794-4cce-a586-9ab58549d3d3.json ``` On Windows, the `<org>/<proj>/<name>` combo gets turned to `<org>\<proj>\<name>` by `stackLockDir(stackName)`. This is normally not a problem because the result is fed into the blob.Bucket, which handles both, but here we do exact string matching where this distinction matters. To fix, make sure to convert the path to `/` form before comparison.
Yes, the lock files are project scoped. They use fully qualified paths for the lock path.
|
bors merge |
Build succeeded: |
Adds a new blog post intended to be published this Wednesday (3/29) on the same day the feature will be released. Part of pulumi/pulumi#12173 Related Issues/PRs: - pulumi/pulumi#2522 - pulumi/pulumi#12437 - pulumi/pulumi#12438 Co-authored-by: Abhinav Gupta <abhinav@pulumi.com> Co-authored-by: George Huang <george@pulumi.com> Co-authored-by: Luke Hoban <luke@pulumi.com>
This re-adds project support back to the filestate backend
by implementing a new referenceStore: projectReferenceStore.
We will use this reference store for all new filestate stores.
Existing states will continue to use the legacyReferenceStore.
To accomplish this, and to plan for the future,
we introduce a 'meta.yaml' file inside the .pulumi directory.
This file contains metadata about the storage state.
Currently, this only holds a version number:
Version 1 is the number we've chosen for the initial release
of project support.
If we ever need to make breaking changes to the storage protocol
we can bump the format version.
Notes:
just the stack name if the project name for the stack
matches the currently selected project.
Testing:
Besides included unit tests,
we duplicate some existing tests that operate on fresh stores
to also run for legacy stores by emulating a pre-existing store.
Environment variables:
This adds two new environment variables that affect behavior:
Suppresses the warning printed if a bucket contains both,
project-scoped and legacy stack files.
Uses the legacy layout for new buckets even if they're empty
instead of project-scoped stacks.
Extracted from #12134
Commits are split for reviewability.