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

[sched] add docker plan class spec #5761

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
126 changes: 126 additions & 0 deletions sched/plan_class_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,124 @@ bool PLAN_CLASS_SPEC::check(
return false;
}

if (docker){
if (!(sreq.host.docker_available)) {
add_no_work_message("Docker is not installed or is not available");
return false;
}

if (docker_compose && !(sreq.host.docker_compose_available)) {
add_no_work_message("Docker compose is not installed or is not available");
return false;
}
if (!sreq.host.wsl_distros.distros.empty()) {
bool docker_found = false;
bool docker_compose_found = false;
for (int i = 0; i < sreq.host.wsl_distros.distros.size(); i++) {
if (sreq.host.wsl_distros.distros[i].is_docker_available) {
if (docker_compose && sreq.host.wsl_distros.distros[i].is_docker_compose_available) {
int maj, min, rel;
int n = sscanf(sreq.host.wsl_distros.distros[i].docker_version.c_str(), "%d.%d.%d", &maj, &min, &rel);
if (n != 3) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] plan_class_spec: can't parse docker version\n"
);
continue;
}
}
int v = maj*10000 + min*100 + rel;
if (min_docker_version && v < min_docker_version) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] plan_class_spec: docker version too low: %d < %d\n",
v, min_docker_version
);
continue;
}
}
docker_found = true;
}
if (!docker_compose && docker_found) {
break;
}
}
if (docker_compose && sreq.host.wsl_distros.distros[i].is_docker_compose_available) {
int maj, min, rel;
int n = sscanf(sreq.host.wsl_distros.distros[i].docker_compose_version.c_str(), "%d.%d.%d", &maj, &min, &rel);
if (n != 3) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] plan_class_spec: can't parse docker compose version\n"
);
continue;
}
}
int v = maj*10000 + min*100 + rel;
if (min_docker_compose_version && v < min_docker_compose_version) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] plan_class_spec: docker compose version too low: %d < %d\n",
v, min_docker_compose_version
);
continue;
}
}
docker_compose_found = true;
}
}
if (!docker_found) {
add_no_work_message("Suitable Docker is not installed or is not available");
return false;
}
if (docker_compose && !docker_compose_found) {
add_no_work_message("Suitable Docker compose is not installed or is not available");
return false;
}
} else {
int maj, min, rel;
int n = sscanf(sreq.host.docker_version, "%d.%d.%d", &maj, &min, &rel);
if (n != 3) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] plan_class_spec: can't parse docker version\n"
);
}
return false;
}
int v = maj*10000 + min*100 + rel;
if (min_docker_version && v < min_docker_version) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] plan_class_spec: docker version too low: %d < %d\n",
v, min_docker_version
);
}
return false;
}

n = sscanf(sreq.host.docker_compose_version, "%d.%d.%d", &maj, &min, &rel);
if (n != 3) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] plan_class_spec: can't parse docker compose version\n"
);
}
return false;
}
v = maj*10000 + min*100 + rel;
if (min_docker_compose_version && v < min_docker_compose_version) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] plan_class_spec: docker compose version too low: %d < %d\n",
v, min_docker_compose_version
);
}
return false;
}
}
}

if (virtualbox) {

// host must run 7.0+ client
Expand Down Expand Up @@ -1109,6 +1227,10 @@ int PLAN_CLASS_SPEC::parse(XML_PARSER& xp) {
if (xp.parse_bool("opencl", opencl)) continue;
if (xp.parse_bool("virtualbox", virtualbox)) continue;
if (xp.parse_bool("wsl", wsl)) continue;
if (xp.parse_bool("docker", docker)) continue;
if (xp.parse_bool("docker_compose", docker_compose)) continue;
if (xp.parse_int("min_docker_version", min_docker_version)) continue;
if (xp.parse_int("min_docker_compose_version", min_docker_compose_version)) continue;
if (xp.parse_bool("is64bit", is64bit)) continue;
if (xp.parse_str("cpu_feature", buf, sizeof(buf))) {
cpu_features.push_back(" " + (string)buf + " ");
Expand Down Expand Up @@ -1255,6 +1377,10 @@ PLAN_CLASS_SPEC::PLAN_CLASS_SPEC() {
opencl = false;
virtualbox = false;
wsl = false;
docker = false;
docker_compose = false;
min_docker_version = 0;
min_docker_compose_version = 0;
is64bit = false;
min_ncpus = 0;
max_threads = 1;
Expand Down
4 changes: 4 additions & 0 deletions sched/plan_class_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ struct PLAN_CLASS_SPEC {
bool opencl;
bool virtualbox;
bool wsl;
bool docker;
bool docker_compose;
int min_docker_version;
int min_docker_compose_version;
bool is64bit;
std::vector<std::string> cpu_features;
double min_ncpus;
Expand Down
12 changes: 12 additions & 0 deletions sched/plan_class_spec.xml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,16 @@
<name> wsl </name>
<wsl/>
</plan_class>
<plan_class>
<name> docker </name>
<docker/>
<min_docker_version> 270102 </min_docker_version>
</plan_class>
<plan_class>
<name> docker_compose </name>
<docker/>
<docker_compose/>
<min_docker_version> 270102 </min_docker_version>
<min_docker_compose_version>32901 </min_docker_compose_version>
</plan_class>
</plan_classes>
20 changes: 20 additions & 0 deletions sched/sched_customize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,24 @@ static inline bool app_plan_opencl(
}
}

//plan class for Docker jobs
//
static inline bool app_plan_docker(
SCHEDULER_REQUEST& sreq, char* plan_class
){
if (!(sreq.host.docker_available)) {
add_no_work_message("Docker is not installed or is not available");
return false;
}

if (strstr(plan_class, "compose") && !(sreq.host.docker_compose_available)) {
add_no_work_message("Docker compose is not installed or is not available");
return false;
}

return true;
}

// handles vbox[32|64][_[mt]|[hwaccel]]
// "mt" is tailored to the needs of CERN:
// use 1 or 2 CPUs
Expand Down Expand Up @@ -1026,6 +1044,8 @@ bool app_plan(SCHEDULER_REQUEST& sreq, char* plan_class, HOST_USAGE& hu, const W
return app_plan_vbox(sreq, plan_class, hu);
} else if (strstr(plan_class, "wsl")) {
return app_plan_wsl(sreq, plan_class, hu);
} else if (strstr(plan_class, "docker")){
return app_plan_docker(sreq, plan_class);
}
log_messages.printf(MSG_CRITICAL,
"Unknown plan class: %s\n", plan_class
Expand Down
Loading