From 90924cdec7477f61853246c3d3677cdc5ab36d2a Mon Sep 17 00:00:00 2001 From: Naeel Date: Sun, 26 Apr 2026 11:44:36 +0300 Subject: [PATCH] layer1: checkpoint namespace manager runtime series --- pkg/buildermgr/namespace_subscriber.go | 2 +- pkg/buildermgr/namespace_subscriber_test.go | 2 +- .../multitenant/namespace_subscriber.go | 2 +- .../multitenant/namespace_subscriber_test.go | 2 +- pkg/executor/multitenant/ns_watcher.go | 1 + pkg/executor/multitenant/ns_watcher_test.go | 24 +++++++++++-------- pkg/router/namespace_subscriber.go | 2 +- pkg/router/namespace_subscriber_test.go | 2 +- pkg/router/ns_watcher.go | 1 + pkg/utils/namespace_manager.go | 8 +++---- pkg/utils/namespace_manager_model.go | 2 +- pkg/utils/namespace_manager_test.go | 10 ++++---- 12 files changed, 32 insertions(+), 26 deletions(-) diff --git a/pkg/buildermgr/namespace_subscriber.go b/pkg/buildermgr/namespace_subscriber.go index 7426607d..f3a9f1d9 100644 --- a/pkg/buildermgr/namespace_subscriber.go +++ b/pkg/buildermgr/namespace_subscriber.go @@ -40,4 +40,4 @@ func registerBuilderNamespace(ctx context.Context, namespace string, envw builde if pkgw != nil { pkgw.AddNamespace(ctx, namespace, mgr) } -} \ No newline at end of file +} diff --git a/pkg/buildermgr/namespace_subscriber_test.go b/pkg/buildermgr/namespace_subscriber_test.go index d82c9f84..0230e64e 100644 --- a/pkg/buildermgr/namespace_subscriber_test.go +++ b/pkg/buildermgr/namespace_subscriber_test.go @@ -49,4 +49,4 @@ func TestNewNamespaceSubscriberAddAndResync(t *testing.T) { if envw.lastNamespace != "tenant-builder-a" || pkgw.lastNamespace != "tenant-builder-a" { t.Fatalf("expected namespace to be forwarded to both watchers") } -} \ No newline at end of file +} diff --git a/pkg/executor/multitenant/namespace_subscriber.go b/pkg/executor/multitenant/namespace_subscriber.go index c4178e4e..1c6aba67 100644 --- a/pkg/executor/multitenant/namespace_subscriber.go +++ b/pkg/executor/multitenant/namespace_subscriber.go @@ -29,4 +29,4 @@ func NewNamespaceSubscriber( return nil }, } -} \ No newline at end of file +} diff --git a/pkg/executor/multitenant/namespace_subscriber_test.go b/pkg/executor/multitenant/namespace_subscriber_test.go index abecb9a0..d2da3ecf 100644 --- a/pkg/executor/multitenant/namespace_subscriber_test.go +++ b/pkg/executor/multitenant/namespace_subscriber_test.go @@ -34,4 +34,4 @@ func TestNewNamespaceSubscriberAddAndResync(t *testing.T) { if poolmgr.lastNamespace != "tenant-executor-b" { t.Fatalf("expected namespace to be forwarded to executor type") } -} \ No newline at end of file +} diff --git a/pkg/executor/multitenant/ns_watcher.go b/pkg/executor/multitenant/ns_watcher.go index 0630e7f6..27d0dc92 100644 --- a/pkg/executor/multitenant/ns_watcher.go +++ b/pkg/executor/multitenant/ns_watcher.go @@ -71,6 +71,7 @@ import ( "github.com/fission/fission/pkg/utils" "github.com/fission/fission/pkg/utils/manager" ) + // StartNSWatcher registers a Kubernetes Namespace Informer that reacts immediately // when a Namespace with label fission.io/managed=true is created or relabeled. // diff --git a/pkg/executor/multitenant/ns_watcher_test.go b/pkg/executor/multitenant/ns_watcher_test.go index d332eefc..4f91643a 100644 --- a/pkg/executor/multitenant/ns_watcher_test.go +++ b/pkg/executor/multitenant/ns_watcher_test.go @@ -21,21 +21,25 @@ type fakeExecutorType struct { } func (f *fakeExecutorType) Run(context.Context, manager.Interface) {} -func (f *fakeExecutorType) GetTypeName(context.Context) fv1.ExecutorType { return fv1.ExecutorTypePoolmgr } +func (f *fakeExecutorType) GetTypeName(context.Context) fv1.ExecutorType { + return fv1.ExecutorTypePoolmgr +} func (f *fakeExecutorType) GetFuncSvc(context.Context, *fv1.Function) (*fscache.FuncSvc, error) { return nil, nil } func (f *fakeExecutorType) GetFuncSvcFromCache(context.Context, *fv1.Function) (*fscache.FuncSvc, error) { return nil, nil } -func (f *fakeExecutorType) DumpDebugInfo(context.Context) error { return nil } -func (f *fakeExecutorType) DeleteFuncSvcFromCache(context.Context, *fscache.FuncSvc) {} -func (f *fakeExecutorType) TapService(context.Context, string) error { return nil } -func (f *fakeExecutorType) UnTapService(context.Context, *metav1.ObjectMeta, string) {} +func (f *fakeExecutorType) DumpDebugInfo(context.Context) error { return nil } +func (f *fakeExecutorType) DeleteFuncSvcFromCache(context.Context, *fscache.FuncSvc) {} +func (f *fakeExecutorType) TapService(context.Context, string) error { return nil } +func (f *fakeExecutorType) UnTapService(context.Context, *metav1.ObjectMeta, string) {} func (f *fakeExecutorType) MarkSpecializationFailure(context.Context, *metav1.ObjectMeta) {} -func (f *fakeExecutorType) IsValid(context.Context, *fscache.FuncSvc) bool { return true } -func (f *fakeExecutorType) RefreshFuncPods(context.Context, *zap.Logger, fv1.Function) error { return nil } -func (f *fakeExecutorType) AdoptExistingResources(context.Context) {} +func (f *fakeExecutorType) IsValid(context.Context, *fscache.FuncSvc) bool { return true } +func (f *fakeExecutorType) RefreshFuncPods(context.Context, *zap.Logger, fv1.Function) error { + return nil +} +func (f *fakeExecutorType) AdoptExistingResources(context.Context) {} func (f *fakeExecutorType) CleanupOldExecutorObjects(context.Context) {} func (f *fakeExecutorType) AddNamespace(ctx context.Context, ns string, mgr manager.Interface) error { f.addCalls++ @@ -62,7 +66,7 @@ func TestRegisterExecutorTypes(t *testing.T) { func TestRegisterExecutorTypesAggregatesErrors(t *testing.T) { err := registerExecutorTypes(context.Background(), zap.NewNop(), "tenant-executor-a", map[fv1.ExecutorType]executortype.ExecutorType{ - fv1.ExecutorTypePoolmgr: &fakeExecutorType{addErr: errors.New("poolmgr failed")}, + fv1.ExecutorTypePoolmgr: &fakeExecutorType{addErr: errors.New("poolmgr failed")}, fv1.ExecutorTypeContainer: &fakeExecutorType{}, }, nil) if err == nil { @@ -71,4 +75,4 @@ func TestRegisterExecutorTypesAggregatesErrors(t *testing.T) { if err.Error() != "poolmgr failed" { t.Fatalf("unexpected error: %v", err) } -} \ No newline at end of file +} diff --git a/pkg/router/namespace_subscriber.go b/pkg/router/namespace_subscriber.go index ba8a890f..3aedbae0 100644 --- a/pkg/router/namespace_subscriber.go +++ b/pkg/router/namespace_subscriber.go @@ -28,4 +28,4 @@ func registerRouterNamespace(ctx context.Context, namespace string, ts routerNam return nil } return ts.AddNamespace(ctx, namespace, mgr) -} \ No newline at end of file +} diff --git a/pkg/router/namespace_subscriber_test.go b/pkg/router/namespace_subscriber_test.go index d0d9b0d0..318df723 100644 --- a/pkg/router/namespace_subscriber_test.go +++ b/pkg/router/namespace_subscriber_test.go @@ -49,4 +49,4 @@ func TestRegisterRouterNamespacePropagatesError(t *testing.T) { if err == nil || err.Error() != "add failed" { t.Fatalf("expected router add error to be propagated, got %v", err) } -} \ No newline at end of file +} diff --git a/pkg/router/ns_watcher.go b/pkg/router/ns_watcher.go index 5c93f799..69c0a33f 100644 --- a/pkg/router/ns_watcher.go +++ b/pkg/router/ns_watcher.go @@ -14,6 +14,7 @@ import ( "github.com/fission/fission/pkg/utils" "github.com/fission/fission/pkg/utils/manager" ) + // StartNSWatcher registers a Kubernetes Namespace Informer for the router. // Whenever a Namespace with label fission.io/managed=true appears (or is relabeled), // the router immediately subscribes to HTTPTriggers and Functions in that namespace. diff --git a/pkg/utils/namespace_manager.go b/pkg/utils/namespace_manager.go index 9415b76f..c1ba15f4 100644 --- a/pkg/utils/namespace_manager.go +++ b/pkg/utils/namespace_manager.go @@ -25,10 +25,10 @@ type NamespaceSubscriber interface { } type NamespaceSubscriberFuncs struct { - SubscriberName string - AddFunc func(ctx context.Context, record NamespaceRecord) error - RemoveFunc func(ctx context.Context, record NamespaceRecord) error - ResyncFunc func(ctx context.Context, record NamespaceRecord) error + SubscriberName string + AddFunc func(ctx context.Context, record NamespaceRecord) error + RemoveFunc func(ctx context.Context, record NamespaceRecord) error + ResyncFunc func(ctx context.Context, record NamespaceRecord) error } func (s NamespaceSubscriberFuncs) Name() string { diff --git a/pkg/utils/namespace_manager_model.go b/pkg/utils/namespace_manager_model.go index d0b13243..763d467e 100644 --- a/pkg/utils/namespace_manager_model.go +++ b/pkg/utils/namespace_manager_model.go @@ -44,7 +44,7 @@ const ( type NamespaceRemovalStrategy string const ( - NamespaceRemovalStrategyTrackOnly NamespaceRemovalStrategy = "track-only" + NamespaceRemovalStrategyTrackOnly NamespaceRemovalStrategy = "track-only" NamespaceRemovalStrategyDispatchRemove NamespaceRemovalStrategy = "dispatch-remove" ) diff --git a/pkg/utils/namespace_manager_test.go b/pkg/utils/namespace_manager_test.go index 134a356c..d4cd1ca0 100644 --- a/pkg/utils/namespace_manager_test.go +++ b/pkg/utils/namespace_manager_test.go @@ -16,11 +16,11 @@ import ( ) type testNamespaceSubscriber struct { - name string - addErr error - removeErr error - resyncErr error - addCalls int + name string + addErr error + removeErr error + resyncErr error + addCalls int removeCalls int resyncCalls int }