Skip to content

Commit

Permalink
[CLD-946] Using InMemory token cache for admin clientset in propeller (
Browse files Browse the repository at this point in the history
…#299) (#5621)


Signed-off-by: Paul Dittamo <[email protected]>
Co-authored-by: Prafulla Mahindrakar <[email protected]>
  • Loading branch information
pvditt and pmahindrakar-oss authored Aug 20, 2024
1 parent efcd82e commit 705bc04
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions flytepropeller/pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
}

Expand Down

0 comments on commit 705bc04

Please sign in to comment.