Skip to content

Conversation

@liranbg
Copy link
Member

@liranbg liranbg commented Jan 4, 2026

📝 Description

To ensure token file names can be explicitly set and (correctly) auto set for runtimes / local development it was required to remove the ~/.igz.yml from config.py and set it according to running env (k8s, jupyter, local).

This fixes Iguazio v4 OAuth token file auto-initialization to correctly distinguish between Kubernetes runtime environments and Jupyter environments. Previously, the token file was always overwritten to the k8s secret path when running inside Kubernetes, which broke authentication for Jupyter environments.


🛠️ Changes Made

  • Modified the token file initialization logic to check for Jupyter environment (JPY_SESSION_NAME) before overriding to k8s secret path
  • Changed default token_file config from ~/.igz.yml to empty string, allowing dynamic initialization based on runtime context
  • Updated docstring in sync_secret_tokens to reflect the new behavior

✅ Checklist

  • I updated the documentation (if applicable)
  • I have tested the changes in this PR
  • I confirmed whether my changes are covered by system tests
    • If yes, I ran all relevant system tests and ensured they passed before submitting this PR
    • I updated existing system tests and/or added new ones if needed to cover my changes
  • If I introduced a deprecation:

🧪 Testing

  • UT
  • igz4 envs

🔗 References

  • Ticket link:
  • Design docs links:
  • External links:

🚨 Breaking Changes?

  • Yes (explain below)
  • No

🔍️ Additional Notes

@liranbg liranbg requested a review from a team as a code owner January 4, 2026 10:42
Comment on lines +651 to +667
if not config.auth_with_oauth_token.token_file:
user_token_file = os.path.expanduser("~/.igz.yml")

# runtimes
# TODO: change to os.getenv("MLRUN_RUNTIME_KIND")
# when https://github.com/mlrun/mlrun/pull/9121 is done.
if (
mlrun.k8s_utils.is_running_inside_kubernetes_cluster()
and not os.environ.get("JPY_SESSION_NAME")
):
user_token_file = os.path.join(
mlrun.common.constants.MLRUN_JOB_AUTH_SECRET_PATH,
mlrun.common.constants.MLRUN_JOB_AUTH_SECRET_FILE,
)

config.auth_with_oauth_token.token_file = user_token_file

Copy link
Contributor

Choose a reason for hiding this comment

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

If a user sets MLRUN_AUTH_WITH_OAUTH_TOKEN__TOKEN_FILE as an env var on the runtime, then he will override the /var/mlrun-secrets/auth/ that is supposed to be used for runtimes.
It's fine to leave it like this for now but once the os.getenv("MLRUN_RUNTIME_KIND") is introduced we'll need to block the user from setting this env var on a runtime

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed can be harmful if setting this envvar mistakenly - but that is the purpose of this PR - to allow overriding

@liranbg liranbg merged commit beec2f2 into mlrun:development Jan 4, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants