<#1182 init_in_cluster: fall back to init_from_con...
# flyte-github
a
#1182 init_in_cluster: fall back to init_from_config when config file is present Pull request opened by mhotan Context Running v2 actions today requires a two-phase deploy: install the dataplane chart, then run
flyte create secret EAGER_API_KEY ...
before any action can execute. That side-channel step breaks GitOps for selfhosted users.
_UNION_EAGER_API_KEY
is also base64-encoded but not encrypted on the task pod manifest — readable via
pods/get
, in audit logs, and via
echo \$_UNION_EAGER_API_KEY
inside the user container. Change When no
api_key=
is passed,
init_in_cluster()
checks
UCTL_CONFIG
and
FLYTECTL_CONFIG
env vars in that order. If either is set, it delegates to
init_from_config.aio()
for the SDK side effects (logger, type transformers, sys.path,
_init_config
globals) and returns controller-shaped kwargs derived from the same
PlatformConfig
so
runtime._run_action
can spread them into
create_remote_controller(**kwargs)
— no env var on the pod manifest.
_platform_to_client_kwargs(pc: PlatformConfig) -> dict
is the single source of truth for translating PlatformConfig fields into the kwargs accepted by
_initialize_client
and
create_remote_controller
.
init_from_config
spreads its output into
init.aio(...)
instead of threading each field by hand. A new PlatformConfig field that needs to reach the HTTP/auth stack is added in one place.
ca_cert_file_path
takes precedence over
insecure_skip_verify
in the helper.
_resolve_tls_ca_cert
otherwise prefers the bootstrap-from-server path, which fetches only what the leaf presents — nginx typically serves the leaf alone, so the bootstrapped chain has no path back to the trust anchor and pyqwest reports
UnknownIssuer
. The chart-managed CA bundle, when mounted, is unambiguously the correct trust anchor. What this PR deliberately does NOT do • Does not walk `resolve_config_path()`'s full precedence chain in
init_in_cluster
. That walk includes a
git rev-parse
subprocess, which is wasted work in a task pod and shows up in
Popen
-mocking tests as an extra call. The chart contract is "the pod's env var points at the mounted file"; honoring just that env var is enough. • Does not add a hardcoded
/etc/flyte/config.yaml
fallback to
resolve_config_path()
. The chart sets
FLYTECTL_CONFIG
explicitly; no fallback default is needed. • Does not introduce a new SDK-level config-loading entry point.
init_from_config()
is the existing public surface; this PR adds one new call site (inside
init_in_cluster
) and refactors `init_from_config`'s internal field threading to use the helper. A typo in
FLYTECTL_CONFIG
raises
InitializationError("ConfigFileNotFoundError")
rather than silently routing to the legacy api-key branch — keeps misconfiguration loud. Explicit
api_key=
and the legacy env-var path are unchanged when no env var is set. Caveats Solves the two-phase deploy. Reduces — does not eliminate — API-key leakage: the mounted
client_secret
file is still readable from inside the user container. Tentative: a follow-up
union-auth-proxy
sidecar (Phase 2, not implemented, subject to review) is one candidate for closing that remaining gap. Alternatives (capability-only narrowing, short-lived token exchange) are still open. Test plan •
FLYTECTL_CONFIG
set → delegates and returns controller-shaped kwargs •
UCTL_CONFIG
takes precedence over
FLYTECTL_CONFIG
• Neither env var set → legacy api-key/env-var branch runs • Env var points at missing path → loud
InitializationError
, no silent fallback • Explicit
api_key=
→ no fallback even when env var is set • Helper round-trips every chart-set
PlatformConfig
field • Helper picks
ca_cert_file_path
over
insecure_skip_verify
when both set • End-to-end: v2 eager run on Union selfmanaged dataplane (mike-apple-aws), file-mounted creds, internal-CA TLS, no env var, first-attempt success — run
ucbzldwjldgtq9fwxchs
, 4/4 actions Success. flyteorg/flyte-sdk