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)

* Using InMmeory token cache for admin clientset in propeller

* pass cache to auth interceptor

Signed-off-by: Paul Dittamo <[email protected]>
  • Loading branch information
pmahindrakar-oss authored and pvditt committed Aug 2, 2024
1 parent 45e287a commit 4abfbc7
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)

Check warning on line 307 in flytepropeller/pkg/controller/controller.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/controller.go#L306-L307

Added lines #L306 - L307 were not covered by tests
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)),

Check warning on line 314 in flytepropeller/pkg/controller/controller.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/controller.go#L314

Added line #L314 was not covered by tests
grpc.WithPerRPCCredentials(credentialsFuture),
}

Expand Down

0 comments on commit 4abfbc7

Please sign in to comment.