From 879363dbed409d090e023a38ee83927b3b7ed499 Mon Sep 17 00:00:00 2001 From: Jeffrey Nelson Date: Tue, 19 Sep 2023 11:22:00 -0500 Subject: [PATCH] pass CNINode scheme to client only (#2570) --- pkg/k8sapi/k8sutils.go | 4 +++- test/framework/framework.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/k8sapi/k8sutils.go b/pkg/k8sapi/k8sutils.go index 9861e6ac44..8d606e0b2b 100644 --- a/pkg/k8sapi/k8sutils.go +++ b/pkg/k8sapi/k8sutils.go @@ -96,7 +96,6 @@ func CreateKubeClient(appName string) (client.Client, error) { vpcCniScheme := runtime.NewScheme() corev1.AddToScheme(vpcCniScheme) eniconfigscheme.AddToScheme(vpcCniScheme) - rcscheme.AddToScheme(vpcCniScheme) var filterMap map[client.Object]cache.ByObject if appName == awsNode { @@ -111,6 +110,9 @@ func CreateKubeClient(appName string) (client.Client, error) { // Start cache and wait for initial sync StartKubeClientCache(cacheReader) + // The cache will start a WATCH for all GVKs in the scheme. CNINode objects should not + // be cached, so their GVK is added only for the client. + rcscheme.AddToScheme(vpcCniScheme) k8sClient, err := client.New(restCfg, client.Options{ Cache: &client.CacheOptions{ Reader: cacheReader, diff --git a/test/framework/framework.go b/test/framework/framework.go index 0988354f65..d114e101f1 100644 --- a/test/framework/framework.go +++ b/test/framework/framework.go @@ -61,7 +61,6 @@ func New(options Options) *Framework { clientgoscheme.AddToScheme(k8sSchema) eniconfigscheme.AddToScheme(k8sSchema) sgpscheme.AddToScheme(k8sSchema) - rcscheme.AddToScheme(k8sSchema) cache, err := k8sapi.CreateKubeClientCache(config, k8sSchema, nil) if err != nil { @@ -84,6 +83,9 @@ func New(options Options) *Framework { // Start cache and wait for initial sync k8sapi.StartKubeClientCache(cache) + // The cache will start a WATCH for all GVKs in the scheme. CNINode objects should not + // be cached, so their GVK is added only for the client. + rcscheme.AddToScheme(k8sSchema) k8sClient, err := client.New(config, client.Options{ Cache: &client.CacheOptions{ Reader: cache,