Skip to content

Commit bc18e32

Browse files
committed
Making sure that sandbox from worker config is used when no sandbox name is selected in the job config.
1 parent 943c04c commit bc18e32

6 files changed

Lines changed: 14 additions & 11 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,8 @@ use. The package names are for CentOS if not specified otherwise.
4545
(`libzmq3-dev` on Debian)
4646
- YAML-CPP library, `yaml-cpp` and `yaml-cpp-devel` (`libyaml-cpp0.5v5` and
4747
`libyaml-cpp-dev` on Debian)
48-
- libcurl library `libcurl-devel` (`libcurl4-gnutls-dev` on Debian)
49-
- libarchive library as optional dependency. Installing will speed up build
50-
process, otherwise libarchive is built from source during installation.
51-
Package name is `libarchive` and `libarchive-devel` (`libarchive-dev` on
52-
Debian)
48+
- libcurl library `libcurl-devel` (`libcurl4-dev` on Debian)
49+
- libarchive library as optional dependency. Installing will speed up build process, otherwise libarchive is built from source during installation. Package name is `libarchive` and `libarchive-devel` (`libarchive-dev` on Debian)
5350

5451
**Isolate** (only for Linux installations)
5552

‎examples/config.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ limits:
6464
mode: "tmp" # if mode is omitted, dir is mounted as read-only (which is typical for lib dirs)
6565
#- src: "/usr/share/something" # actually existing directory
6666
# dst: "/something" # where the directory will be mounted in sandbox fs
67-
# mode: "rw" # multiple modes can be separated by comma, see http://www.ucw.cz/moe/isolate.1.html (directory rules - options)
67+
# mode: "rw" # multiple modes can be separated by comma
6868
max-output-length: 4096 # in bytes
6969
max-carboncopy-length: 1048576 # in bytes
7070
cleanup-submission: false # if true, then folders with data concerning submissions will be cleared after evaluation, should be used carefully, can produce huge amount of used disk space

‎src/helpers/config.cpp‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,7 @@ std::shared_ptr<job_metadata> helpers::build_job_metadata(const YAML::Node &conf
159159

160160
if (ctask["sandbox"]["name"] && ctask["sandbox"]["name"].IsScalar()) {
161161
sandbox->name = ctask["sandbox"]["name"].as<std::string>();
162-
} else {
163-
throw config_exception("Name of sandbox not given");
164-
}
162+
} // can be omitted, will be filled from worker config... no throw
165163

166164
if (ctask["sandbox"]["stdin"] && ctask["sandbox"]["stdin"].IsScalar()) {
167165
sandbox->std_input = ctask["sandbox"]["stdin"].as<std::string>();

‎src/job/job.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ void job::build_job()
116116

117117
auto sandbox = task_meta->sandbox;
118118

119+
if (sandbox->name.empty()) {
120+
// if the sandbox is not specified in the job, use worker config instead
121+
sandbox->name = worker_config_->get_sandbox_name();
122+
}
123+
124+
// and let's make sure that one of the sandboxes is specified
119125
if (sandbox->name.empty()) { throw job_exception("Sandbox name cannot be empty"); }
120126

121127
// first we have to get appropriate hwgroup limits

‎tests/job.cpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ TEST(job_test, empty_tasks_details)
277277
task->binary = "hello";
278278
auto sandbox = std::make_shared<sandbox_config>();
279279
task->sandbox = sandbox;
280-
EXPECT_THROW(job(job_meta, worker_conf, dir_root, dir, temp_directory_path(), factory, nullptr), job_exception);
280+
job j(job_meta, worker_conf, dir_root, dir, temp_directory_path(), factory, nullptr);
281+
// job_meta has one task, which is updated by the job (sandbox name is filled from worker config)
282+
ASSERT_EQ(task->sandbox->name, worker_conf->get_sandbox_name()); // sandbox name is filled from worker config
281283

282284
// cleanup after yourself
283285
remove_all(dir_root);

‎tests/mocks.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using namespace testing;
2323

2424

2525
/**
26-
* A mock configuration object. Inverval of pinging is 1 second.
26+
* A mock configuration object. Interval of pinging is 1 second.
2727
*/
2828
class mock_worker_config : public worker_config
2929
{

0 commit comments

Comments
 (0)