Skip to content

Reducing GetPublicClientConfig API call For Pkce and ClientCredential#1105

Open
edwardsun-union wants to merge 15 commits into
flyteorg:mainfrom
edwardsun-union:reducerCall
Open

Reducing GetPublicClientConfig API call For Pkce and ClientCredential#1105
edwardsun-union wants to merge 15 commits into
flyteorg:mainfrom
edwardsun-union:reducerCall

Conversation

@edwardsun-union
Copy link
Copy Markdown

@edwardsun-union edwardsun-union commented May 22, 2026

- Description

This PR is made as effort to reduce GetPublicClientConfig API call for Pkce and ClientCredential authType. Currently, this API is called unconditionally to extract metadata like scopes, authenticationHeader, redirectUri. To optimize the auth workflow, necessary metadata are added as static to client configuration so that GetPublicClientConfig became conditional call. Required changes also applied to flyte create config utility so that required auth fields are written for remote authentication.

- Testing

before change:

  1. In local env, triggering flyte run task that will be execute in dogfood staging. Example test command below:
    flyte -vvv -c ./.flyte/config.yaml run ./basics/types/int_collection.py main --numbers '[1,2,3,4,5,10,20,30]'
    For client configuration refer to dogfood staging config v2

  2. observed that GetPublicClientConfig call is captured in Grafana dashboard for every flyte run execution

after change:

  1. To differentiate traffic from local env, temporarily bump up connectrpc minor version to such as connectrpc/0.10.1
  2. Repeat the same flyte task run
  3. observed that GetPublicClientConfig API call is not made from Grafana

@edwardsun-union edwardsun-union force-pushed the reducerCall branch 2 times, most recently from c3c10eb to c9956d8 Compare May 26, 2026 16:37
Comment thread src/flyte/cli/_create.py Outdated
Comment thread src/flyte/config/_internal.py Outdated
Comment on lines +54 to +55
if cfg.token_endpoint is None:
raise ValueError("token_endpoint is required for client credentials authentication")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wont this break existing clients who haven't generated there new configs. Ideally we want to keep it backward compat

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed this by keeping ClientConfig untouched and pack my changes into LocalClientConfigOverrides, this way is cleaner and ensure backward compatibility for existing client

Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
Signed-off-by: Edward Sun <edward.sun@union.ai>
kwargs = set_if_exists(
kwargs, "authorization_header", _internal.Platform.AUTHORIZATION_HEADER.read(config_file)
)
redirect_uri = _internal.Platform.REDIRECT_URI.read(config_file)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this var is not used other that in L120. Can use similar pattern to L121

Comment thread pyproject.toml
"mcp>=1.26.0",
"starlette",
"uvicorn",
"debugpy>=1.8.20",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this dependency

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmahindrakar-oss yes, it is needed to enable breakpoints and it is dev dependency only

Comment thread src/flyte/_initialize.py
Comment on lines +393 to +394
local_client_config_overrides=local_client_config_overrides,
audience=audience,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to keep audience different from local_client_config_overrides

Comment on lines +53 to +54
def has_required_public_client_fields(self) -> bool:
return bool(self.client_id and self.redirect_uri and self.header_key and self.scopes)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we missing audience

Comment thread src/flyte/cli/_create.py
Comment on lines +325 to +326
if not org:
raise click.BadParameter("--endpoint or --org must be provided")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if this could break for local-persistence mode.

--local-persistence enables a local SQLite-backed record of local runs. The data comes from the SDK process itself while it executes locally: task/
  run metadata, inputs/outputs references, status, timestamps, etc. It is written to local storage, then tools like the local TUI can read it back.

Comment thread src/flyte/cli/_create.py
Comment on lines +329 to +333
admin["clientId"] = f"{org}-uctl"
admin["insecure"] = insecure
admin["authorizationHeader"] = "flyte-authorization"
admin["redirectUri"] = "http://localhost:53593/callback"
admin["scopes"] = ["all"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to make sure these defaults are ok to be used in selfhosted environments.
cc : @mhotan .

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as an escape hatch , can we allow these to be passed, for eg in cases of selfhosted or where there are deviations in these defaults. An explicit args would help here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this more, we can populate this from GetPublicClientConfig call so we remove these unknowns. We only call this API on create config call and once that data exists in cli's config, it doesn't need to refetch it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants