summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-02-02 12:42:45 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-02-02 12:42:45 +0100
commit245f09bd220695664e754f5407f424e9033c322c (patch)
tree4b3ec7357419b97ac9ebb38a1c9d326d732bd9d1 /src
parent928b85f24bee213442a596675143eb06a29b1550 (diff)
Add network-mode setting for endpoints
This patch adds the ability to set network mode for an endpoint. This means that all containers on the endpoint are started with, for example, --net=host (if that is desired). Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src')
-rw-r--r--src/config/endpoint_config.rs3
-rw-r--r--src/endpoint/configured.rs22
2 files changed, 20 insertions, 5 deletions
diff --git a/src/config/endpoint_config.rs b/src/config/endpoint_config.rs
index b1734c8..12a588a 100644
--- a/src/config/endpoint_config.rs
+++ b/src/config/endpoint_config.rs
@@ -37,6 +37,9 @@ pub struct Endpoint {
/// Maximum number of jobs which are allowed on this endpoint
#[getset(get_copy = "pub")]
maxjobs: usize,
+
+ #[getset(get = "pub")]
+ network_mode: Option<String>,
}
/// The type of an endpoint
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs
index 7d38c45..83d51b4 100644
--- a/src/endpoint/configured.rs
+++ b/src/endpoint/configured.rs
@@ -51,6 +51,9 @@ pub struct Endpoint {
num_max_jobs: usize,
#[getset(get = "pub")]
+ network_mode: Option<String>,
+
+ #[getset(get = "pub")]
uri: String,
}
@@ -116,6 +119,7 @@ impl Endpoint {
.uri(ep.uri().clone())
.docker(docker)
.num_max_jobs(ep.maxjobs())
+ .network_mode(ep.network_mode().clone())
.build()
}),
@@ -124,6 +128,7 @@ impl Endpoint {
.name(ep.name().clone())
.uri(ep.uri().clone())
.num_max_jobs(ep.maxjobs())
+ .network_mode(ep.network_mode().clone())
.docker(shiplift::Docker::unix(ep.uri()))
.build()
}),
@@ -301,11 +306,18 @@ impl<'a> PreparedContainer<'a> {
.collect::<Vec<_>>();
trace!("Job resources: Environment variables = {:?}", envs);
- let builder_opts = shiplift::ContainerOptions::builder(job.image().as_ref())
- .env(envs.iter().map(AsRef::as_ref).collect::<Vec<&str>>())
- .cmd(vec!["/bin/bash"]) // we start the container with /bin/bash, but exec() the script in it later
- .attach_stdin(true) // we have to attach, otherwise bash exits
- .build();
+ let builder_opts = {
+ let mut builder_opts = shiplift::ContainerOptions::builder(job.image().as_ref());
+ builder_opts.env(envs.iter().map(AsRef::as_ref).collect::<Vec<&str>>());
+ builder_opts.cmd(vec!["/bin/bash"]); // we start the container with /bin/bash, but exec() the script in it later
+ builder_opts.attach_stdin(true); // we have to attach, otherwise bash exits
+
+ if let Some(network_mode) = endpoint.network_mode().as_ref() {
+ builder_opts.network_mode(network_mode);
+ }
+
+ builder_opts.build()
+ };
trace!("Builder options = {:?}", builder_opts);
let create_info = endpoint