-
Notifications
You must be signed in to change notification settings - Fork 160
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
Fix ability to detect and apply agent_pool_id and execution_mode changes #607
Conversation
553765e
to
225b76c
Compare
CHANGELOG.md
Outdated
@@ -1,4 +1,5 @@ | |||
## Unreleased | |||
* r/tfe_workspace: Changes in `agent_pool_id` and `execution_mode` attributes is now detected and applied. ([#607](https://github.com/hashicorp/terraform-provider-tfe/pull/607)) |
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.
* r/tfe_workspace: Changes in `agent_pool_id` and `execution_mode` attributes is now detected and applied. ([#607](https://github.com/hashicorp/terraform-provider-tfe/pull/607)) | |
* r/tfe_workspace: Changes in `agent_pool_id` and `execution_mode` attributes are now detected and applied. ([#607](https://github.com/hashicorp/terraform-provider-tfe/pull/607)) |
tfe/resource_tfe_workspace.go
Outdated
@@ -85,7 +86,7 @@ func resourceTFEWorkspace() *schema.Resource { | |||
"execution_mode": { | |||
Type: schema.TypeString, | |||
Optional: true, | |||
Computed: true, |
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.
I wonder why this was listed as Computed
? Any thoughts?
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 is most likely based on logic that whenever an execution_mode is not specified, it will be computed and returned. With this changes, the default value is always appended whenever the field is not specified.
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.
Actually, Computed might still needed for the execution_mode
to be updated when it changes as a result of operation
field change. I am investigating this.
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.
Looks like operations
attribute has been marked as deprecated. Would it be easier to reason about if we removed the attribute?
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.
With the new changes, I have marked it as deprecated to match the API docs.
be89d11
to
f12f9eb
Compare
f12f9eb
to
caaa10a
Compare
// this prevents an attempt to destroy the agent pool before dissasociating it from the workspace | ||
func testAccTFEWorkspace_executionModeNull(organization string) string { | ||
return fmt.Sprintf(` | ||
resource "tfe_agent_pool" "foobar" { |
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.
The test was failing during the agent mode unset flow because the first config had the resource "tfe_agent_pool"
and the second config did not.The diff causes an attempt to delete the agent pool while applying the second config.
~ Approach 1 is to persist the resource "tfe_agent_pool"
in both configs so the only diff action is unsetting the workspace execution mode.
~Approach 2 is to create agent pool external to the config and then use data source to grab the agent pool in the config. This would required using the go client interface.
I have gone with approach 1. Let me know your thoughts...
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.
Much, much nicer than approach 2 👍
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.
LGTM 🔥
Smoke tested ✔️, ran acceptance test locally ✔️
Description
Workspaces can be created using the
resource "tfe_workspace"
with fields includingexecution_mode
andagent_pool_id
. After creation, if the config is updated by removing theexecution_mode
andagent_pool_id
fields, the changes are not detected during an apply and plan fails with error:Error: agent_pool_id must be provided when execution_mode is 'agent'
.See issue: #544
With this fix, changes in
execution_mode
andagent_pool_id
fields are now detected and plans/applies are successful.Remember to:
Update the Change Log
Update the Documentation
Testing plan
External links
Include any links here that might be helpful for people reviewing your PR. If there are none, feel free to delete this section.
Output from acceptance tests
Please run applicable acceptance tests locally and include the output here. See TESTS.md to learn how to run acceptance tests.
If you are an external contributor, your contribution(s) will first be reviewed before running them against the project's CI pipeline.