mirror of https://github.com/BOINC/boinc.git
debug docker_wrapper on Linux
Make 'verbose' an attribute of DOCKER_CONN.
This commit is contained in:
parent
c7c8fea320
commit
733b1f7952
18
lib/util.cpp
18
lib/util.cpp
|
@ -701,7 +701,7 @@ string parse_ldd_libc(const char* input) {
|
|||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
int DOCKER_CONN::init(DOCKER_TYPE docker_type, string distro_name) {
|
||||
int DOCKER_CONN::init(DOCKER_TYPE docker_type, string distro_name, bool _verbose) {
|
||||
cli_prog = docker_cli_prog(docker_type);
|
||||
if (docker_type == DOCKER) {
|
||||
int retval = ctl_wc.setup();
|
||||
|
@ -714,16 +714,18 @@ int DOCKER_CONN::init(DOCKER_TYPE docker_type, string distro_name) {
|
|||
} else {
|
||||
return -1;
|
||||
}
|
||||
verbose = _verbose;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int DOCKER_CONN::init(DOCKER_TYPE docker_type) {
|
||||
int DOCKER_CONN::init(DOCKER_TYPE docker_type, bool _verbose) {
|
||||
cli_prog = docker_cli_prog(docker_type);
|
||||
verbose = _verbose;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int DOCKER_CONN::command(const char* cmd, vector<string> out, bool verbose) {
|
||||
int DOCKER_CONN::command(const char* cmd, vector<string> &out) {
|
||||
char buf[1024];
|
||||
int retval;
|
||||
if (verbose) {
|
||||
|
@ -745,10 +747,15 @@ int DOCKER_CONN::command(const char* cmd, vector<string> out, bool verbose) {
|
|||
#else
|
||||
sprintf(buf, "%s %s\n", cli_prog, cmd);
|
||||
retval = run_command(buf, out);
|
||||
if (retval) return retval;
|
||||
if (retval) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "command failed: %s\n", boincerror(retval));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
if (verbose) {
|
||||
fprintf(stderr, "output:\n");
|
||||
fprintf(stderr, "command output:\n");
|
||||
for (string line: out) {
|
||||
fprintf(stderr, "%s\n", line.c_str());
|
||||
}
|
||||
|
@ -756,7 +763,6 @@ int DOCKER_CONN::command(const char* cmd, vector<string> out, bool verbose) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
// localhost/boinc__app_test__test_wu latest cbc1498dfc49 43 hours ago 121 MB
|
||||
|
||||
|
|
10
lib/util.h
10
lib/util.h
|
@ -151,15 +151,15 @@ extern double simtime;
|
|||
struct DOCKER_CONN {
|
||||
DOCKER_TYPE type;
|
||||
const char* cli_prog;
|
||||
bool verbose;
|
||||
#ifdef _WIN32
|
||||
WSL_CMD ctl_wc;
|
||||
int init(DOCKER_TYPE type, std::string distro_name);
|
||||
int init(DOCKER_TYPE type, std::string distro_name, bool verbose);
|
||||
#else
|
||||
int init(DOCKER_TYPE);
|
||||
int init(DOCKER_TYPE, bool verbose);
|
||||
#endif
|
||||
int command(
|
||||
const char* cmd, std::vector<std::string> out, bool verbose=false
|
||||
);
|
||||
int command(const char* cmd, std::vector<std::string> &out);
|
||||
|
||||
static const int TIMEOUT = 10; // timeout for docker commands
|
||||
|
||||
// parse a line from "docker images" output; return name
|
||||
|
|
|
@ -483,7 +483,7 @@ int wsl_init() {
|
|||
distro_name = distro->distro_name;
|
||||
docker_type = distro->docker_type;
|
||||
}
|
||||
return docker_conn.init (docker_type, distro_name);
|
||||
return docker_conn.init(docker_type, distro_name, verbose);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -555,7 +555,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
#else
|
||||
docker_conn.init(
|
||||
boinc_is_standalone()?DOCKER:aid.host_info.docker_type
|
||||
boinc_is_standalone()?DOCKER:aid.host_info.docker_type, verbose
|
||||
);
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue