Skip to content

[k8s] Set proper owner context identity#9190

Open
kyuds wants to merge 2 commits intomasterfrom
kyuds/k8s-identity
Open

[k8s] Set proper owner context identity#9190
kyuds wants to merge 2 commits intomasterfrom
kyuds/k8s-identity

Conversation

@kyuds
Copy link
Collaborator

@kyuds kyuds commented Mar 25, 2026

Testing methodology:

  1. Create two k8s clusters, A, B. Current Context: A
  2. Launch via sky launch -c test --infra k8s/B
  3. Remove context A entirely, set current context to B
  4. Try sky exec test -- echo hi

Fails on current master, works on this PR.

Tested (run the relevant ones):

  • Code formatting: install pre-commit (auto-check on commit) or bash format.sh
  • Any manual or new tests for this PR (please specify below)
  • All smoke tests: /smoke-test (CI) or pytest tests/test_smoke.py (local)
  • Relevant individual tests: /smoke-test -k test_name (CI) or pytest tests/test_smoke.py::test_name (local)
  • Backward compatibility: /quicktest-core (CI) or pytest tests/smoke_tests/test_backward_compat.py (local)

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines how owner identities are managed, specifically for Kubernetes clusters. It introduces Kubernetes-aware logic to correctly identify cluster owners based on their context and prevents certain owner identity warnings and updates that are not applicable to Kubernetes environments. This ensures more accurate and appropriate handling of cluster ownership within the Kubernetes ecosystem.

Highlights

  • Kubernetes Owner Identity Handling: Introduced specific logic to handle owner identity for Kubernetes clusters, differentiating it from other cloud providers.
  • Context-based User Identity Retrieval: Added a new utility method to retrieve a user's identity directly from a specified Kubernetes context name.
  • Conditional Owner Identity Warnings: Modified the owner identity check to suppress warnings and prevent automatic identity updates for Kubernetes clusters, as their identity management differs.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors user identity management to include specific handling for Kubernetes clusters. It introduces a new method get_user_identity_from_context_name in sky/clouds/kubernetes.py to fetch user identities from Kubernetes contexts, which is then utilized during cluster provisioning. The changes also adjust the _check_owner_identity_with_record function to conditionally skip certain owner identity warnings and updates for Kubernetes. A key piece of feedback suggests replacing the assert False for control flow in get_user_identity_from_context_name with a ValueError exception to prevent unexpected behavior if assertions are disabled, and to update the corresponding docstring.

@kyuds
Copy link
Collaborator Author

kyuds commented Mar 25, 2026

/quicktest-core --kubernetes

@kyuds
Copy link
Collaborator Author

kyuds commented Mar 25, 2026

/smoke-test --kubernetes

@kyuds kyuds requested a review from kevinmingtarja March 25, 2026 18:05
# showing the warning above again.
global_user_state.set_owner_identity_for_cluster(
cluster_name, identity)
if not is_k8s_cloud:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a comment here on why we skip this if is_k8s_cloud?

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