Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker support #5757

Merged
merged 6 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
}

int rsc_index(const char* name) {
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
Loading