[DRAFT] Rewrite Rotation Logic in time_rotating
#180
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
time_rotating
resource currently triggers a "rotation" by comparing the current time torotation_rfc3339
and if the current time is afterrotation_rfc3339
it will remove the resource in theread
method.The
rotation_rfc3339
is currently set in three different ways:rotation_rfc3339
attributerfc3339
and at least one configuredrotation_
attribute to be added to the baserfc3339
rotation_
attribute to be added to therfc3339
which is computed to the current timeThe current implementation has several issues:
read
method and creating it again increate
is a different behavior than triggering a recreate by settingrequiresReplace
. Use of thedepends_on
meta argument on thetime_rotating
resource or it's attributes does not properly trigger a replacement of another resource or data sourcerfc3339
orrotation_rfc3339
is set in the configuration and the time has expired and the resource is removed inread
and created again. Every subsequent plan will prompt a resource creation but the state does not change.rfc3339
orrotation_rfc3339
is set, then the "rotation" will only happen once. Once the time has expired for the first "rotation", therotation_rfc3339
will not change unless there is a configuration change.As a rough implementation to solve these issues, this draft PR:
read
method and into theplanModifier
method.rfc3339
is set in the configuration. The recalculated rotation value will be set to the current time plus any additionalrotation_
values in the configuration.id
to store any new rotation value and change the time expiration logic to compare against theid
attribute instead ofrotation_rfc3339
, to prevent errors when recalculating the rotation sincerotation_rfc3339
is aComputed
+Optional
attribute.This is a very rough draft of an implementation as there are many edge case and further design decisions to be made, but this solution does solve the problems outlined above.