Skip to content

fix: preserve zero user and group IDs in Pebble services - #2847

Merged
benhoyt merged 2 commits into
canonical:mainfrom
ItsM0rty:code-fix/pebble-root-identity
Nov 4, 2026
Merged

benhoyt merged 2 commits into
canonical:mainfrom
ItsM0rty:code-fix/pebble-root-identity

Conversation

@ItsM0rty

@ItsM0rty ItsM0rty commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2846.

Pebble service serialization drops user-id: 0 and group-id: 0. Merging a zero ID also keeps the previous ID, so the resulting configuration can differ from what the charm requested.

This keeps zero as an explicit identity and still omits unset IDs. Added regressions for both fields through service and layer serialization, plus merging.

Validation: the full Linux unit run passes with 2,483 tests and 56 skips; the release-script tests add 13 passes. The Pebble client file passes all 198 tests. All four new cases fail on unchanged upstream. Full Ruff, codespell and Pyright checks pass.

The Linux test copy uses LF line endings and restored executable bits from Git. The docs build passes after fetching the full Git history, which the documentation timestamp extension requires. No Juju controller or live Pebble daemon was used.

@ItsM0rty
ItsM0rty marked this pull request as ready for review October 26, 2026 05:00

@benhoyt benhoyt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @ItsM0rty for the contribution. The bug is real and fix looks good. I didn't love the use of parametrize in the tests, and I realised _merge didn't have any tests, so I updated the tests.

@ItsM0rty

ItsM0rty commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review and for updating the tests @benhoyt; glad the fix looks good.

@benhoyt
benhoyt merged commit 41b19e7 into canonical:main Nov 4, 2026
60 checks passed
tonyandrewmeyer pushed a commit that referenced this pull request Nov 10, 2026
…#2867)

Fixes #2881

`Check._merge_exec` skipped falsy values, so an override layer that sets
an exec check's `user-id: 0` or `group-id: 0` (root) kept the previous
IDs. Pebble's `ExecCheck.Merge` only skips nil IDs (`if other.UserID !=
nil`), so the plan merged by Harness and `ops.testing` differed from the
real one.

This treats only `None` as unset for the exec `user-id` and `group-id`,
the same approach #2847 took for services. Other exec fields keep the
current behaviour.

Test: `TestCheck.test_merge_exec_zero_ids` in `test/test_pebble.py`
merges a layer with zero IDs over one with 1000/2000 (expects 0/0), then
merges a layer without IDs (expects 0/0 to stay). It fails on main.

---------

Co-authored-by: James Garner <[email protected]>
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.

Pebble service serialization and merging drop UID/GID zero

3 participants