Git Product home page Git Product logo

Comments (8)

apparentlymart avatar apparentlymart commented on June 1, 2024

@jbardin in hashicorp/terraform#3018 we added a default hashing function for sets that always includes all of the attributes. Do you think using that would solve the problem here?

We didn't go back and switch all the existing set users to use this default implementation because doing so requires migrating the existing state data to the new hashes in order to avoid spurious diffs after a Terraform upgrade. However, it is possible to do this and we've done it at least once. (It's also necessary to migrate each time a new attribute is added even after switching to the default implementation, since of course that too will change the hash... but I think we've not always bothered with this in cases where the diff doesn't force a new resource.)

(Sorry if I'm misunderstanding what you're reporting here.)

from terraform-plugin-sdk.

jbardin avatar jbardin commented on June 1, 2024

@apparentlymart: I ended up here after patching a crash in that default hashing function ;)

My first instinct was to use the default to hash all fields, but that doesn't work with any computed fields. If the hash of the config and the hash from the read phase don't match, they are considered 2 different values at 2 different paths. I started writing some special-case code to merge the difference for the common instance where a set can only contain 1 value, but that got really ugly and it would be nice to fix the complete set case like the ebs_block_device example.

from terraform-plugin-sdk.

apparentlymart avatar apparentlymart commented on June 1, 2024

Computed fields always pose an interesting challenge for sets, indeed... Terraform core tries to work around this in a few places, but I guess it's not perfect.

If that crash you found hasn't already been fixed it'd be nice to know more about it so we can fix it, since it's not supposed to crash. :)

from terraform-plugin-sdk.

jbardin avatar jbardin commented on June 1, 2024

@apparentlymart, sorry forgot to link it -- serialization fixed in hashicorp/terraform#7091

from terraform-plugin-sdk.

magodo avatar magodo commented on June 1, 2024

Adding only the fields mutable within the config to the hash value also doesn't work, because the new hash value still creates a new set in the diff, which will trigger the ForceNew for all the remaining fields.

Hi @jbardin

Why does the new hash is different from the current hash given the mutable fields are not modified?

Plus, does this issue still existed in current sdk?

from terraform-plugin-sdk.

paultyng avatar paultyng commented on June 1, 2024

I don't think this is still an issue and not sure what work needs to be done as its pretty old/dated. Are you experiencing a specific issue in sets/hashing?

from terraform-plugin-sdk.

jbardin avatar jbardin commented on June 1, 2024

Nope, this is long out of date, and I had since forgotten it was still open. We now have a defined behavior in cty.Set, and should base sdk changes of of that.

from terraform-plugin-sdk.

 avatar commented on June 1, 2024

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.

from terraform-plugin-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.