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

state/remote/atlas: handle conflicts on equivalent states #3603

Merged
merged 1 commit into from
Oct 22, 2015

Conversation

phinze
Copy link
Contributor

@phinze phinze commented Oct 22, 2015

Atlas returns an HTTP 409 - Conflict if the pushed state reports the same
Serial number but the checksum of the raw content differs. This can
sometimes happen when Terraform changes state representation internally
between versions in a way that's semantically neutral but affects the JSON
output and therefore the checksum.

Here we detect and handle this situation by ticking the serial and retrying
iff for the previous state and the proposed state:

  • the serials match
  • the parsed states are Equal (semantically equivalent)

In other words, in this situation Terraform can override Atlas's detected
conflict by asserting that the state it is pushing is indeed correct.

@phinze phinze force-pushed the b-atlas-state-conflict-handling branch 2 times, most recently from 4cb4c9f to 5290fb3 Compare October 22, 2015 20:11
}

return fmt.Errorf(
"Atlas detected a state conflict.\n\nMessage: %s", c.readBody(resp.Body))
Copy link
Contributor

Choose a reason for hiding this comment

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

"remote state"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

@ryanuber
Copy link
Member

Left one comment, but this looks sound to me. Great tests too!

Atlas returns an HTTP 409 - Conflict if the pushed state reports the same
Serial number but the checksum of the raw content differs. This can
sometimes happen when Terraform changes state representation internally
between versions in a way that's semantically neutral but affects the JSON
output and therefore the checksum.

Here we detect and handle this situation by ticking the serial and retrying
iff for the previous state and the proposed state:

  * the serials match
  * the parsed states are Equal (semantically equivalent)

In other words, in this situation Terraform can override Atlas's detected
conflict by asserting that the state it is pushing is indeed correct.
@phinze phinze force-pushed the b-atlas-state-conflict-handling branch from 5290fb3 to 6aa5fdc Compare October 22, 2015 20:40
@phinze
Copy link
Contributor Author

phinze commented Oct 22, 2015

Addressed comments. 🚢

phinze added a commit that referenced this pull request Oct 22, 2015
state/remote/atlas: handle conflicts on equivalent states
@phinze phinze merged commit 6a8ae92 into master Oct 22, 2015
@phinze phinze deleted the b-atlas-state-conflict-handling branch October 22, 2015 20:51
@ghost
Copy link

ghost commented Apr 30, 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 and limited conversation to collaborators Apr 30, 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.

3 participants