summaryrefslogtreecommitdiffstats
path: root/src/endpoint/scheduler.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-12-04 10:23:27 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-12-07 13:21:54 +0100
commit4f0eb2b11ac44ce4f3b2273dcd863c5e173689c1 (patch)
treeb4ef4f7b0a66e66f9c52ef89c6e9d9cfe50d7bd4 /src/endpoint/scheduler.rs
parent89e48c21245e1b09678363fcf157094c1234b277 (diff)
Remove passing of additional env variables
This patch removes the passing around of additional environment variables that were specified on the commandline and adds them directly to the Job object instance upon creation. This does not result in a netto-loss of code, but in a netto-loss of complexity. For this to be possible, we had to derive Clone for `JobResource`, which we have to clone when creating the `Job` objects during the creation of the jobsets from the `Tree` object. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/endpoint/scheduler.rs')
-rw-r--r--src/endpoint/scheduler.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/endpoint/scheduler.rs b/src/endpoint/scheduler.rs
index 57b8043..8742663 100644
--- a/src/endpoint/scheduler.rs
+++ b/src/endpoint/scheduler.rs
@@ -20,6 +20,7 @@ use crate::db::models as dbmodels;
use crate::endpoint::Endpoint;
use crate::endpoint::EndpointConfiguration;
use crate::filestore::StagingStore;
+use crate::job::JobResource;
use crate::job::RunnableJob;
use crate::log::LogItem;
use crate::util::progress::ProgressBars;
@@ -33,12 +34,11 @@ pub struct EndpointScheduler {
db: Arc<PgConnection>,
progressbars: ProgressBars,
submit: crate::db::models::Submit,
- additional_env: Vec<(String, String)>,
}
impl EndpointScheduler {
- pub async fn setup(endpoints: Vec<EndpointConfiguration>, staging_store: Arc<RwLock<StagingStore>>, db: Arc<PgConnection>, progressbars: ProgressBars, submit: crate::db::models::Submit, log_dir: Option<PathBuf>, additional_env: Vec<(String, String)>) -> Result<Self> {
+ pub async fn setup(endpoints: Vec<EndpointConfiguration>, staging_store: Arc<RwLock<StagingStore>>, db: Arc<PgConnection>, progressbars: ProgressBars, submit: crate::db::models::Submit, log_dir: Option<PathBuf>) -> Result<Self> {
let endpoints = Self::setup_endpoints(endpoints).await?;
Ok(EndpointScheduler {
@@ -48,7 +48,6 @@ impl EndpointScheduler {
db,
progressbars,
submit,
- additional_env,
})
}
@@ -84,7 +83,6 @@ impl EndpointScheduler {
staging_store: self.staging_store.clone(),
db: self.db.clone(),
submit: self.submit.clone(),
- additional_env: self.additional_env.clone(),
})
}
@@ -126,7 +124,6 @@ pub struct JobHandle {
db: Arc<PgConnection>,
staging_store: Arc<RwLock<StagingStore>>,
submit: crate::db::models::Submit,
- additional_env: Vec<(String, String)>,
}
impl std::fmt::Debug for JobHandle {
@@ -147,7 +144,7 @@ impl JobHandle {
let job_id = self.job.uuid().clone();
trace!("Running on Job {} on Endpoint {}", job_id, ep.name());
let res = ep
- .run_job(self.job, log_sender, self.staging_store, self.additional_env);
+ .run_job(self.job, log_sender, self.staging_store);
let logres = LogReceiver {
log_dir: self.log_dir.as_ref(),
@@ -179,7 +176,7 @@ impl JobHandle {
fn create_env_in_db(&self) -> Result<Vec<dbmodels::EnvVar>> {
trace!("Creating environment in database");
trace!("Hardcoded = {:?}", self.job.package().environment());
- trace!("Dynamic = {:?}", self.additional_env);
+ trace!("Dynamic = {:?}", self.job.resources());
self.job
.package()
.environment()
@@ -195,8 +192,10 @@ impl JobHandle {
.into_iter()
.map(Ok)
.chain({
- self.additional_env
+ self.job
+ .resources()
.iter()
+ .filter_map(JobResource::env)
.inspect(|(k, v)| trace!("Creating environment variable in database: {} = {}", k, v))
.map(|(k, v)| dbmodels::EnvVar::create_or_fetch(&self.db, k, v))
})