Ensure /run/containerd gets created with correct perms#10516
Ensure /run/containerd gets created with correct perms#10516estesp merged 1 commit intocontainerd:mainfrom
/run/containerd gets created with correct perms#10516Conversation
|
Hi @etungsten. Thanks for your PR. I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
/retest |
|
/test pull-containerd-node-e2e |
|
Hmm, I'm having a hard time understanding how these changes would cause these test timeouts. |
1f839f9 to
5a01677
Compare
|
/retest |
thaJeztah
left a comment
There was a problem hiding this comment.
Looking at these changes in context though, I'm a bit on the fence if these locations are the right location for creating these directories; specifically the one in pkg/cio feels very out of place, but I'm a bit concerned about the general design to sprinkle some MkdirAll calls through the code; more so after looking that the CreateTopLevelDirectories is present to setup required paths as early as possible. Having such mechanisms centralised so that they're created, as early as possible, and that there's a canonical location on their permissions may be a good thing.
Looking at the linked ticket; #10502 the request
I am running multiple instances of the containerd daemon on my machine and each containerd instance has their own state directories. e.g.
/run/containerd-fooand/run/containerd-bar,/run/containerd
Those locations (per above) should already be created when each of those instances starts up.
containerd-shim however creates the shim socket under the default state directory which is set to
/run/containerd
This is the part that (IIUC) causes issues for you, because starting a containerd instance with /run/containerd-foo as state-dir, will still attempt to create sockets in /run/containerd. Also from that linked discussion it looks like that's currently not configurable (hence this PR). I'm slightly concerned though that we're tapering over the underlying issue (those paths not configurable and/or not tied to the actual state directory in use (/run/containerd-foo)).
I'm also interested to learn about this part of your request; i.e., is there a specific reason you must have the additional instances running before the "main" (for better words) instance?
This is an issue because I want some containerd daemon instances to start earlier than the regular containerd daemon
Given that (from all things above) it looks like "multiple instances" is still a partial implementation, but the code changes in this PR will affect standard setups, I'm wondering if (while the "custom path" implementation is not complete / fully fledged out), a different workaround would be more appropriate. Which could be (e.g.) a systemd unit / script to create the directories ahead of time (before any of the containerd instances is started).
An alternative could be to;
- have
CreateTopLevelDirectoriesunconditionally create/run/containerdregardless of the actually configured state directory - or have
CreateTopLevelDirectoriescreate/run/containerdif the configured State is non-standard
The latter one could be something like;
if config.State != defaults.DefaultStateDir {
// FIXME: socket-paths in pkg/shim are hard-coded to the default location, so make sure this location is created.
if err := sys.MkdirAllWithACL(config.State, 0o711); err != nil {
return err
}
}It looks like taking that approach also makes sure that these directories are created with the same permissions and options as the default.
I agree. I neglected to look at
I have some containers that I would like to run with different containerd plugins/configurations that's separate from the "main" containerd instance serving K8s workloads.
I'll update my changes with this approach. Thanks for the thoughtful review. |
5a01677 to
ed5d5e8
Compare
ed5d5e8 to
688b05f
Compare
There are a couple directories that get created under the default
state directory ("/run/containerd") even when containerd is configured
to use a different location for its state directory. Create the default
state directory even if containerd is configured to use a different
state directory location. This ensure pkg/shim and pkg/fifo won't create
the default state directory with incorrect permissions when calling
os.MkdirAll for their respective subdirectories.
Signed-off-by: Erikson Tung <[email protected]>
688b05f to
551ac06
Compare
| return err | ||
| } | ||
| if config.State != defaults.DefaultStateDir { | ||
| // XXX: socketRoot in pkg/shim is hard-coded to the default state directory. |
There was a problem hiding this comment.
I've never seen XXX before, but apparently it's an old Java convention.
(no action required here)
|
/cherrypick release/1.7 |
|
@samuelkarp: new pull request created: #10534 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/cherrypick release/1.6 |
|
@samuelkarp: new pull request created: #10535 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/run/containerd gets created with correct perms
Issue: #10502 (specifically this comment about fixing the default state dir creation with expected perms 0711)
There are a couple directories that get created under the default
state directory ("/run/containerd") even when containerd is configured
to use a different location for its state directory. Create the default
state directory even if containerd is configured to use a different
state directory location. This ensure pkg/shim and pkg/fifo won't create
the default state directory with incorrect permissions when calling
os.MkdirAll for their respective subdirectories.