Skip to content

Setting deterministic encoding id output, just sorting the keys #303

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

Merged
merged 2 commits into from
Sep 16, 2020

Conversation

leofigy
Copy link
Contributor

@leofigy leofigy commented Sep 2, 2020

Description

behaviour found by Edgar, sometimes the encodeStateID function generates a different ID with the same input.
This is given it encodes iterating over a map, and maps are unordered, the iteration sequence is not ensure.

So quick fix, sort the keys and access in that way to encode the ID.

Link to any related issue(s):

Type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the Terraform contribution guidelines
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirments
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code

Further comments

@coderGo93
Copy link
Contributor

Hi, I tried myself with cmd make testacc it seem It didn't fail with state error related, could you delete the func SkipTestImport so it can try in github actions and see if it really works, @leofigy ?

@leofigy
Copy link
Contributor Author

leofigy commented Sep 8, 2020

Sure, let me do the update :)

@gssbzn
Copy link
Collaborator

gssbzn commented Sep 8, 2020

Please don't forget to sign our CLA https://www.mongodb.com/legal/contributor-agreement

@leofigy
Copy link
Contributor Author

leofigy commented Sep 10, 2020

Hi @coderGo93 removed the skipImportTest function, and it worked, previous execution failed with the capacity error, but that's independent

@coderGo93
Copy link
Contributor

@leofigy Thank you so much, indeed there are not errors about import state id or related, if there are similar error about capacity, probably need to change the region to US_EAST_1 or the config using a project created, but not sure if that changes should be made in this PR or another PR @themantissa .

@themantissa
Copy link
Collaborator

@coderGo93 let's do that work, fix any tests not using larger regions and ensure existing project/new project is use to avoid conflicts, in another PR. We can create a Jira ticket for it and then schedule some time.

Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

LGTM! Please have Abraham create a ticket for the work noted but not yet covered to fix tests.

Copy link
Contributor

@coderGo93 coderGo93 left a comment

Choose a reason for hiding this comment

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

LGTM

@leofigy leofigy merged commit c2e1d51 into master Sep 16, 2020
@leofigy leofigy deleted the encode-order branch September 22, 2020 00:46
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.

4 participants