acoustic-carpenter-78188
03/19/2026, 4:25 AMGetPublicClientConfig is called up to 4 times during client initialization (token_source_provider.go:64, client.go:100, auth_interceptor.go:142, oauth/config.go:22). The response contains static server configuration (client ID, redirect URI, scopes, audience, authorization metadata key) that does not change at runtime.
As noted in the issue, this shows up as unnecessary API call volume on monitoring dashboards. The success criteria from the issue is reducing these calls to 0 after the first fetch.
What changes were proposed in this pull request?
Added a cachedMetadataClient decorator in flyteidl/clients/go/admin/cached_metadata_client.go that wraps AuthMetadataServiceClient and caches the GetPublicClientConfig response using sync.Once. The first call makes the RPC; subsequent calls return the cached result.
The decorator is applied in InitializeAuthMetadataClient (client.go:124), which is the single point where the auth metadata client is created. All 4 downstream call sites automatically benefit from caching without any changes.
GetOAuth2Metadata is not cached in this PR since it's called less frequently and serves a different purpose, but the same pattern could be applied if needed.
How was this patch tested?
• go fmt ./... and go vet ./clients/go/admin/... pass clean
• The sync.Once pattern is well-established for this use case. The cached value is immutable after first write, so there are no concurrency concerns.
This contribution was developed with AI assistance (Claude Code + Codex).
Labels
• changed: Caches previously redundant API calls.
flyteorg/flyte