-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uid/gid drift possible when switching between different host builds #673
Comments
The following work around can be implemented in a bootc container file to address this issue.
|
You will likely hit the following once you rebase to a CentOS Stream/RHEL version with this openssh change: |
( I've added a link to https://issues.redhat.com/browse/USHIFT-3749 where this was discussed originally to avoid duplicate discussion where relevant) But again, this issue is not about "ostree vs bootc", it's specially about "ostree commits as built by RHEL for Edge" vs "fedora/c9s/rhel derived bootc" which happen to allocate different uids/gids due to buildsystem drift. It could also occur when switching between bootc images that have different defined ssh_key gids, and it could also occur when switching between ostree images (again if the buildsystem generating those hasn't ensured they're the same). Because of this, I don't think this is really a bootc issue at a technical level. It's more a higher level buildsystem issue. I would accept though that in practice, it may make sense for us to at least track the overall issue here, but...if we were to do something like that ssh key chown hack, I would probably say the code would logically be owned by e.g. https://gitlab.com/fedora/bootc/base-images Except for the fact that the world does not need more load bearing bash scripts run as unrestricted root, and maybe we actually implement it in Rust here as an opt-in...similarly to coreos/rpm-ostree#4913 in many ways. |
The problem can certainly occur when switching between images of the same type, but only in the case when different image parents are used for the base image vs update image. To mitigate this issue, the way we usually build our image hierarchies is to have a base (parent) image and then derive all the updates from it. The ostree-to-bootc upgrade is a special case because we're guaranteed to have different parents, so it's a 100% failure. While I prefer this to be handled by the base images we produce, the fallback would be to document all the known pitfalls, which goes back to the #671 issue. P.S. The title of this issue was changed to be more generic and we may want to go back to the specific problem of ostree-to-bootc upgrade because the generic one is a "known" issue. |
No - it's equally possible to build a custom base image using the same buildsystem that produces ostree commits today. In fact, there's significant tooling to streamline exactly that process, such as e.g. |
I did not know this tooling was in place. I will investigate this direction asap. |
Further investigation on installing bootc images on top of an unrelated ostree commit led me to a dead end. The problem with the uid/gid is serious. In my case, I got Next, I followed up on using the I did encounter a few small issues that might be worth mentioning in the upgrade instructions:
|
@cgwalters , based on my recent experience described in the previous comment, I wonder if we should be stricter in our instructions for ostree-to-bootc upgrade? I mean, should we state that the upgrade is likely to fail unless the bootc container image is derived from the base ostree commit? |
Yeah, it is a really annoying problem. See also openshift/os#1318 where we worked around this just in RHCOS...and that code isn't inherited elsewhere right. IMO |
ci: Add cross-arch builds
Import generic prep
Since the But what travier said is also really important to emphasize - in current Fedora and C10S I think we can just drop the |
Let's again narrow in on However, openvswitch also has a specific problem in that The most direct hack for the openvswitch case today is (at build time) is basically adding a systemd unit that does But what would be better here...is to not have the user at build time! We should have tooling to "flush" /etc/passwd and /etc/group - basically for each user/group that has a However, even better again than all of that for openvswitch would be |
Related to this, cockpit just switched to DynamicUser=yes for similar reasons. |
I filed https://issues.redhat.com/browse/RHEL-68655 to engage the openvswitch maintainers. |
@cgwalters to go ahead with this, at least from the ssh pov, should we just remove the group on the base image and rebuild it then? UPDATE: see https://gitlab.com/fedora/bootc/base-images/-/merge_requests/66
|
Hitting this also in the context of openshift/enhancements#1637, where I'm converting the OCP node image to become a layered image on top of an RHCOS base (instead of being part of the initial compose). What's interesting here is that drift doesn't just affect users/groups defined in the layered portion, but any dynamically allocated uids/gids in the base compose. Look at e.g. the diff for diff --git a/unlayered/usr/lib/group b/layered/usr/lib/group
index ac34a57..7db8e7b 100644
--- a/unlayered/usr/lib/group
+++ b/layered/usr/lib/group
@@ -43,14 +43,11 @@ sshd:x:74:
chrony:x:992:
-clevis:x:793:
+clevis:x:795:
-containers:x:792:
-dnsmasq:x:791:
+dnsmasq:x:794:
-gluster:x:794:
+gluster:x:796:
hugetlbfs:x:801:openvswitch
-input:x:798:
kvm:x:36:
openvswitch:x:800:
-printadmin:x:795:
+printadmin:x:797:
-render:x:797:
+render:x:799:
-systemd-coredump:x:796:
+systemd-coredump:x:798:
-systemd-journal-remote:x:790:
+systemd-journal-remote:x:793:
-unbound:x:799: E.g. We basically need a way to (1) at base compose time, freeze those GIDs to what they were in previous composes, and (2) at layering time, force the GIDs of layered packages to match those they previously had when they were part of the base compose. Similarly for UIDs. |
Can you link the code for this? |
Not much code. Just https://github.com/openshift/os/blob/master/Containerfile, which runs https://github.com/openshift/os/blob/master/scripts/apply-manifest, which applies https://github.com/openshift/os/blob/master/packages-openshift.yaml. Basically just a wrapper around |
Hmmm, https://github.com/openshift/os/blob/ce4da959eb3fc9477a0a96b69e6efd084a69b9ac/packages-openshift.yaml#L61 is in the mix here too. |
I have PR: https://gitlab.com/fedora/bootc/base-images/-/merge_requests/67 |
This approach makes sense. Can you explain how it addresses the case when the users / groups "disappear" in the new commit? I think we might want to extend the script to check for users / groups in 2 places: current commit and new commit. |
I considered only the shift in uids/gids, but as per the disappearance use-case- I think that while scanning through all the files we can create them when we encounter files owned by user/group not present in the list.
Comparing the files from two deployments and setting merge logic can work too, I guess it needs a bit of thought on how to |
User and group handling is a very messy topic and the split RHCOS effort runs right into some of the intricacies. In the layered node image model, a bunch of packages that previously were part of the base compose are now layered in a separate build step. Some of those packages also want to bring their own users/groups, such as `openvswitch`, `containers`, and `unbound`. Because they're no longer part of the base compose, the way UIDs and GIDs are allocated to dynamic system users changes, possibly shifting the IDs of multiple system users. Even for system users that don't actually have e.g. data in `/var`, we pretty much have to reserve their IDs they historically had so as to not create a "hole" in the range that could be filled by something which _does_ have data. This issue is in fact relevant even without the split RHCOS effort. Any system user dropped (or e.g. package that switches to `DynamicUser`) from the base compose can also create a hole, causing drift to occur for other system users. Anyway, this is obviously not a great position to be in, but we can't really have IDs drifting on client systems. So just pin all the currently dynamically allocated entries. Cross fingers on `DynamicUser` and systemd sysusers to save us before we run out of IDs... See also: coreos/fedora-coreos-tracker#155 See also: https://gitlab.com/fedora/bootc/tracker/-/issues/31 See also: containers/bootc#673
Ended up just doing openshift/os@ |
For me the long term solution for this is coreos/fedora-coreos-tracker#1599 with the transition path in coreos/fedora-coreos-tracker#155 (comment). In the meantime, I think what Jonathan did is the best approach: freeze the IDs in the image to a "known state". |
@travier , do the above proposals address the issue of upgrading existing systems? |
It does in coreos/fedora-coreos-tracker#155 (comment). |
When upgrading from an ostree to a bootc image, the SSH key file permissions may get invalidated in the
/etc/ssh
directory. This is causing SSH service to fail its startup, effectively preventing the user from remotely accessing the host following the upgrade.(edit by @cgwalters) Originally: https://issues.redhat.com/browse/USHIFT-3749
The text was updated successfully, but these errors were encountered: