Skip to content

DM-56606: Fix user / group collision in build-user image - #1126

Draft
malensek wants to merge 3 commits into
mainfrom
tickets/DM-56606
Draft

malensek wants to merge 3 commits into
mainfrom
tickets/DM-56606

Conversation

@malensek

@malensek malensek commented Oct 8, 2026

Copy link
Copy Markdown
Member

Currently, build-user-build-image can fail if the host UID or GID already exists in the base image. To reproduce, create a user with UID / GID set to 1000 / 1000 and build the image:

 => ERROR [2/6] RUN OGROUP=$(getent group 1000 | cut -d: -f1) && if [ "$OGROUP" != "" ]; then groupdel $OGROUP; fi                                                          0.2s
------
 > [2/6] RUN OGROUP=$(getent group 1000 | cut -d: -f1) && if [ "$OGROUP" != "" ]; then groupdel $OGROUP; fi:
0.116 groupdel: cannot remove the primary group of user 'qserv'
------

This can be resolved by removing the conflicting user account before configuring the groups. However, simply rearranging the commands can produce another error because userdel will automatically remove the user’s primary group as long as it has the same name as the user and the user is the only member, causing the subsequent groupdel command to fail.

Proposed Change

We need to remove conflicting users first, then set up the groups (we can use --non-unique to work around GID conflicts), and finally add the user to the image.

Additional Build-Related Changes

  • This PR also adds a submodule check that produces a warning message if submodules are not initialized or their HEAD does not match the commit hash on the current branch.
  • Some minor cleanup for spelling and correcting CLI help messages.

This would previously fail upon executing `groupdel` if the group in
question was the only/primary group of a user. With this change,
conflicting users are removed first, then the groups are updated in
place without being removed, and finally the container user account gets
created.
This repurposes the unused `submodules_initialized` function to check
for submodule initialization and report a warning message if (1) any of
the submodules are not initialized, or (2) the current submodule HEAD
does not match what was committed to the current branch.
This fixes a few spelling errors and corrects the documentation for the
option_user_build_image option.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The collision handling and submodule diagnostics are consistent with the stated requirements, with no unresolved correctness issues found.

0 open findings

What changed in this PR

Fixes UID/GID collisions when creating personalized Qserv build images and improves build diagnostics.

Changes:

  • Removes conflicting users before configuring duplicate GIDs.
  • Warns about uninitialized or mismatched Git submodules.
  • Corrects CLI help text and spelling.
File Description
deploy/​docker/​build-user/​Dockerfile Handles user and group collisions safely.
python/​lsst/​qserv/​admin/​qservCli/​launch.py Adds recursive submodule checks and typo fixes.
python/​lsst/​qserv/​admin/​qservCli/​qserv_cli.py Corrects user-build image help text.
bin/​qserv Corrects a comment typo.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

if getent passwd "$USER" > /dev/null; then userdel "$USER"; fi; \
groupadd --force --non-unique --gid "$GID" "$GROUP"; \
groupmod --non-unique --gid "$GID" "$GROUP"; \
useradd --uid "$UID" --gid "$GROUP" "$USER"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The old busted buggy version was prettier, just sayin'... 🙂

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.

3 participants