Skip to content

Two devenv patches#96

Merged
cgwalters merged 3 commits intobootc-dev:mainfrom
cgwalters:two-devenv-patches
Jan 28, 2026
Merged

Two devenv patches#96
cgwalters merged 3 commits intobootc-dev:mainfrom
cgwalters:two-devenv-patches

Conversation

@cgwalters
Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @cgwalters, 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 significantly enhances the development environment's capabilities by enabling nested containerization and virtual machine support within devcontainers without relying on the broad --privileged flag. It achieves this through a new Python-based setup script that intelligently configures user namespaces, mount propagation, and device access, coupled with a dedicated self-test script to validate these complex interactions. Additionally, it refines a GitHub Action for more robust package cleanup.

Highlights

  • Refactored Nested Container Setup: The devenv-init.sh script has been completely refactored to delegate its complex logic to a new Python script, userns-setup. This new script intelligently handles mount propagation, KVM device permissions, and subuid/subgid configuration for rootless Podman in constrained UID namespaces, as well as containers.conf adjustments.
  • Reduced Privileges for Devcontainers: The common/.devcontainer/devcontainer.json configuration now replaces the broad --privileged flag with a set of minimal, specific security options. These options (label=disable, unmask=/proc/*, /dev/net/tun, /dev/kvm) provide the necessary capabilities for nested Podman and VM support without granting excessive privileges.
  • New Self-Test for Nested Functionality: A new devcontainer-test target has been added to the Justfile, which executes a new devenv-selftest.sh script. This script verifies that nested Podman and VM functionality (using bcvk) works correctly within the devcontainer, ensuring the new setup is effective.
  • Improved GitHub Action Package Cleanup: The bootc-ubuntu-setup GitHub Action has been enhanced to use glob patterns for identifying unwanted packages and now includes a check (dpkg -l) to ensure a package is installed before attempting to remove it, preventing errors during cleanup.

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

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/test-devcontainer.yml
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
Copy Markdown

@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 introduces several improvements to the development environment setup. Key changes include replacing the --privileged flag with more granular security options for nested containers, which is a significant security enhancement. The devenv-init.sh script has been refactored from a shell script into a more robust and maintainable Python script (userns-setup). A new self-test script (devenv-selftest.sh) and a corresponding Justfile command have been added to validate the nested container setup. Additionally, the GitHub Action for setting up Ubuntu has been improved for more reliable package removal.

The changes are well-structured and improve the security and maintainability of the development environment. I have a couple of minor suggestions for the new Python script to improve its robustness and adherence to Python conventions.

Comment thread devenv/userns-setup
Comment thread devenv/userns-setup
@cgwalters cgwalters force-pushed the two-devenv-patches branch 5 times, most recently from 05634de to ffd7d42 Compare January 28, 2026 16:17
@cgwalters cgwalters enabled auto-merge (squash) January 28, 2026 16:17
When running inside a constrained UID namespace (e.g., devaipod's rootless
podman), the container only has access to a limited UID range. The previous
configuration only handled cgroups but not the subuid/subgid mappings, causing
nested podman to fail with 'newuidmap: write to uid_map failed'.

This adds a Python script at /usr/lib/devenv/userns-setup which:
- Detects constrained UID namespaces by parsing /proc/self/uid_map
- Configures /etc/subuid and /etc/subgid with the available UID range
- Uses SUDO_USER to correctly configure for the target user when run via sudo
- Resets podman storage if mappings change
- Preserves other users' entries when updating subuid/subgid
- Creates containers.conf with cgroups=disabled for constrained namespaces

The devenv-init.sh becomes a thin wrapper calling the Python implementation.

Also adds chmod u+s for newuidmap/newgidmap on C10s, as shadow-utils doesn't
set setuid by default (unlike Debian's uidmap package).

Also adds a GitHub Actions workflow and just target to test nested podman
by pulling and running busybox in the devcontainer images.

Tested by running bootc workspace inside devaipod and successfully pulling and
running containers with nested podman.

Assisted-by: OpenCode (Claude claude-opus-4-5@20251101)
Signed-off-by: Colin Walters <walters@verbum.org>
The arm64 runners from Arm Limited don't have all the same packages
as x86_64 runners (e.g. google-chrome-stable). This caused apt-get
remove to fail with exit code 100.

Fix by checking with dpkg -l before attempting removal. Also switch
from regex patterns to globs since both apt and dpkg support fnmatch
globs, avoiding the need for pattern conversion.

Assisted-by: OpenCode (Claude claude-opus-4-5@20251101)
Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters
Copy link
Copy Markdown
Contributor Author

OK, well the plus side of adding tests is it found out that the c10s devenv was broken. Man, figuring out that /usr/bin/newuidmap was missing file caps becuase we have a broken legacy buildsystem for quay.io/centos/centos:stream10 was a pain.

The test was pulling pre-built images from the registry, but those
don't have the selftest script until this PR is merged. Build the
image locally first using the existing just targets.

Also switch from docker to podman for consistency with the build.

Signed-off-by: Colin Walters <walters@verbum.org>
Copy link
Copy Markdown
Contributor

@gursewak1997 gursewak1997 left a comment

Choose a reason for hiding this comment

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

looks decent to me

@cgwalters cgwalters merged commit e15b962 into bootc-dev:main Jan 28, 2026
12 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