Skip to content

Commit 9316874

Browse files
authored
Customize refresh interval of WaitForControlledPodsRunning measurement (#10)
1 parent 3475690 commit 9316874

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

clusterloader2/pkg/measurement/common/wait_for_controlled_pods.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import (
5050
const (
5151
defaultSyncTimeout = 60 * time.Second
5252
defaultOperationTimeout = 10 * time.Minute
53-
checkControlledPodsInterval = 5 * time.Second
53+
defaultRefreshInterval = 5 * time.Second
5454
informerSyncTimeout = time.Minute
5555
waitForControlledPodsRunningName = "WaitForControlledPodsRunning"
5656

@@ -216,11 +216,15 @@ func (w *waitForControlledPodsRunningMeasurement) Execute(config *measurement.Co
216216
}
217217
return nil, w.start()
218218
case "gather":
219+
refreshInterval, err := util.GetDurationOrDefault(config.Params, "refreshInterval", defaultRefreshInterval)
220+
if err != nil {
221+
return nil, err
222+
}
219223
syncTimeout, err := util.GetDurationOrDefault(config.Params, "syncTimeout", defaultSyncTimeout)
220224
if err != nil {
221225
return nil, err
222226
}
223-
ps, err := w.gather(syncTimeout)
227+
ps, err := w.gather(refreshInterval, syncTimeout)
224228
summary := createSummary(ps)
225229
return summary, err
226230
case "stop":
@@ -284,7 +288,7 @@ func (w *waitForControlledPodsRunningMeasurement) start() error {
284288
return informer.StartAndSync(i, w.stopCh, informerSyncTimeout)
285289
}
286290

287-
func (w *waitForControlledPodsRunningMeasurement) gather(syncTimeout time.Duration) ([]failedPod, error) {
291+
func (w *waitForControlledPodsRunningMeasurement) gather(refreshInterval time.Duration, syncTimeout time.Duration) ([]failedPod, error) {
288292
klog.V(2).Infof("%v: waiting for controlled pods measurement...", w)
289293
if !w.isRunning {
290294
return nil, fmt.Errorf("metric %s has not been started", w)
@@ -315,7 +319,7 @@ func (w *waitForControlledPodsRunningMeasurement) gather(syncTimeout time.Durati
315319
defer w.lock.Unlock()
316320
return w.opResourceVersion >= maxResourceVersion && objectKeys.Equal(w.objectKeys), nil
317321
}
318-
if err := wait.Poll(checkControlledPodsInterval, syncTimeout, cond); err != nil {
322+
if err := wait.Poll(refreshInterval, syncTimeout, cond); err != nil {
319323
return nil, fmt.Errorf("timed out while waiting for controlled pods: %v", err)
320324
}
321325

0 commit comments

Comments
 (0)