PSS: Add alternative, experimental version of init command that downloads providers in two stages#37350
Merged
SarahFrench merged 33 commits intomainfrom Aug 18, 2025
Merged
Conversation
35e5fd6 to
e4e4587
Compare
23f73b1 to
e089961
Compare
Member
Author
|
Edit: it's due to the modification of the package level |
216359a to
764650f
Compare
764650f to
4ad9f59
Compare
init command that downloads providers in two stages
3 tasks
…ocks and merge those with any locks on file. This allows re-use of providers downloaded by `getProvidersFromConfig` in the same init command
…ssing version constraints
…provider download step. When downloading providers described only in the state then the provider may already be downloaded from a previous init (i.e. is recorded in the deps lock file) or downloaded during step 1 of provider download. The message here needs to cover both potential scenarios.
…ks when there is no state
…l variable that causes tests to interact.
626d03f to
31f2cc1
Compare
radeksimko
approved these changes
Aug 14, 2025
SarahFrench
added a commit
that referenced
this pull request
Aug 26, 2025
…nloads providers in two stages (#37350) * Add forked version of `run` logic that's only used if experiments are enabled * Reorder actions in experimental init - load in full config before configuring the backend. * Add getProvidersFromConfig method, initially as an exact copy of getProviders * Make getProvidersFromConfig not use state to get providers * Add `appendLockedDependencies` method to `Meta` to allow multi-phase saving to the dep locks file * Update experimental init to use new getProvidersFromConfig method * Add new getProvidersFromState method that only accepts state information as input for getting providers. Use in experimental init and append values to existing deps lock file * Update messages sent to view about provider download phases * Change init to save updates to the deps lock file only once * Make Terraform output report that a lock file _will_ be made after providers are determined from config * Remove use of `ProviderDownloadOutcome`s * Move repeated code into separate method * Change provider download approach: determine if locks changed at point of attempting to update the lockfile, keep record of incomplete providers inside init command struct * Refactor `mergeLockedDependencies` and update test * Add comments to provider download methods * Fix issue where incorrect message ouput to view when downloading providers * Update `mergeLockedDependencies` method to be more generic * Update `getProvidersFromState` method to receive in-progress config locks and merge those with any locks on file. This allows re-use of providers downloaded by `getProvidersFromConfig` in the same init command * Fix config for `TestInit_stateStoreBlockIsExperimental` * Improve testing of mergeLockedDependencies; state locks are always missing version constraints * Add tests for 2 phase provider download * Add test case to cover use of the `-upgrade` flag * Change the message shown when a provider is reused during the second provider download step. When downloading providers described only in the state then the provider may already be downloaded from a previous init (i.e. is recorded in the deps lock file) or downloaded during step 1 of provider download. The message here needs to cover both potential scenarios. * Update mergeLockedDependencies comment * fix: completely remove use of upgrade flag in getProvidersFromState * Fix: avoid nil pointer errors by returning an empty collection of locks when there is no state * Fix: use state store data only in diagnostic * Change how we make PSS experimental - avoid relying on a package level variable that causes tests to interact. * Remove full-stop in view message, update tests * Update span names to be unique * Re-add lost early returns * Remove unused view messages * Add comments to new view messages
3 tasks
Contributor
|
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces an alternative version of the logic controlling events during an
initcommand. Instead of downloading providers in a single step, the new logic downloads providers in two steps:The dependency locks identified after each provider download action are tracked. The locks identified from the config are used as an input for downloading providers present in the state, and this prevents providers being re-downloaded or another version of a provider being downloaded. The locks identified from the config and the state are later combined and written to the dependency lock file.
This PR also changes how we control the parsing of the state_store block to gate this feature as experimental. The old approach (implemented here) is not compatible with multiple tests running in parallel, so this commit changes the way the feature is gated.
Details
The original version of the init logic (
internal/command/init_run.go) roughly does this:getProvidersmethod, with the full config and state data as inputs to that process.In the new version (
internal/command/init_run_experiment.go) there are these changes:getProvidersFromConfig(step1)getProvidersFromState(step2)The original version of this logic is used by default. The new init logic is only used when Terraform has experiments enabled and either the
-enable-pluggable-state-storage-experimentflag is passed to the init command or an environment variable calledTF_ENABLE_PLUGGABLE_STATE_STORAGEhas a non-empty value.Target Release
N/A
Rollback Plan
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
CHANGELOG entry