Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Use non-zero resync period as last insurance in local volume provisioner #800

Merged
merged 1 commit into from
Jun 19, 2018

Conversation

cofyc
Copy link
Contributor

@cofyc cofyc commented Jun 14, 2018

Fixes #795.

  • Add MinResyncPeriod configuration, defaults: 5m0s.
  • Update JobController to use default resync period.
  • Test TestLoadProvisionerConfigs with real cases.
  • Add example for customizing resync period.
  • Update test/run.sh to fail on errors.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 14, 2018
@cofyc
Copy link
Contributor Author

cofyc commented Jun 14, 2018

/area local-volume
/assign @msau42

// We choose a random resync period between MinResyncPeriod and 2 *
// MinResyncPeriod, so that local provisioners deployed on multiple nodes
// at same time don't list the apiserver simultaneously.
resyncPeriod := time.Duration(float64(config.MinResyncPeriod.Nanoseconds()) * (1 + rand.Float64()))
Copy link
Contributor

Choose a reason for hiding this comment

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

The final value should be multiplied by time.Nanosecond. Also, do we really need Nanosecond granularlity? I think probably Seconds should be sufficient.

Copy link
Contributor Author

@cofyc cofyc Jun 15, 2018

Choose a reason for hiding this comment

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

Fixed in e45ee19. Also initialized default source in main.go.

@@ -53,7 +53,7 @@ func StartLocalController(client *kubernetes.Clientset, ptable deleter.ProcTable
// We choose a random resync period between MinResyncPeriod and 2 *
// MinResyncPeriod, so that local provisioners deployed on multiple nodes
// at same time don't list the apiserver simultaneously.
resyncPeriod := time.Duration(float64(config.MinResyncPeriod.Nanoseconds()) * (1 + rand.Float64()))
resyncPeriod := time.Duration(config.MinResyncPeriod.Seconds()*(1+rand.Float64())) * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if you don't cast it to float64 like before, then you don't need to multiple by time.Second at the end.

Copy link
Contributor Author

@cofyc cofyc Jun 16, 2018

Choose a reason for hiding this comment

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

Seconds() method divides it by time.Second to get number of seconds, so we need to multiple by time.Second at the end. time.Duration is int64 in nanoseconds, so we don't need to multiple by time.Nanosecond if we use Nanoseconds().

Demo: https://play.golang.org/p/taL1ywwQ1wt

@@ -43,6 +44,7 @@ var (
)

func main() {
rand.Seed(time.Now().UTC().UnixNano())
Copy link
Contributor

Choose a reason for hiding this comment

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

This may be causing mac osx build to fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

helm install script, fixed in #806.

@cofyc
Copy link
Contributor Author

cofyc commented Jun 16, 2018

Rebased due to conflicts with #799.

- Add `MinResyncPeriod` configuration, defaults: 5m0s.
- Update JobController to use default resync period.
- Test `TestLoadProvisionerConfigs ` with real cases.
- Add example for customizing resync period.
- Update test/run.sh to fail on errors.
- Initialize rand default source on startup.
@msau42
Copy link
Contributor

msau42 commented Jun 18, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 18, 2018
@wongma7 wongma7 merged commit 2d6258a into kubernetes-retired:master Jun 19, 2018
@cofyc cofyc deleted the resyncperiod branch June 20, 2018 03:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/local-volume cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants