From 1a8477fac1de100ba745c92185b7fd463b442ae4 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 21 Aug 2024 00:40:50 -0700 Subject: [PATCH] Unix build fixes. Generally use 'available' instead of 'present'. If dont_user_docker is set (or WSL, or vbox), we don't even check for it, so we don't know if it's present. 'Available' means it's allowed and present. --- client/client_state.cpp | 12 ++++-------- client/hostinfo_unix.cpp | 4 ++-- db/boinc_db_types.h | 6 +++--- lib/hostinfo.cpp | 15 ++++++++++----- lib/hostinfo.h | 5 +++-- lib/wslinfo.h | 10 +++++----- sched/sched_types.cpp | 3 +-- 7 files changed, 28 insertions(+), 27 deletions(-) diff --git a/client/client_state.cpp b/client/client_state.cpp index e7a5657af3..acf00de20c 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -292,19 +292,15 @@ void CLIENT_STATE::show_host_info() { } #ifndef _WIN64 - if (host_info.docker_present && strlen(host_info.docker_version)) { - msg_printf(NULL, MSG_INFO, "Docker %s is present", + if (host_info.docker_available && strlen(host_info.docker_version)) { + msg_printf(NULL, MSG_INFO, "Docker version %s found", host_info.docker_version ); - } else { - msg_printf(NULL, MSG_INFO, "Docker is not present"); } - if (host_info.docker_compose_present && strlen(host_info.docker_compose_version)) { - msg_printf(NULL, MSG_INFO, "Docker compose %s is present", + if (host_info.docker_compose_available && strlen(host_info.docker_compose_version)) { + msg_printf(NULL, MSG_INFO, "Docker compose version %s found", host_info.docker_compose_version ); - } else { - msg_printf(NULL, MSG_INFO, "Docker compose is not present"); } #endif } diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp index 08d21d6045..972cb6fb40 100644 --- a/client/hostinfo_unix.cpp +++ b/client/hostinfo_unix.cpp @@ -1242,7 +1242,7 @@ bool HOST_INFO::get_docker_compose_info(){ fgets(buf, 256, f); std::string version; if (get_docker_compose_version_string(buf, version)) { - docker_compose_present = true; + docker_compose_available = true; safe_strcpy(docker_compose_version, version.c_str()); } pclose(f); @@ -1261,7 +1261,7 @@ bool HOST_INFO::get_docker_info(){ fgets(buf, 256, f); std::string version; if (get_docker_version_string(buf, version)) { - docker_present = true; + docker_available = true; safe_strcpy(docker_version, version.c_str()); } pclose(f); diff --git a/db/boinc_db_types.h b/db/boinc_db_types.h index 53fab3f1e4..3586820dd8 100644 --- a/db/boinc_db_types.h +++ b/db/boinc_db_types.h @@ -372,11 +372,11 @@ struct HOST { bool p_vm_extensions_disabled; int num_opencl_cpu_platforms; OPENCL_CPU_PROP opencl_cpu_prop[MAX_OPENCL_CPU_PLATFORMS]; - bool wsl_available; - WSLS wsls; + WSL_DISTROS wsl_distros; - //Docker available + // Docker info (non-Win only) bool docker_available; + // present and allowed by config bool docker_compose_available; char docker_version[256]; char docker_compose_version[256]; diff --git a/lib/hostinfo.cpp b/lib/hostinfo.cpp index 1c661e0bfc..6adf88bd44 100644 --- a/lib/hostinfo.cpp +++ b/lib/hostinfo.cpp @@ -74,8 +74,8 @@ void HOST_INFO::clear_host_info() { #ifdef _WIN64 wsl_distros.clear(); #else - docker_present = false; - docker_compose_present = false; + docker_available = false; + docker_compose_available = false; safe_strcpy(docker_version, ""); safe_strcpy(docker_compose_version, ""); #endif @@ -142,7 +142,8 @@ int HOST_INFO::parse(XML_PARSER& xp, bool static_items_only) { continue; } #else - if (xp.parse_bool("docker_present", docker_present)) continue; + if (xp.parse_bool("docker_available", docker_available)) continue; + if (xp.parse_bool("docker_compose_available", docker_compose_available)) continue; if (xp.parse_str("docker_version", docker_version, sizeof(docker_version))) continue; if (xp.parse_str("docker_compose_version", docker_compose_version, sizeof(docker_compose_version))) continue; #endif @@ -238,8 +239,12 @@ int HOST_INFO::write( #else out.printf( - " %d\n", - docker_present ? 1 : 0 + " %d\n", + docker_available ? 1 : 0 + ); + out.printf( + " %d\n", + docker_compose_available ? 1 : 0 ); if (strlen(docker_version)) { out.printf( diff --git a/lib/hostinfo.h b/lib/hostinfo.h index f87f323334..760e911fa0 100644 --- a/lib/hostinfo.h +++ b/lib/hostinfo.h @@ -89,8 +89,9 @@ public: // on Windows, Docker info is per WSL_DISTRO, not global WSL_DISTROS wsl_distros; #else - bool docker_present; - bool docker_compose_present; + bool docker_available; + // Docker is present and allowed by config + bool docker_compose_available; char docker_version[256]; char docker_compose_version[256]; #endif diff --git a/lib/wslinfo.h b/lib/wslinfo.h index 9b3b72896c..613a46af25 100644 --- a/lib/wslinfo.h +++ b/lib/wslinfo.h @@ -35,15 +35,15 @@ struct WSL_DISTRO { int wsl_version; // version of WSL (currently 1 or 2) bool is_default; - // whether this is the default distro + // this is the default distro bool is_docker_available; - // whether Docker is available in this distro + // Docker is present and allowed by config bool is_docker_compose_available; - // whether Docker Compose is available in this distro + // Docker Compose is present and allowed by config std::string docker_version; - // version of Docker in this distro + // version of Docker std::string docker_compose_version; - // version of Docker Compose in this distro + // version of Docker Compose WSL_DISTRO(); void clear(); diff --git a/sched/sched_types.cpp b/sched/sched_types.cpp index 71a2cbb50c..65e5ba7354 100644 --- a/sched/sched_types.cpp +++ b/sched/sched_types.cpp @@ -1412,9 +1412,8 @@ int HOST::parse(XML_PARSER& xp) { if (!retval) num_opencl_cpu_platforms++; continue; } - if (xp.parse_bool("wsl_available", wsl_available)) continue; if (xp.match_tag("wsl")) { - wsls.parse(xp); + wsl_distros.parse(xp); continue; }