// StartOnce starts pod volume calc that will occur periodically in the background until s.StopOnce is called func (s *volumeStatCalculator) StartOnce() *volumeStatCalculator { s.startO.Do(func() { go wait.JitterUntil(func() { s.calcAndStoreStats() }, s.jitterPeriod, 1.0, true, s.stopChannel) }) return s }
// acquire loops calling tryAcquireOrRenew and returns immediately when tryAcquireOrRenew succeeds. func (le *LeaderElector) acquire() { stop := make(chan struct{}) glog.Infof("attempting to acquire leader lease...") wait.JitterUntil(func() { succeeded := le.tryAcquireOrRenew() le.maybeReportTransition() desc := le.config.Lock.Describe() if !succeeded { glog.V(4).Infof("failed to acquire lease %v", desc) return } le.config.Lock.RecordEvent("became leader") glog.Infof("successfully acquired lease %v", desc) close(stop) }, le.config.RetryPeriod, JitterFactor, true, stop) }