-
Notifications
You must be signed in to change notification settings - Fork 522
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
Add support for bootstrap containers via API settings #1387
Add support for bootstrap containers via API settings #1387
Conversation
1b6608f
to
154f3c4
Compare
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.
Nice!
I've reviewed the changes to the unit dependencies; haven't looked at the actual bootstrap containers implementation yet.
@@ -154,7 +161,7 @@ func App() *cli.App { | |||
return app | |||
} | |||
|
|||
func runCtr(containerdSocket string, namespace string, containerID string, source string, superpowered bool) error { | |||
func runCtr(containerdSocket string, namespace string, containerID string, source string, superpowered bool, bootstrap bool) error { |
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.
Since this function's definition is getting fairly large, would it make sense to use a single struct containing the arguments (essentially the "config" of the container to run)? (The Go folks might have more to say about how idiomatic this would be).
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.
Since this is a private function that really only gets called in one place, I don't know if we need to do that yet. One change we could make is to separate this function a bit more. The first two arguments here are only used up until line 181 for constructing the client; if we extract the client object from this function and instead pass it in (either directly or as a data field on a receiver object) that might be a bit cleaner. I think that's the route I would go.
var persistentPath string | ||
|
||
if bootstrap { | ||
persistentPath = "bootstrap-containers/" + containerID |
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.
Do these make sense as constants?
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.
I used a different approach now, let me know if you still think the new approach should use constants
154f3c4
to
a4db0cd
Compare
sources/api/migration/migrations/v1.0.8/add-bootstrap-containers/src/main.rs
Show resolved
Hide resolved
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.
I haven't gotten through all the rust code in the third commit yet, but figured I'd stop here to get the questions I already have answered first. Two things I'd like to get worked out:
- If bootstrap containers can't be superpowered, we should enforce this assertion in the code of host-ctr
- If host containers and bootstrap containers are allowed to share the same name, we need to work out non-collision for the container IDs in containerd
a4db0cd
to
933955e
Compare
IMPORTANT UPDATEI changed the base branch to have this and #1423 reviewed in parallel Changes in forced push:
|
933955e
to
86a662d
Compare
Changes in forced push:
|
95c752a
to
cad9380
Compare
86a662d
to
db60990
Compare
|
I marked all the systemd changes as resolved since I separated those changes in #1423 |
cad9380
to
3874edb
Compare
db60990
to
01a31c2
Compare
|
196dc2e
to
74cbcdb
Compare
|
bcressey@ confirmed this needs regular re-review, but not a big red "changes requested" :)
74cbcdb
to
5153d08
Compare
|
5153d08
to
cceca9b
Compare
|
cceca9b
to
3b111ff
Compare
|
3b111ff
to
ce55093
Compare
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's a couple small changes I'd like to see in host-ctr
before merge.
// PersistentDir returns the persistent base directory for the container type | ||
func (ct ContainerType) PersistentDir() (string, bool) { | ||
switch ct { | ||
case Host: | ||
return "host-containers", true | ||
case Bootstrap: | ||
return "bootstrap-containers", true | ||
} | ||
|
||
return "", false | ||
} |
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.
The call sites for these don't seem to use the third state, and is not idiomatic in this case (return the zero value). Can we drop this from the signature please?
// PersistentDir returns the persistent base directory for the container type | |
func (ct ContainerType) PersistentDir() (string, bool) { | |
switch ct { | |
case Host: | |
return "host-containers", true | |
case Bootstrap: | |
return "bootstrap-containers", true | |
} | |
return "", false | |
} | |
// PersistentDir returns the persistent base directory for the container type | |
func (ct ContainerType) PersistentDir() string { | |
switch ct { | |
case Host: | |
return "host-containers" | |
case Bootstrap: | |
return "bootstrap-containers" | |
} | |
return "" | |
} |
// Prefix returns the prefix for the container type | ||
func (ct ContainerType) Prefix() (string, bool) { | ||
switch ct { | ||
case Bootstrap: | ||
return "boot.", true | ||
case Host: | ||
return "", true | ||
} | ||
|
||
return "", false | ||
} |
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.
The call sites for these don't seem to use the third state, and is not idiomatic in this case (return the zero value). Can we drop this from the signature please?
// Prefix returns the prefix for the container type | |
func (ct ContainerType) Prefix() (string, bool) { | |
switch ct { | |
case Bootstrap: | |
return "boot.", true | |
case Host: | |
return "", true | |
} | |
return "", false | |
} | |
// Prefix returns the prefix for the container type | |
func (ct ContainerType) Prefix() string { | |
switch ct { | |
case Bootstrap: | |
return "boot." | |
case Host: | |
return "" | |
} | |
return "" | |
} |
|
// Used to define valid container types | ||
type ContainerType string | ||
|
||
const ( | ||
Host ContainerType = "host" | ||
Bootstrap ContainerType = "bootstrap" | ||
) |
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.
GitHub lost my comment.
Please update this to keep the types private.
// Used to define valid container types | |
type ContainerType string | |
const ( | |
Host ContainerType = "host" | |
Bootstrap ContainerType = "bootstrap" | |
) | |
// Used to define valid container types | |
type containerType string | |
const ( | |
containerTypeHost containerType = "host" | |
containerTypeBootstrap containerType = "bootstrap" | |
) |
ce55093
to
7bc729c
Compare
|
This commit adds support for bootstrap containers in `host-ctr`. The `container-type` flag was added to specify the type of container to be setup, which defaults to `host`. This allows to add support for other type of containers in the future without adding flags for each of them. The root filesystem mounts were refactored out from `withSuperpowered` to `withRootFilesystemMounts`, since bootstrap containers require access to the underlying root filesystem without being given the superpowered treatment. Failed container tasks will now return an error if the task exited with a non-zero status.
This commit adds support to create bootstrap containers through the API. Bootstrap containers are host containers that can be used to setup the host during the execution of the `configured` target. These containers are created with the prefix `boot` to prevent collisions with normal host containers. They can be setup to fail the boot process if the underlying container task exists with a non-zero status code.
This commit updates the model name used to configure a host container from `ContainerImage` to `HostContainer`
This commit updates the permissions in `/etc/host-containers` from `755` to `750`
7bc729c
to
5894d58
Compare
|
Issue number:
#1392
Description of changes:
This commit updates the permissions in
/etc/host-containers
from755
to750
This commit updates the model name used to configure a host container from
ContainerImage
toHostContainer
This commit adds support to create bootstrap containers through the API. Bootstrap containers are host containers that can be used to setup the host during the execution of the
configured
target.These containers are created with the prefix
boot
to prevent collisions with normal host containers. They can be setup to fail the boot process if the underlying container task exists with a non-zero status code.This commit adds support for bootstrap containers in
host-ctr
. Thecontainer-type
flag was added to specify the type of container to be setup, which defaults tohost
. This allows to add support for other type of containers in the future without adding flags for each of them.The root filesystem mounts were refactored out from
withSuperpowered
towithRootFilesystemMounts
, since bootstrap containers require access to the underlying root filesystem without being given the superpowered treatment.Failed container tasks will now return an error if the task exited with a non-zero status.
Testing done:
In
k8s 1.18
,ecs
anddev
aarch64:systemctl status
to check that no units were failingnginx
pods/containers, access them andcurl http://localhost
successfullysystemctl isolate multi-user
to verify that no services were killed/restartedVerified that:
ʕ·͡ᴥ·ʔ
appears in the journal logs/var/lib/my_directory
was created, with the expected user/group ids, and permissions/local/bootstrap-containers/access
created through thecurrent
mountconfigured.target
was "blocked" for two minutesmark-successful-boot.service
executed successfullyUpdate the bootstrap container's configuration with
apiclient set bootstrap-containers.admin.mode=once
, reboot and verified its execution failed because/var/lib/my_dir
already exists.apiclient set bootstrap-containers.admin.essential=true
, reboot and verified the boot failed:Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.