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

Add Global Run Task support #1330

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

glennsarti
Copy link
Contributor

@glennsarti glennsarti commented Apr 23, 2024

Description

This PR;

  • Updates the workspace run task resource and datasource to deprecate the stage attribute
    in favour of the new stages attribute. This also includes a state version update
  • Adds a new organization_run_task_global_settings resource and datasource for managing the
    global settings of a Run task. This does require the HCP Terraform/TFE instance to support
    global run tasks. The provider does attempt to error gracefully if a user is trying to use
    this feature if it's unsupported.

Remember to:

Testing plan

Handled by acceptance tests

External links

Output from acceptance tests

In this PR.

@glennsarti glennsarti force-pushed the gs/global-run-tasks-update branch 4 times, most recently from 3ac88ce to 4c09986 Compare May 3, 2024 04:05
@glennsarti glennsarti self-assigned this May 3, 2024
@glennsarti glennsarti changed the title {wip} Add Global Run Task support Add Global Run Task support May 3, 2024
@glennsarti glennsarti marked this pull request as ready for review May 3, 2024 04:08
@glennsarti glennsarti requested a review from a team as a code owner May 3, 2024 04:08
@glennsarti glennsarti requested a review from a team May 3, 2024 04:11
@glennsarti
Copy link
Contributor Author

Added compliance team for review as a once-over.

This commit;

* Updates the workspace run task resource and datasource to deprecate the `stage` attribute
  in favour of the new `stages` attribute. This also includes a state version update
* Adds a new organization_run_task_global_settings resource and datasource for managing the
  global settings of a Run task. This does require the HCP Terraform/TFE instance to support
  global run tasks. The provider does attempt to error gracefully if a user is trying to use
  this feature if it's unsupported.
This commit updates the documentation and changelog for the Global Run
Tasks feature.
Copy link
Collaborator

@brandonc brandonc left a comment

Choose a reason for hiding this comment

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

The code looks healthy, but let's start with a high level question 👇

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you help me understand why this schema was not added to organization_run_task?

In the case of tfe_organization_default_settings, it's very common to not manage the organization itself with the provider... and in the case of tfe_workspace_settings, the primary issue was breaking the circular dependency between agent pools and workspaces but it was also a convenient symmetry with organization_settings because it overrides 'inheritability' of those settings.

In the case of organization run tasks, neither problem seems to appear so it seems like it would be much straightforward to put all schema within the same resource. Is there a concept I am overlooking?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Another concern is "enabled" schema would appear to be managing the same thing on both resources

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So there a couple of things that forced me down this path;

  1. Global Run Tasks are entitlement based.
    So it's possible for their functionality to be removed/added outside of the provider.

    • Imagine the run task resource includes global information in it's state.
    • A run task resource is created without global run tasks being available.
    • An admin comes along and upgrades their TFC subscription to premium
    • Now the next run the resource will be out of sync because its state has changed. (from null to something)

Same applies when a resource wants to manage a global run task, but the subscription was demoted. (from something to null).

  1. We are still using Plugin Protocol v5 so I don't have have access to nested attributes. I tried so many different combinations of hacks but I could never get it quite right.

I originally did have it all in one resource ala;

org_run_task "thing" {
  ...
  global = {
    enabled = true
    enforcement-level = "advisory"
  }
}

And it worked perfectly, until I started testing changing the subscription, and everything broke.
I desperately wanted to use a nested block syntax, but I just couldn't, given the dynamic nature of the subscription turning on/off the global run task feature.

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.

None yet

2 participants