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

command: Taint should respect required_version #26345

Merged
merged 1 commit into from
Sep 24, 2020

Conversation

alisdair
Copy link
Contributor

@alisdair alisdair commented Sep 22, 2020

Despite not requiring the configuration for any other reason, the taint subcommand should not execute if the required_version constraints cannot be met. Doing so can result in an undesirable state file upgrade.

Fixes #26325. Fixes #23049.

Question for reviewers: it feels to me like there ought to be a neater way of loading the config to check the constraints are met. Can you think of one? 🙏

Despite not requiring the configuration for any other reason, the taint
subcommand should not execute if the required_version constraints cannot
be met. Doing so can result in an undesirable state file upgrade.
@alisdair alisdair requested a review from a team September 22, 2020 21:38
@alisdair alisdair self-assigned this Sep 22, 2020
@codecov
Copy link

codecov bot commented Sep 22, 2020

Codecov Report

Merging #26345 into master will decrease coverage by 0.00%.
The diff coverage is 47.36%.

Impacted Files Coverage Δ
command/taint.go 39.24% <47.36%> (+1.11%) ⬆️
internal/providercache/dir.go 66.66% <0.00%> (-6.25%) ⬇️
dag/marshal.go 54.79% <0.00%> (+1.36%) ⬆️
terraform/node_resource_plan.go 94.39% <0.00%> (+1.86%) ⬆️

Copy link
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

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

I have no objections to this PR as-is, but I did leave a suggestion for alternative config loading that may or may not be useful.

@@ -62,6 +64,34 @@ func (c *TaintCommand) Run(args []string) int {
return 1
}

// Load the config and check the core version requirements are satisfied
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure, but I'd be curious to see if the earlyconfig loader (examples in init.go) is sufficient and perhaps faster for this purpose. loadSingleModule for e.g. will only load the root module:

// loadSingleModule reads configuration from the given directory and returns
// a description of that module only, without attempting to assemble a module
// tree for referenced child modules.

Again, this might not actually be faster or better, but it might be worth looking at.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I hadn't thought of that! Unfortunately I think we need to load and check the entire tree's version constraints. In particular, many public registry modules have fairly strict version requirements that we need to honour.

@alisdair alisdair merged commit 60c469b into master Sep 24, 2020
@alisdair alisdair deleted the alisdair/taint-should-respect-required-version branch September 24, 2020 19:52
@ghost
Copy link

ghost commented Oct 25, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terraform taint does not respect required_version terraform taint Does Not Check Terraform Version
3 participants