Skip to content

Use Duration over int for resyncPeriod #420

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

Closed
olvesh opened this issue Aug 20, 2018 · 2 comments
Closed

Use Duration over int for resyncPeriod #420

olvesh opened this issue Aug 20, 2018 · 2 comments

Comments

@olvesh
Copy link

olvesh commented Aug 20, 2018

func Watch(apiVersion, kind, namespace string, resyncPeriod int) {
and
func NewInformer(resourcePluralName, namespace string, resourceClient dynamic.ResourceInterface, resyncPeriod int, c *metrics.Collector) Informer {

should use time.Duration for resyncPeriod rather than an int that gets multiplied by time.Second in NewInformer method:

resyncDuration := time.Duration(resyncPeriod) * time.Second

@olvesh
Copy link
Author

olvesh commented Aug 20, 2018

Say I want to do an operator syncing every hour, my instinct is to write:

resync := 60 * time.Minute

This little oversight will in this case cause the following differences:

=== RUN   Test
1 hours 0 minutes 0 seconds
33390 days 2 hours 40 minutes 26 seconds
--- PASS: Test (0.00s)
PASS

@hasbro17
Copy link
Contributor

@olvesh Closing this as it's a duplicate of #345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants