Skip to content

Commit 5ca07ab

Browse files
committed
fix
Signed-off-by: upsaurav12 <sauravup041103@gmail.com> fix: removed println Signed-off-by: upsaurav12 <sauravup041103@gmail.com>
1 parent 6080174 commit 5ca07ab

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

backend/pkg/k8cache/cacheInvalidation.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff 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.

0 commit comments

Comments
 (0)