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

fix: save resource state when failing on subtasks #289

Merged
merged 1 commit into from
Oct 18, 2022
Merged

Conversation

ddebko
Copy link
Contributor

@ddebko ddebko commented Oct 14, 2022

Summary:

The following resources have one or more subtasks when applying the terraform creation task: group, host set, role, target, user. For example, when creating a target the following steps are invoked:

  1. Create the target
  2. Associate host sources to the target
  3. Associate credential sources to the target

Each step is a different call to the boundary API. Currently there is a bug where if I provide an invalid credential source to the target the state file does not save any information about the target. When resolving the error in the terraform source file and then reapplying the changes, boundary will return the following error: unique name violation. This is because we only set the state at the end of the creation function and the state is never set if the happy path is not followed.

Solution:

Invoke the resource setFrom{Resource Name}ResponseMap() function when a subtasks fails. This allows us to correctly sync the resource's state to what we have in Boundary. I also validated the changes by building the provider locally and testing it out against a boundary dev instance.

@ddebko ddebko requested review from johanbrandhorst, louisruch and tmessi and removed request for louisruch October 17, 2022 15:54
internal/provider/resource_group.go Outdated Show resolved Hide resolved
internal/provider/resource_group.go Outdated Show resolved Hide resolved
@ddebko ddebko force-pushed the ddebko-fix-state branch 2 times, most recently from 4bed53b to 153c317 Compare October 17, 2022 18:19
Copy link
Contributor

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

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

😅

internal/provider/resource_role.go Outdated Show resolved Hide resolved
Copy link
Contributor

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

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

It's beautiful :it's-so-beautiful:

@ddebko ddebko merged commit f95954c into main Oct 18, 2022
@ddebko ddebko deleted the ddebko-fix-state branch October 18, 2022 05:00
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.

2 participants