Skip to content
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

feat(config): Accept durations given in days (e.g. "7d") #12579

Merged
merged 1 commit into from
Feb 16, 2023

Conversation

srebhan
Copy link
Contributor

@srebhan srebhan commented Jan 31, 2023

This PR allows to specify duration in days. This is e.g. helpful for logfile rotation or other long-running tasks or intervals.

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Jan 31, 2023
@srebhan srebhan requested a review from Hipska January 31, 2023 18:57
Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings on this.

On one hand, I acknowledge that it is nice for some config options. On the other hand it has never worked before now, we produce an error currently, and it is not a valid option with time.Duration and I do not like having two different behaviors.

I will approve, but just note the above.

edit: I restarted mac test as it seemed to have timed out.

@telegraf-tiger
Copy link
Contributor

Copy link
Contributor

@Hipska Hipska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be much simpler by using fmt.Scanf?

On one hand, I acknowledge that it is nice for some config options. On the other hand it has never worked before now, we produce an error currently, and it is not a valid option with time.Duration and I do not like having two different behaviors.

It was discussed on the maintainers meeting of 2022-12-20. Granted, you weren't there, but my idea was to support this for now, but with a deprecation warning given the following facts:

  • Never worked, started to give errors in 1.22.0 (May 2022)
  • Suggested as default value (0d) until 1.22.1 (April 2022)

So my idea is to remove this 'functionality' again after the deprecation and moving to new version with breaking changes..

Comment on lines +98 to +99
"3d7d",
"15m8h3.5d"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these formats should be supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Golang's ParseDuration supports them, so why shouldn't we?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes it more complex and was only intended to be a temporary workaround.. Or do you think differently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I do think differently as I do not think this is in any way more complex than the other features. If the code change is too complex in your view, we should completely drop the feature as it won't become any simpler...

Copy link
Contributor

@Hipska Hipska Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, never mind then.

But do add depreciation warnings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or aren't we going to deprecate it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see what we do deprecate.... 0d is explicitly supported in the code and the remaining never worked. So either we add this or leave the stuff with an (overdue) error...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole idea was initially to support it, but immediately deprecate it so it can be removed in next major version.

Its fine for me to not deprecate it and keep it working, but then the docs need to be updated.

Copy link
Contributor

@Hipska Hipska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update documentation or add deprecation warning.

Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in the past, duration with days would not error, but effectively would not be applied. I made duration with days an error, a few releases ago. This PR would allow them to actually work. I do not see us adding support and then immediately deprecating something that is already throwing an error.

Approving this and adding it is effectively a new feature to allow day based timestamps, and while it is not officially supported upstream is a convienince thing.

@powersj powersj merged commit 9dfbbb2 into influxdata:master Feb 16, 2023
@Hipska
Copy link
Contributor

Hipska commented Feb 21, 2023

@powersj you merged, but documentation is still not updated..

@srebhan srebhan added this to the v1.26.0 milestone Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants