-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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 resource.UniqueId to be properly ordered #10152
Conversation
c8d5eb4
to
8795ee4
Compare
UniqueId attempted to provide an ordered unique id by using a nanosecond timestamp, but doesn't take into account that time is not monotonic increasing. This provides an implementation that will always be increasing.
8795ee4
to
e28e11d
Compare
I know this was a while ago, but I only noticed it recently. The goal of introducing the timestamp (see #8143 and #8249) was less about getting ordering between resources created in a single invocation of For example, when creating a new AWS ASG and moving instances slowly from the old one to the new one, I wanted to be able to easily see "this is the old one, this is the new one". It also makes it immediately obvious "I made this ASG about two weeks ago" which is helpful. So we've moved from "purely random" to "mostly ordered and indicates the general time when something started, with random prefix" to "consistent within a single TF iteration but otherwise not helpful". Would you accept a PR that restored the timestamp prefix but with an incrementing suffix? |
The timestamp prefix added in hashicorp#8249 was removed in hashicorp#10152 to ensure that returned IDs really are properly ordered. However, this meant that IDs were no longer ordered over multiple invocations of terraform, which was the main motivation for adding the timestamp in the first place. This commit does a hybrid: timestamp-plus-incrementing-counter instead of just incrementing counter or timestamp-plus-random.
The timestamp prefix added in hashicorp#8249 was removed in hashicorp#10152 to ensure that returned IDs really are properly ordered. However, this meant that IDs were no longer ordered over multiple invocations of terraform, which was the main motivation for adding the timestamp in the first place. This commit does a hybrid: timestamp-plus-incrementing-counter instead of just incrementing counter or timestamp-plus-random.
The timestamp prefix added in hashicorp#8249 was removed in hashicorp#10152 to ensure that returned IDs really are properly ordered. However, this meant that IDs were no longer ordered over multiple invocations of terraform, which was the main motivation for adding the timestamp in the first place. This commit does a hybrid: timestamp-plus-incrementing-counter instead of just incrementing counter or timestamp-plus-random.
The timestamp prefix added in hashicorp#8249 was removed in hashicorp#10152 to ensure that returned IDs really are properly ordered. However, this meant that IDs were no longer ordered over multiple invocations of terraform, which was the main motivation for adding the timestamp in the first place. This commit does a hybrid: timestamp-plus-incrementing-counter instead of just incrementing counter or timestamp-plus-random.
The timestamp prefix added in hashicorp#8249 was removed in hashicorp#10152 to ensure that returned IDs really are properly ordered. However, this meant that IDs were no longer ordered over multiple invocations of terraform, which was the main motivation for adding the timestamp in the first place. This commit does a hybrid: timestamp-plus-incrementing-counter instead of just incrementing counter or timestamp-plus-random.
The timestamp prefix added in hashicorp#8249 was removed in hashicorp#10152 to ensure that returned IDs really are properly ordered. However, this meant that IDs were no longer ordered over multiple invocations of terraform, which was the main motivation for adding the timestamp in the first place. This commit does a hybrid: timestamp-plus-incrementing-counter instead of just incrementing counter or timestamp-plus-random.
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. |
This isn't a major issue, and probably never encountered in real usage, but I was tired of my unit tests failing because time was used as a counter.
UniqueId
attempted to provide an ordered unique id by using a nanosecondtimestamp, but doesn't take into account that time is not monotonic
increasing, nor do many system clocks have the resolution to return different times
when called in quick succession. This provides an implementation that will always be
increasing.