Comments (8)
@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.
@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.
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.
@apparentlymart, sorry forgot to link it -- serialization fixed in hashicorp/terraform#7091
from terraform-plugin-sdk.
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.
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.
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.
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)
- Behaviour of `terraform providers schema` command for computed fields HOT 4
- `diff.GetOk` return `nil` for the value of `TypeList` defined in `TypeSet` HOT 1
- Not Helpful Err When Running Tests For Provider HOT 4
- Unsupported Field Type for Resource
- TypeSet resource wanting to destroy and recreate everything when diff is found HOT 2
- losing precision when using maximum value for a 64-bit signed integer
- helper/schema: Provide Functionality to Reduce Resident Memory Usage from Schemas HOT 1
- Consider Method for Disabling Legacy SDK Data Consistency Warning Log Demotion HOT 7
- Updates for Protocol Version 5.4 HOT 1
- Value out of range on 32-bit architecture HOT 3
- Update Go Module to Go 1.20 Minimum HOT 1
- `Schema.Set` adds an empty value when attempting to Patch HOT 1
- `meta.SDKVersion` reporting incorrect version HOT 6
- Terraform CloudFormation Multi Region Stacksets HOT 3
- Is it possible to have a dependency between 2 attributes? HOT 2
- `schema.ResourceData.GetRaw<whatever>()` not populated during provider configuration HOT 3
- Consider Migrating from mitchellh/mapstructure to go-viper/mapstructure
- Low performance in deduplicate strings function HOT 4
- ForceNew doesn't trigger resource recreation when defined on TypeSet, which leads to Update error HOT 1
- helper/resource: Add Go Deprecation Messages That Point To terraform-plugin-testing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-plugin-sdk.