List Fission resource for specific namespace in executor reaper (#2587)

* pool manager to work with specific namespaces

* code review changes and revert changes for go.mod and values.yaml file
This commit is contained in:
Shubham Bansal
2022-10-28 20:39:08 +05:30
committed by GitHub
parent dbd2153181
commit 47cbbef06f
+18 -15
View File
@@ -583,26 +583,29 @@ func (gpm *GenericPoolManager) idleObjectReaper(ctx context.Context) {
} }
func (gpm *GenericPoolManager) doIdleObjectReaper(ctx context.Context) { func (gpm *GenericPoolManager) doIdleObjectReaper(ctx context.Context) {
envs, err := gpm.fissionClient.CoreV1().Environments(metav1.NamespaceAll).List(ctx, metav1.ListOptions{})
if err != nil {
gpm.logger.Error("failed to get environment list", zap.Error(err))
return
}
envList := make(map[k8sTypes.UID]struct{}) envList := make(map[k8sTypes.UID]struct{})
for _, env := range envs.Items { for _, namespace := range utils.GetNamespaces() {
envList[env.ObjectMeta.UID] = struct{}{} envs, err := gpm.fissionClient.CoreV1().Environments(namespace).List(ctx, metav1.ListOptions{})
} if err != nil {
gpm.logger.Error("failed to get environment list", zap.Error(err), zap.String("namespace", namespace))
return
}
fns, err := gpm.fissionClient.CoreV1().Functions(metav1.NamespaceAll).List(ctx, metav1.ListOptions{}) for _, env := range envs.Items {
if err != nil { envList[env.ObjectMeta.UID] = struct{}{}
gpm.logger.Error("failed to get environment list", zap.Error(err)) }
return
} }
fnList := make(map[k8sTypes.UID]fv1.Function) fnList := make(map[k8sTypes.UID]fv1.Function)
for i, fn := range fns.Items { for _, namespace := range utils.GetNamespaces() {
fnList[fn.ObjectMeta.UID] = fns.Items[i] fns, err := gpm.fissionClient.CoreV1().Functions(namespace).List(ctx, metav1.ListOptions{})
if err != nil {
gpm.logger.Error("failed to get environment list", zap.Error(err), zap.String("namespace", namespace))
return
}
for i, fn := range fns.Items {
fnList[fn.ObjectMeta.UID] = fns.Items[i]
}
} }
funcSvcs, err := gpm.fsCache.ListOldForPool(time.Second * 5) funcSvcs, err := gpm.fsCache.ListOldForPool(time.Second * 5)