Skip to content

Commit

Permalink
Merge pull request #5757 from BOINC/vko_wsl_docker
Browse files Browse the repository at this point in the history
Add docker support
  • Loading branch information
davidpanderson authored Aug 19, 2024
2 parents fd8eec8 + 0a354f5 commit 38b131d
Show file tree
Hide file tree
Showing 14 changed files with 397 additions and 112 deletions.
36 changes: 34 additions & 2 deletions client/client_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void CLIENT_STATE::show_host_info() {

#ifdef _WIN64
if (host_info.wsl_available) {
msg_printf(NULL, MSG_INFO, "WSL detected:");
msg_printf(NULL, MSG_INFO, "WSL present:");
for (size_t i = 0; i < host_info.wsls.wsls.size(); ++i) {
const WSL& wsl = host_info.wsls.wsls[i];
if (wsl.is_default) {
Expand All @@ -262,7 +262,7 @@ void CLIENT_STATE::show_host_info() {
}
}
} else {
msg_printf(NULL, MSG_INFO, "No WSL found.");
msg_printf(NULL, MSG_INFO, "WSL is not present or is not allowed by configuration file. For more details see https://github.com/BOINC/boinc/wiki/Client-configuration");
}
#endif

Expand All @@ -280,6 +280,38 @@ void CLIENT_STATE::show_host_info() {
}
#endif
}
#ifdef _WIN64
if (host_info.docker_available) {
msg_printf(NULL, MSG_INFO, "Docker is present on next WSLs:");
for (size_t i = 0; i < host_info.wsls.wsls.size(); ++i) {
const WSL& wsl = host_info.wsls.wsls[i];
if (wsl.is_docker_available) {
msg_printf(NULL, MSG_INFO, " [%s]: Docker version is: %s", wsl.distro_name.c_str(), wsl.docker_version.c_str());
}
}
#else
if (host_info.docker_available && strlen(host_info.docker_version)) {
msg_printf(NULL, MSG_INFO, "Docker %s is present", host_info.docker_version);
#endif
} else {
msg_printf(NULL, MSG_INFO, "Docker is not present");
}
#ifdef _WIN64
if (host_info.docker_compose_available) {
msg_printf(NULL, MSG_INFO, "Docker compose is present on next WSLs:");
for (size_t i = 0; i < host_info.wsls.wsls.size(); ++i) {
const WSL& wsl = host_info.wsls.wsls[i];
if (wsl.is_docker_compose_available) {
msg_printf(NULL, MSG_INFO, " [%s]: Docker compose version is: %s", wsl.distro_name.c_str(), wsl.docker_compose_version.c_str());
}
}
#else
if (host_info.docker_compose_available && strlen(host_info.docker_compose_version)) {
msg_printf(NULL, MSG_INFO, "Docker compose %s is present", host_info.docker_compose_version);
#endif
} else {
msg_printf(NULL, MSG_INFO, "Docker compose is not present");
}
}

// TODO: the following 3 should be members of COPROCS
Expand Down
11 changes: 9 additions & 2 deletions client/cs_statefile.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2022 University of California
// https://boinc.berkeley.edu
// Copyright (C) 2024 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
Expand Down Expand Up @@ -970,6 +970,13 @@ int CLIENT_STATE::parse_app_info(PROJECT* p, FILE* in) {
delete avp;
continue;
}
if (cc_config.dont_use_docker && strstr(avp->plan_class, "docker")) {
msg_printf(p, MSG_INFO,
"skipping docker app in app_info.xml; docker disabled in cc_config.xml"
);
delete avp;
continue;
}
if (strlen(avp->platform) == 0) {
safe_strcpy(avp->platform, get_primary_platform());
}
Expand Down
49 changes: 45 additions & 4 deletions client/hostinfo_unix.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2021 University of California
// https://boinc.berkeley.edu
// Copyright (C) 2024 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
Expand All @@ -20,7 +20,6 @@
// Try to keep this well-organized and not nested.

#include "version.h" // version numbers from autoconf

#include "cpp.h"
#include "config.h"

Expand Down Expand Up @@ -1231,10 +1230,47 @@ int HOST_INFO::get_virtualbox_version() {
pclose(fd);
}
}

return 0;
}

// check if docker compose is installed on volunteer's host
// populates docker compose version and docker_compose_available on success
bool HOST_INFO::get_docker_compose_info(){
FILE* f = popen(command_get_docker_compose_version, "r");
if (f) {
char buf[256];
fgets(buf, 256, f);
std::string version;
if (get_docker_compose_version_string(buf, version)) {
docker_compose_available = true;
safe_strcpy(docker_compose_version, version.c_str());
}
pclose(f);
return true;
}
return false;
}


// check if docker is installed on volunteer's host
// populates docker version and docker_available on success
bool HOST_INFO::get_docker_info(){
FILE* f = popen(command_get_docker_version, "r");
if (f) {
char buf[256];
fgets(buf, 256, f);
std::string version;
if (get_docker_version_string(buf, version)) {
docker_available = true;
safe_strcpy(docker_version, version.c_str());
}
pclose(f);
return true;
}
return false;
}


// get p_vendor, p_model, p_features
//
int HOST_INFO::get_cpu_info() {
Expand Down Expand Up @@ -1682,6 +1718,11 @@ int HOST_INFO::get_host_info(bool init) {
get_virtualbox_version();
}

if(!cc_config.dont_use_docker){
get_docker_info();
get_docker_compose_info();
}

get_cpu_info();
get_cpu_count();
get_memory_info();
Expand Down
7 changes: 3 additions & 4 deletions client/hostinfo_win.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2018 University of California
// https://boinc.berkeley.edu
// Copyright (C) 2024 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
Expand Down Expand Up @@ -1550,7 +1550,6 @@ int get_network_usage_totals(unsigned int& total_received, unsigned int& total_s
return iRetVal;
}


// see if Virtualbox is installed
//
int HOST_INFO::get_virtualbox_version() {
Expand Down Expand Up @@ -1670,7 +1669,7 @@ int HOST_INFO::get_host_info(bool init) {
if (!cc_config.dont_use_wsl) {
OSVERSIONINFOEX osvi;
if (get_OSVERSIONINFO(osvi) && osvi.dwMajorVersion >= 10) {
get_wsl_information(wsl_available, wsls);
get_wsl_information(cc_config.allowed_wsls, wsl_available, wsls, !cc_config.dont_use_docker, docker_available, docker_compose_available);
}
}
#endif
Expand Down
Loading

0 comments on commit 38b131d

Please sign in to comment.