From 33bc765f99d69aa20db258e470f3a7a7032ca006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Tue, 19 May 2026 11:33:52 +0400 Subject: [PATCH] fix(storagesvc): scan all namespaces in archivePruner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DefaultNSResolver().Snapshot() returns only namespaces registered via AddNamespace(). Storagesvc does not listen to namespace events, so tenant namespaces (fission-*) are never registered and their Package CRDs are invisible to the pruner — causing all archives to be treated as orphans and deleted. Fix: use metav1.NamespaceAll to list Packages across all namespaces. Remove unused pkg/utils import. Deployed as naeel/fission-bundle:v1.23.1 --- pkg/storagesvc/archivePruner.go | 55 ++++++++++++++++----------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/pkg/storagesvc/archivePruner.go b/pkg/storagesvc/archivePruner.go index 56a9ad0e..63c22995 100644 --- a/pkg/storagesvc/archivePruner.go +++ b/pkg/storagesvc/archivePruner.go @@ -26,7 +26,6 @@ import ( "github.com/fission/fission/pkg/crd" "github.com/fission/fission/pkg/generated/clientset/versioned" - "github.com/fission/fission/pkg/utils" "github.com/fission/fission/pkg/utils/manager" ) @@ -91,36 +90,36 @@ func (pruner *ArchivePruner) getOrphanArchives(ctx context.Context) { archivesRefByPkgs := make([]string, 0) var archiveID string - // get all pkgs from kubernetes - for _, namespace := range utils.DefaultNSResolver().Snapshot() { - pkgList, err := pruner.crdClient.CoreV1().Packages(namespace).List(ctx, metav1.ListOptions{}) - if err != nil { - pruner.logger.Error("error getting package list from kubernetes", zap.Error(err)) - return - } + // get all pkgs from kubernetes across ALL namespaces (including tenant namespaces) + // Fix: DefaultNSResolver().Snapshot() returns only fission-registered namespaces, + // not tenant namespaces (fission-*). Use NamespaceAll to scan everything. + pkgList, err := pruner.crdClient.CoreV1().Packages(metav1.NamespaceAll).List(ctx, metav1.ListOptions{}) + if err != nil { + pruner.logger.Error("error getting package list from kubernetes", zap.Error(err)) + return + } - // extract archives referenced by these pkgs - for _, pkg := range pkgList.Items { - if pkg.Spec.Deployment.URL != "" { - archiveID, err = getQueryParamValue(pkg.Spec.Deployment.URL, "id") - if err != nil { - pruner.logger.Error("error extracting value of archiveID from deployment url", - zap.Error(err), - zap.String("url", pkg.Spec.Deployment.URL)) - return - } - archivesRefByPkgs = append(archivesRefByPkgs, archiveID) + // extract archives referenced by these pkgs + for _, pkg := range pkgList.Items { + if pkg.Spec.Deployment.URL != "" { + archiveID, err = getQueryParamValue(pkg.Spec.Deployment.URL, "id") + if err != nil { + pruner.logger.Error("error extracting value of archiveID from deployment url", + zap.Error(err), + zap.String("url", pkg.Spec.Deployment.URL)) + return } - if pkg.Spec.Source.URL != "" { - archiveID, err = getQueryParamValue(pkg.Spec.Source.URL, "id") - if err != nil { - pruner.logger.Error("error extracting value of archiveID from source url", - zap.Error(err), - zap.String("url", pkg.Spec.Source.URL)) - return - } - archivesRefByPkgs = append(archivesRefByPkgs, archiveID) + archivesRefByPkgs = append(archivesRefByPkgs, archiveID) + } + if pkg.Spec.Source.URL != "" { + archiveID, err = getQueryParamValue(pkg.Spec.Source.URL, "id") + if err != nil { + pruner.logger.Error("error extracting value of archiveID from source url", + zap.Error(err), + zap.String("url", pkg.Spec.Source.URL)) + return } + archivesRefByPkgs = append(archivesRefByPkgs, archiveID) } }