Skip to content

Commit 31e741a

Browse files
author
Ben Reed
committed
Use WatcherOptions pointer in ControllerOptions
Previously, the ControllerOptions struct copied a field from the WatcherOptions struct, leading to duplicated logic. This change adds a pointer to WatcherOptions in the ControllerOptions. This allows the watcher's options to be handled in one place.
1 parent a61fb21 commit 31e741a

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

testctrl/svc/orch/controller.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ type ControllerOptions struct {
5555
// processed at a time. It defaults to 1, disabling concurrent sessions.
5656
ExecutorCount int
5757

58-
// WatchEventBufferSize specifies the size of the buffered channel for
59-
// each channel the watcher creates. It allows the watcher to write
60-
// additional kubernetes events without blocking for reads. It defaults
61-
// to 32 events.
62-
WatchEventBufferSize int
58+
// WatcherOptions overrides the defaults of the watcher. The watcher
59+
// listens for Kubernetes events and reports the health of components
60+
// to the session's executor.
61+
WatcherOptions *WatcherOptions
6362

6463
// TestTimeout is the maximum duration to wait for component containers
6564
// to provision and terminate with a successful exit code. If this
@@ -97,21 +96,14 @@ func NewController(clientset kubernetes.Interface, store store.Store, options *C
9796
executorCount = 1
9897
}
9998

100-
watcherOpts := &WatcherOptions{
101-
EventBufferSize: opts.WatchEventBufferSize,
102-
}
103-
if watcherOpts.EventBufferSize == 0 {
104-
watcherOpts.EventBufferSize = 32
105-
}
106-
10799
coreV1Interface := clientset.CoreV1()
108100
podInterface := coreV1Interface.Pods(corev1.NamespaceDefault)
109101

110102
c := &Controller{
111103
pcd: podInterface,
112104
pw: podInterface,
113105
nl: coreV1Interface.Nodes(),
114-
watcher: NewWatcher(podInterface, watcherOpts),
106+
watcher: NewWatcher(podInterface, opts.WatcherOptions),
115107
store: store,
116108
executorCount: executorCount,
117109
testTimeout: opts.TestTimeout,

0 commit comments

Comments
 (0)