File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed
Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,43 @@ func returnGVRList(apiResourceLists []*metav1.APIResourceList) []schema.GroupVer
131131 }
132132 }
133133
134- return gvrList
134+ // filtering the gvrList to make sure spawning go routines for only important
135+ // resources which are required to be watched and cached,
136+ // this will help to reduce the performance issue and resource utilization.
137+ filtered := filterImportantResources (gvrList )
138+
139+ return filtered
140+ }
141+
142+ // filterImportantResources filters the provided list of GroupVersionResources to
143+ // include only those that are deemed important for caching and watching.
144+ // This helps reduce the number of resources we watch and cache,
145+ // improving performance and resource utilization.
146+ func filterImportantResources (gvrList []schema.GroupVersionResource ) []schema.GroupVersionResource {
147+ allowed := map [string ]struct {}{
148+ "pods" : {},
149+ "services" : {},
150+ "deployments" : {},
151+ "replicasets" : {},
152+ "statefulsets" : {},
153+ "daemonsets" : {},
154+ "nodes" : {},
155+ "configmaps" : {},
156+ "secrets" : {},
157+ "jobs" : {},
158+ "cronjobs" : {},
159+ }
160+
161+ filtered := make ([]schema.GroupVersionResource , 0 , len (allowed ))
162+
163+ for _ , gvr := range gvrList {
164+ if _ , ok := allowed [gvr .Resource ]; ok {
165+ filtered = append (filtered , gvr )
166+ }
167+ }
168+
169+ // return the filtered list of GroupVersionResources that are important for caching and watching
170+ return filtered
135171}
136172
137173// Corrected CheckForChanges.
You can’t perform that action at this time.
0 commit comments