aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2026-06-22 10:04:09 -0400
committerGitHub <noreply@github.com>2026-06-22 10:04:09 -0400
commit582744998b624cada2293a533e0cce5720433454 (patch)
tree1add7bfeb4da613b68b65a2b182852f5edc62513 /src
parente2008513b5fb4ae71d87ca6d05bdab5f3cb3a53f (diff)
downloadstasis-582744998b624cada2293a533e0cce5720433454.tar.gz
Always display information about docker even if its not available (#144)
* Update/add error messages indicating why docker checks failed
Diffstat (limited to 'src')
-rw-r--r--src/cli/stasis/system_requirements.c40
-rw-r--r--src/lib/core/docker.c33
2 files changed, 44 insertions, 29 deletions
diff --git a/src/cli/stasis/system_requirements.c b/src/cli/stasis/system_requirements.c
index a48c113..4eb0f3c 100644
--- a/src/cli/stasis/system_requirements.c
+++ b/src/cli/stasis/system_requirements.c
@@ -102,30 +102,28 @@ void check_system_requirements(struct Delivery *ctx) {
}
msg(STASIS_MSG_L2, "Docker\n");
- if (docker_capable(&ctx->deploy.docker.capabilities)) {
- struct DockerCapabilities *dcap = &ctx->deploy.docker.capabilities;
- msg(STASIS_MSG_L3, "Available: %s%s%s\n", dcap->available ? STASIS_COLOR_GREEN : STASIS_COLOR_RED, dcap->available ? "Yes" : "No", STASIS_COLOR_RESET);
- msg(STASIS_MSG_L3, "Usable: %s%s%s\n", dcap->usable ? STASIS_COLOR_GREEN : STASIS_COLOR_RED, dcap->usable ? "Yes" : "No", STASIS_COLOR_RESET);
- msg(STASIS_MSG_L3, "Podman [Docker Emulation]: %s\n", dcap->podman ? "Yes" : "No");
- msg(STASIS_MSG_L3, "Build plugin(s): ");
- if (dcap->build) {
- if (dcap->build & STASIS_DOCKER_BUILD) {
- msg(STASIS_MSG_RESTRICT, "build ");
- }
- if (dcap->build & STASIS_DOCKER_BUILD_X) {
- msg(STASIS_MSG_RESTRICT, "buildx ");
- }
- msg(STASIS_MSG_RESTRICT,"\n");
- } else {
- msg(STASIS_MSG_RESTRICT, "%sN/A%s\n", STASIS_COLOR_YELLOW, STASIS_COLOR_RESET);
+ struct DockerCapabilities *dcap = &ctx->deploy.docker.capabilities;
+ docker_capable(dcap);
+ if (!globals.enable_docker) {
+ dcap->usable = false;
+ }
+ msg(STASIS_MSG_L3, "Available: %s%s%s\n", dcap->available ? STASIS_COLOR_GREEN : STASIS_COLOR_RED, dcap->available ? "Yes" : "No", STASIS_COLOR_RESET);
+ msg(STASIS_MSG_L3, "Usable: %s%s%s %s\n", dcap->usable ? STASIS_COLOR_GREEN : STASIS_COLOR_RED, dcap->usable ? "Yes" : "No", STASIS_COLOR_RESET, globals.enable_docker ? "" : STASIS_COLOR_GREEN "(disabled by CLI argument)" STASIS_COLOR_RESET);
+ msg(STASIS_MSG_L3, "Podman [Docker Emulation]: %s\n", dcap->podman ? "Yes" : "No");
+ msg(STASIS_MSG_L3, "Build plugin(s): ");
+ if (dcap->build) {
+ if (dcap->build & STASIS_DOCKER_BUILD) {
+ msg(STASIS_MSG_RESTRICT, "build ");
}
-
- if (!dcap->usable) {
- // disable docker builds
- globals.enable_docker = false;
+ if (dcap->build & STASIS_DOCKER_BUILD_X) {
+ msg(STASIS_MSG_RESTRICT, "buildx ");
}
+ msg(STASIS_MSG_RESTRICT,"\n");
} else {
- SYSWARN("Docker is broken");
+ msg(STASIS_MSG_RESTRICT, "%sN/A%s\n", STASIS_COLOR_YELLOW, STASIS_COLOR_RESET);
+ }
+ if (!dcap->usable) {
+ SYSWARN("Docker related tasks are now disabled");
// disable docker builds
globals.enable_docker = false;
}
diff --git a/src/lib/core/docker.c b/src/lib/core/docker.c
index 84fdfd5..48ba2ed 100644
--- a/src/lib/core/docker.c
+++ b/src/lib/core/docker.c
@@ -1,6 +1,5 @@
#include "docker.h"
-
int docker_exec(const char *args, const unsigned flags) {
struct Process proc;
char cmd[PATH_MAX];
@@ -40,13 +39,13 @@ int docker_script(const char *image, char *args, char *data, const unsigned flag
FILE *outfile = popen(cmd, "w");
if (!outfile) {
- // opening command pipe for writing failed
+ SYSERROR("opening command pipe for writing failed");
return -1;
}
FILE *infile = fmemopen(data, strlen(data), "r");
if (!infile) {
- // opening memory file for reading failed
+ SYSERROR("opening memory file for reading failed");
pclose(outfile);
return -1;
}
@@ -104,9 +103,13 @@ int docker_save(const char *image, const char *destdir, const char *compression_
}
static int docker_exists() {
- if (find_program("docker")) {
+ const char *prog = find_program("docker");
+ if (prog) {
+ SYSDEBUG("Found in PATH: %s", prog);
return true;
}
+ const char *pathvar = getenv(PATH_ENV_VAR);
+ SYSDEBUG("Not found in PATH: %s", pathvar ? pathvar : "PATH UNDEFINED");
return false;
}
@@ -118,6 +121,7 @@ static char *docker_ident() {
tempfile = xmkstemp(&fp, "w+");
if (!fp || !tempfile) {
+ SYSERROR("unable to open temporary file for writing");
return NULL;
}
@@ -129,12 +133,13 @@ static char *docker_ident() {
shell(&proc, "docker --version");
if (!freopen(tempfile, "r", fp)) {
+ SYSERROR("unable to open temporary file for reading");
remove(tempfile);
- guard_free(tempfile);
return NULL;
}
if (!fgets(line, sizeof(line) - 1, fp)) {
+ SYSERROR("unable to read version from docker output");
fclose(fp);
remove(tempfile);
guard_free(tempfile);
@@ -149,17 +154,25 @@ static char *docker_ident() {
}
int docker_capable(struct DockerCapabilities *result) {
+ const int quiet = LOG_LEVEL < LOG_LEVEL_DEBUG;
char *version = NULL;
memset(result, 0, sizeof(*result));
+ int flags = 0;
+ if (quiet) {
+ flags |= STASIS_DOCKER_QUIET_STDOUT;
+ }
+
if (!docker_exists()) {
// docker isn't available
+ SYSDEBUG("docker not found in PATH");
return false;
}
result->available = true;
- if (docker_exec("ps", STASIS_DOCKER_QUIET)) {
+ if (docker_exec("ps", flags)) {
// user cannot connect to the socket
+ SYSERROR("unable to run a basic docker command");
return false;
}
@@ -169,13 +182,16 @@ int docker_capable(struct DockerCapabilities *result) {
}
guard_free(version);
- if (!docker_exec("buildx build --help", STASIS_DOCKER_QUIET)) {
+ if (!docker_exec("buildx build --help >/dev/null", flags)) {
+ SYSDEBUG("buildx plugin is present");
result->build |= STASIS_DOCKER_BUILD_X;
}
- if (!docker_exec("build --help", STASIS_DOCKER_QUIET)) {
+ if (!docker_exec("build --help >/dev/null", STASIS_DOCKER_QUIET)) {
+ SYSDEBUG("build plugin is present");
result->build |= STASIS_DOCKER_BUILD;
}
if (!result->build) {
+ SYSDEBUG("docker has no build plugin(s) installed!");
// can't use docker without a build plugin
return false;
}
@@ -206,6 +222,7 @@ int docker_validate_compression_program(char *prog) {
goto invalid;
}
result = find_program(parts[0]) ? 0 : -1;
+ SYSDEBUG("result = %d", result);
invalid:
guard_array_free(parts);