[DRAFT] Rewrite Rotation Logic in time_rotating#180
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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_rotatingresource currently triggers a "rotation" by comparing the current time torotation_rfc3339and if the current time is afterrotation_rfc3339it will remove the resource in thereadmethod.The
rotation_rfc3339is currently set in three different ways:rotation_rfc3339attributerfc3339and at least one configuredrotation_attribute to be added to the baserfc3339rotation_attribute to be added to therfc3339which is computed to the current timeThe current implementation has several issues:
readmethod and creating it again increateis a different behavior than triggering a recreate by settingrequiresReplace. Use of thedepends_onmeta argument on thetime_rotatingresource or it's attributes does not properly trigger a replacement of another resource or data sourcerfc3339orrotation_rfc3339is set in the configuration and the time has expired and the resource is removed inreadand created again. Every subsequent plan will prompt a resource creation but the state does not change.rfc3339orrotation_rfc3339is set, then the "rotation" will only happen once. Once the time has expired for the first "rotation", therotation_rfc3339will not change unless there is a configuration change.As a rough implementation to solve these issues, this draft PR:
readmethod and into theplanModifiermethod.rfc3339is set in the configuration. The recalculated rotation value will be set to the current time plus any additionalrotation_values in the configuration.idto store any new rotation value and change the time expiration logic to compare against theidattribute instead ofrotation_rfc3339, to prevent errors when recalculating the rotation sincerotation_rfc3339is aComputed+Optionalattribute.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.