Skip to content

Commit 4f4a18d

Browse files
committed
Add SharedInformerOption to the VolumePopulatorConfig
1 parent 20ae37d commit 4f4a18d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

populator-machinery/controller.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ type VolumePopulatorConfig struct {
150150
// CrossNamespace indicates if the populator supports data sources located in namespaces different than the PVC's namespace.
151151
// This feature is alpha and requires the populator machinery to process gateway.networking.k8s.io/v1beta1.ReferenceGrant objects
152152
CrossNamespace bool
153+
// SharedInformerOptions is an array of SharedInformerOption. This can be provided when the volume populator shared informers are created,
154+
// to allow for customization of the informer options. If unset, no additional SharedInformerOption is set when creating the shared informers.
155+
//
156+
// This is an advanced feature, specifically added as a parameter for memory management, and can be used by users that require greater access to the
157+
// machinery of the volume populator library. It is the client's responsibility to ensure that if they are using functionality that limits
158+
// resources or limits fields stored in the informer cache, they are responsible for ensuring that this is compatible with the library
159+
// implementation they are using.
160+
SharedInformerOptions []kubeinformers.SharedInformerOption
153161
// StopCh is an optional channel you can provide to override the controller's default internal stop channel. In either case, sending
154162
// an os.Interrupt or syscall.SIGTERM signal will initiate a graceful shutdown of the controller, by closing the stop channel
155163
// (whichever one is used). If the graceful shutdown fails (a second signal is received), the controller will abruptly exit with a
@@ -273,7 +281,7 @@ func RunControllerWithConfig(vpcfg VolumePopulatorConfig) {
273281
klog.Fatalf("Failed to create gateway client: %v", err)
274282
}
275283

276-
kubeInformerFactory := kubeinformers.NewSharedInformerFactory(kubeClient, time.Second*30)
284+
kubeInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions(kubeClient, time.Second*30, vpcfg.SharedInformerOptions...)
277285
dynInformerFactory := dynamicinformer.NewDynamicSharedInformerFactory(dynClient, time.Second*30)
278286

279287
pvcInformer := kubeInformerFactory.Core().V1().PersistentVolumeClaims()

populator-machinery/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func initTest(test testCase) (
288288
dynClient := dynamicfake.NewSimpleDynamicClient(runtime.NewScheme())
289289
gatewayClient := gatewayfake.NewSimpleClientset()
290290

291-
kubeInformerFactory := kubeinformers.NewSharedInformerFactory(kubeClient, time.Second*30)
291+
kubeInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions(kubeClient, time.Second*30)
292292
dynInformerFactory := dynamicinformer.NewDynamicSharedInformerFactory(dynClient, time.Second*30)
293293

294294
pvcInformer := kubeInformerFactory.Core().V1().PersistentVolumeClaims()

0 commit comments

Comments
 (0)