Skip to content

fix: improve run_as_user and run_as_group handling#7

Merged
thxCode merged 1 commit intogpustack:mainfrom
yxf0314:run-as-user
Feb 6, 2026
Merged

fix: improve run_as_user and run_as_group handling#7
thxCode merged 1 commit intogpustack:mainfrom
yxf0314:run-as-user

Conversation

@yxf0314
Copy link
Contributor

@yxf0314 yxf0314 commented Feb 6, 2026

gpustack/gpustack#3408
enable to set ContainerExecution.run_as_user=0

@yxf0314 yxf0314 requested review from Copilot and thxCode February 6, 2026 02:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the handling of run_as_user and run_as_group settings to allow explicitly setting these values to 0 (root user/group). The previous implementation using the or operator prevented setting user ID 0, as it would fall back to the workload default when the value was falsy.

Changes:

  • Replaced or operator with explicit None checks for run_as_user and run_as_group
  • Applied the fix consistently to both Docker and Podman deployers

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
gpustack_runtime/deployer/podman.py Updated user/group assignment logic to handle 0 values correctly
gpustack_runtime/deployer/docker.py Applied identical fix to Docker deployer for consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gemini-code-assist
Copy link

Summary of Changes

Hello @yxf0314, 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 resolves a critical bug in the container deployment logic for both Docker and Podman. It specifically targets the handling of run_as_user and run_as_group parameters, where a value of 0 (representing the root user or group) was being inadvertently ignored. The updated logic now correctly interprets 0 as a valid identifier, providing accurate control over container execution privileges and enabling the explicit configuration of containers to run as root.

Highlights

  • Corrected User/Group ID Handling: The logic for determining run_as_user and run_as_group in container creation has been updated to correctly interpret 0 as a valid user or group ID.
  • Fix for Falsy Zero Value: Addressed an issue where a run_as_user or run_as_group value of 0 was incorrectly treated as None due to Python's or operator behavior, preventing containers from running as root when intended.
  • Consistent Behavior Across Runtimes: The fix has been applied to both Docker and Podman deployers, ensuring consistent and accurate control over container execution privileges.

🧠 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.

Changelog
  • gpustack_runtime/deployer/docker.py
    • Updated the assignment logic for run_as_user and run_as_group from X or Y to X if X is not None else Y to correctly handle 0 as a valid user/group ID.
  • gpustack_runtime/deployer/podman.py
    • Applied the same logic correction for run_as_user and run_as_group as in the Docker deployer, ensuring consistent behavior across container runtimes.
Activity
  • No human activity (comments, reviews, or progress updates) has been recorded on this pull request since its creation.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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

@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 fixes a bug in how run_as_user and run_as_group are handled in both the Docker and Podman deployers. The previous implementation used or to fall back to workload-level settings, which incorrectly handled the valid case where run_as_user or run_as_group is 0. The fix correctly uses an is not None check to handle this. The logic is sound. I've added a couple of suggestions to improve the conciseness of the new code.

Comment on lines +913 to +922
run_as_user = (
c.execution.run_as_user
if c.execution.run_as_user is not None
else workload.run_as_user
)
run_as_group = (
c.execution.run_as_group
if c.execution.run_as_group is not None
else workload.run_as_group
)

Choose a reason for hiding this comment

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

medium

While the logic is correct, these assignments can be written more concisely using single-line ternary operators. This improves readability by reducing the number of lines.

                run_as_user = c.execution.run_as_user if c.execution.run_as_user is not None else workload.run_as_user
                run_as_group = c.execution.run_as_group if c.execution.run_as_group is not None else workload.run_as_group

Comment on lines +914 to +923
run_as_user = (
c.execution.run_as_user
if c.execution.run_as_user is not None
else workload.run_as_user
)
run_as_group = (
c.execution.run_as_group
if c.execution.run_as_group is not None
else workload.run_as_group
)

Choose a reason for hiding this comment

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

medium

Similar to the change in docker.py, these assignments can be made more concise. Using single-line ternary operators would improve readability here.

                run_as_user = c.execution.run_as_user if c.execution.run_as_user is not None else workload.run_as_user
                run_as_group = c.execution.run_as_group if c.execution.run_as_group is not None else workload.run_as_group

Copy link
Contributor

@thxCode thxCode left a comment

Choose a reason for hiding this comment

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

LGTM

@thxCode thxCode merged commit e90d6b1 into gpustack:main Feb 6, 2026
7 checks passed
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