diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-11-13 17:21:57 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-11-13 17:25:25 +0100 |
commit | 1558a2817081d9110eff20f5d429125e460d9a81 (patch) | |
tree | 52f5cddc9b4e8f248f5367601074e9af76019821 /src | |
parent | 4eca99a67c87dde25024877b8fc390ab67dde23c (diff) |
Add uuid field to "job" table
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/db.rs | 4 | ||||
-rw-r--r-- | src/db/models/job.rs | 4 | ||||
-rw-r--r-- | src/endpoint/scheduler.rs | 2 | ||||
-rw-r--r-- | src/schema.rs | 1 |
4 files changed, 8 insertions, 3 deletions
diff --git a/src/commands/db.rs b/src/commands/db.rs index 087cd85..c96ef7b 100644 --- a/src/commands/db.rs +++ b/src/commands/db.rs @@ -213,7 +213,7 @@ fn jobs(conn_cfg: DbConnectionConfig, matches: &ArgMatches) -> Result<()> { use crate::schema::jobs::dsl; let csv = matches.is_present("csv"); - let hdrs = mk_header(vec!["id", "submit uuid", "time", "endpoint", "success"]); + let hdrs = mk_header(vec!["id", "submit uuid", "job uuid", "time", "endpoint", "success"]); let conn = crate::db::establish_connection(conn_cfg)?; let jobs = matches.value_of("submit_uuid") .map(uuid::Uuid::parse_str) @@ -244,7 +244,7 @@ fn jobs(conn_cfg: DbConnectionConfig, matches: &ArgMatches) -> Result<()> { }) .unwrap_or_else(|| String::from("unknown")); - Ok(vec![format!("{}", job.id), submit.uuid.to_string(), submit.submit_time.to_string(), ep.name, success]) + Ok(vec![format!("{}", job.id), submit.uuid.to_string(), job.uuid.to_string(), submit.submit_time.to_string(), ep.name, success]) }) .collect::<Result<Vec<_>>>()?; diff --git a/src/db/models/job.rs b/src/db/models/job.rs index fd3b862..12fba7b 100644 --- a/src/db/models/job.rs +++ b/src/db/models/job.rs @@ -19,6 +19,7 @@ pub struct Job { pub container_hash: String, pub script_text: String, pub log_text: String, + pub uuid: ::uuid::Uuid, } #[derive(Debug, Insertable)] @@ -31,10 +32,12 @@ struct NewJob<'a> { pub container_hash: &'a str, pub script_text: &'a str, pub log_text: &'a str, + pub uuid: &'a ::uuid::Uuid, } impl Job { pub fn create(database_connection: &PgConnection, + job_uuid: &::uuid::Uuid, submit: &Submit, endpoint: &Endpoint, package: &Package, @@ -44,6 +47,7 @@ impl Job { log: &str, ) -> Result<()> { let new_job = NewJob { + uuid: job_uuid, submit_id: submit.id, endpoint_id: endpoint.id, package_id: package.id, diff --git a/src/endpoint/scheduler.rs b/src/endpoint/scheduler.rs index 6bbb438..541082a 100644 --- a/src/endpoint/scheduler.rs +++ b/src/endpoint/scheduler.rs @@ -151,7 +151,7 @@ impl JobHandle { let log = logres.with_context(|| anyhow!("Collecting logs for job on '{}'", ep.name()))?; let (paths, container_hash, script) = res.with_context(|| anyhow!("Running job on '{}'", ep.name()))?; - dbmodels::Job::create(&self.db, &self.submit, &endpoint, &package, &image, &container_hash, &script, &log)?; + dbmodels::Job::create(&self.db, &job_id, &self.submit, &endpoint, &package, &image, &container_hash, &script, &log)?; Ok(paths) } diff --git a/src/schema.rs b/src/schema.rs index 0baaf47..aa777a6 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -68,6 +68,7 @@ table! { container_hash -> Varchar, script_text -> Text, log_text -> Text, + uuid -> Uuid, } } |