confd: add support for upgrading container images

This patch adds a new CLI command 'container upgrade foo', where 'foo'
is the name of the container.  If more than one container use the same
image, multiple upgrades must be done because a container runs not on
the 'image:tag' but on the hash of the 'image:tag' it was created from.

Rename "done" queue to "active", since we want to recreate an active
container after fetching an updated base image.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2024-02-25 19:49:27 +01:00
parent aafa88b648
commit 31502c8aab
5 changed files with 24 additions and 6 deletions
+4 -4
View File
@@ -19,7 +19,7 @@
#define CFG_XPATH "/infix-containers:container"
#define INBOX_QUEUE "/run/containers/inbox"
#define JOB_QUEUE "/run/containers/queue"
#define DONE_QUEUE "/var/lib/containers/done"
#define ACTIVE_QUEUE "/var/lib/containers/active"
#define LOGGER "logger -t container -p local1.notice"
static const struct srx_module_requirement reqs[] = {
@@ -231,13 +231,13 @@ void infix_containers_launch(void)
}
while ((d = readdir(dir))) {
char curr[strlen(ACTIVE_QUEUE) + strlen(d->d_name) + 2];
char next[strlen(INBOX_QUEUE) + strlen(d->d_name) + 2];
char curr[strlen(DONE_QUEUE) + strlen(d->d_name) + 2];
snprintf(curr, sizeof(curr), "%s/%s", ACTIVE_QUEUE, d->d_name);
snprintf(next, sizeof(next), "%s/%s", INBOX_QUEUE, d->d_name);
snprintf(curr, sizeof(curr), "%s/%s", DONE_QUEUE, d->d_name);
if (!systemf("cmp %s %s", curr, next)) {
ERRNO("New job %s is already done, no changes, skipping.", next);
ERRNO("New job %s is already active, no changes, skipping.", next);
systemf("initctl -nbq cond set container:$(basename %s .sh)", d->d_name);
remove(next);
continue;
+7
View File
@@ -245,6 +245,13 @@
<PARAM name="name" ptype="/CONTAINERS" help="Container name" />
<ACTION sym="script" out="tty" interrupt="true">container stop $KLISH_PARAM_name</ACTION>
</COMMAND>
<COMMAND name="upgrade" help="Upgrade image of a container (writable layer is lost!)">
<PARAM name="name" ptype="/CONTAINERS" help="Container name" />
<ACTION sym="script" out="tty" interrupt="true">
container upgrade $KLISH_PARAM_name
</ACTION>
</COMMAND>
</COMMAND>
<COMMAND name="copy" help="Copy configuration, e.g., copy running-config startup-config">