From 4abfbc7679cda6b852c7a9e8d68b017145c1ec16 Mon Sep 17 00:00:00 2001 From: Prafulla Mahindrakar Date: Tue, 28 May 2024 09:50:46 -0700 Subject: [PATCH] [CLD-946] Using InMemory token cache for admin clientset in propeller (#299) * Using InMmeory token cache for admin clientset in propeller * pass cache to auth interceptor Signed-off-by: Paul Dittamo --- flytepropeller/pkg/controller/controller.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flytepropeller/pkg/controller/controller.go b/flytepropeller/pkg/controller/controller.go index afa0c6e9ef..c59aa9745d 100644 --- a/flytepropeller/pkg/controller/controller.go +++ b/flytepropeller/pkg/controller/controller.go @@ -28,6 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "github.com/flyteorg/flyte/flyteidl/clients/go/admin" + tokenCache "github.com/flyteorg/flyte/flyteidl/clients/go/admin/cache" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/flytek8s" flyteK8sConfig "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/flytek8s/config" @@ -302,14 +303,15 @@ func newControllerMetrics(scope promutils.Scope) *metrics { func getAdminClient(ctx context.Context) (client service.AdminServiceClient, signalClient service.SignalServiceClient, opt []grpc.DialOption, err error) { cfg := admin.GetConfig(ctx) - clients, err := admin.NewClientsetBuilder().WithConfig(cfg).Build(ctx) + tc := tokenCache.NewTokenCacheInMemoryProvider() + clients, err := admin.NewClientsetBuilder().WithConfig(cfg).WithTokenCache(tc).Build(ctx) if err != nil { return nil, nil, nil, fmt.Errorf("failed to initialize clientset. Error: %w", err) } credentialsFuture := admin.NewPerRPCCredentialsFuture() opts := []grpc.DialOption{ - grpc.WithChainUnaryInterceptor(admin.NewAuthInterceptor(cfg, nil, credentialsFuture, nil)), + grpc.WithChainUnaryInterceptor(admin.NewAuthInterceptor(cfg, tc, credentialsFuture, nil)), grpc.WithPerRPCCredentials(credentialsFuture), }