Skip to content

Commit

Permalink
pass CNINode scheme to client only (#2570)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdn5126 authored Sep 19, 2023
1 parent c7729e0 commit 879363d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/k8sapi/k8sutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion test/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down

0 comments on commit 879363d

Please sign in to comment.