Autostart is not working correctly
sebs2837 opened this issue · comments
Hey,
I just noticed that autostart for containers is not working correctly in the current release northstar-runtime 0.5.0.
Here is a bit more detailed description:
When configuring a container to autostart, Northstar should start the container automatically
currently those containers are not started anymore.
Here is an examplified config:
name: hello-world
version: 0.0.1
init: /hello-world
uid: 1000
gid: 1000
autostart: relaxed
env:
HELLO: northstar
io:
stdout: pipe
stderr: pipe
mounts:
/dev:
type: dev
/proc:
type: proc
/lib:
type: bind
host: /lib
/lib64:
type: bind
host: /lib64
/system:
type: bind
host: /system
IMO the handling of containers that should be auto started is wrong in northstar-runtime/src/runtime/state.rs:274
if !to_mount.is_empty() {
self.mount_all(&to_mount).await;
for (container, autostart) in autostarts {
info!("Autostarting {} ({:?})", container, autostart);
if let Err(e) = self
.start(&container, &[], &HashMap::with_capacity(0))
.await
{
Self::warn_autostart_failure(&container, &autostart, e)?
}
}
}
With this implementation only containers with a resource will be auto started.
Possible solution mount resources then start
if !to_mount.is_empty() {
self.mount_all(&to_mount).await;
}
for (container, autostart) in autostarts {
info!("Autostarting {} ({:?})", container, autostart);
if let Err(e) = self
.start(&container, &[], &HashMap::with_capacity(0))
.await
{
Self::warn_autostart_failure(&container, &autostart, e)?
}
}
Cheers
Sebs