fix(storagesvc): scan all namespaces in archivePruner

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
This commit is contained in:
“Naeel”
2026-05-19 11:33:52 +04:00
parent 7265985309
commit 33bc765f99
+27 -28
View File
@@ -26,7 +26,6 @@ import (
"github.com/fission/fission/pkg/crd" "github.com/fission/fission/pkg/crd"
"github.com/fission/fission/pkg/generated/clientset/versioned" "github.com/fission/fission/pkg/generated/clientset/versioned"
"github.com/fission/fission/pkg/utils"
"github.com/fission/fission/pkg/utils/manager" "github.com/fission/fission/pkg/utils/manager"
) )
@@ -91,36 +90,36 @@ func (pruner *ArchivePruner) getOrphanArchives(ctx context.Context) {
archivesRefByPkgs := make([]string, 0) archivesRefByPkgs := make([]string, 0)
var archiveID string var archiveID string
// get all pkgs from kubernetes // get all pkgs from kubernetes across ALL namespaces (including tenant namespaces)
for _, namespace := range utils.DefaultNSResolver().Snapshot() { // Fix: DefaultNSResolver().Snapshot() returns only fission-registered namespaces,
pkgList, err := pruner.crdClient.CoreV1().Packages(namespace).List(ctx, metav1.ListOptions{}) // not tenant namespaces (fission-*). Use NamespaceAll to scan everything.
if err != nil { pkgList, err := pruner.crdClient.CoreV1().Packages(metav1.NamespaceAll).List(ctx, metav1.ListOptions{})
pruner.logger.Error("error getting package list from kubernetes", zap.Error(err)) if err != nil {
return pruner.logger.Error("error getting package list from kubernetes", zap.Error(err))
} return
}
// extract archives referenced by these pkgs // extract archives referenced by these pkgs
for _, pkg := range pkgList.Items { for _, pkg := range pkgList.Items {
if pkg.Spec.Deployment.URL != "" { if pkg.Spec.Deployment.URL != "" {
archiveID, err = getQueryParamValue(pkg.Spec.Deployment.URL, "id") archiveID, err = getQueryParamValue(pkg.Spec.Deployment.URL, "id")
if err != nil { if err != nil {
pruner.logger.Error("error extracting value of archiveID from deployment url", pruner.logger.Error("error extracting value of archiveID from deployment url",
zap.Error(err), zap.Error(err),
zap.String("url", pkg.Spec.Deployment.URL)) zap.String("url", pkg.Spec.Deployment.URL))
return return
}
archivesRefByPkgs = append(archivesRefByPkgs, archiveID)
} }
if pkg.Spec.Source.URL != "" { archivesRefByPkgs = append(archivesRefByPkgs, archiveID)
archiveID, err = getQueryParamValue(pkg.Spec.Source.URL, "id") }
if err != nil { if pkg.Spec.Source.URL != "" {
pruner.logger.Error("error extracting value of archiveID from source url", archiveID, err = getQueryParamValue(pkg.Spec.Source.URL, "id")
zap.Error(err), if err != nil {
zap.String("url", pkg.Spec.Source.URL)) pruner.logger.Error("error extracting value of archiveID from source url",
return zap.Error(err),
} zap.String("url", pkg.Spec.Source.URL))
archivesRefByPkgs = append(archivesRefByPkgs, archiveID) return
} }
archivesRefByPkgs = append(archivesRefByPkgs, archiveID)
} }
} }