-
Notifications
You must be signed in to change notification settings - Fork 18.9k
c8d/daemon: Mount root and fill BaseFS #44075
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
Conversation
0eea216 to
1c1da2e
Compare
daemon/containerd/mount.go
Outdated
| logrus.WithError(err).WithField("dir", root).Error("failed to remove mount temp dir") | ||
| } | ||
|
|
||
| container.BaseFS = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intended. Since we already unmounted and removed the dir the BaseFS set here no longer makes sense.
It will also make it more visible if there is some code path that tries to use the BaseFS after unmount, because it will panic due to nil pointer instead of trying to perform some funny stuff on no longer existing path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! sorry, I think I commented on the wrong file. I meant to comment on the daemon/images/mount.go (so, the graph driver implementation, not the snapshotter)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah I think it would make sense to consider lack of resetting this to nil as a bug. In this case the directory may still exist, because the RWLayer.Unmount seems to just decrement the refcount for this mount, so something else may still use this.
But since Unmount was called on this container, I think it shouldn't have an access to this dir any longer.
+1 on extracting it to another PR, someone else from the maintainers may have some input on this so it would be nice not to sneak this change silently with this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was wondering if it was used elsewhere (e.g., cleaning up dead containers that failed to be removed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is interesting actually.
The daemon/images/mount.go Unmount implementation shouldn't set the BaseFS to nil. The difference is that the graph driver's implementation mounts the rootfs to its final destination, but the snapshotter one creates a new mount each time.
So even if you Unmount there is other code that uses the BaseFS of the container. For example when you docker exec we don't mount the rootfs but you look at the container's BaseFS and then look for resources inside (like the UID/GID for example). So if we set (in the graph driver's case) the BaseFS to nil on unmount parts of the code don't work any more.
|
Bunch of failures that could be related, e.g.; |
This fixes things that were broken due to nil BaseFS like `docker cp` and running a container with workdir override. This is more of a temporary hack than a real solution. The correct fix would be to refactor the code to make BaseFS and LayerRW an implementation detail of the old image store implementation and use the temporary mounts for the c8d implementation instead. That requires more work though. Signed-off-by: Paweł Gronowski <[email protected]> Signed-off-by: Sebastiaan van Stijn <[email protected]>
1c1da2e to
9f35efd
Compare
|
Rebased this one to look at the remaining diff in here that was not included in #44804 |
|
Closing this one, the upstream PR was already upstreamed |
Details
This fixes things that were broken due to nil BaseFS like
docker cpand running a container with workdir override.
This is more of a temporary hack than a real solution.
The correct fix would be to refactor the code to make BaseFS and LayerRW
an implementation detail of the old image store implementation and use
the temporary mounts for the c8d implementation instead.
That requires more work though.
- A picture of a cute animal (not mandatory but encouraged)