Skip to content

Commit

Permalink
feat: record job assign time
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Apr 4, 2024
1 parent 5f2411c commit 372d744
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion frontend/src/pages/jobs/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
<v-card-text>
Creation time: {{ job.creation_time }}
<br/>
Finish time: {{ job.finish_time }}
Running since: {{ job.assign_time }}
<br/>
Time elapsed: {{ job.elapsed_secs }}
<br/>
Finish time: {{ job.finish_time }}
<br/>
Git commit: <a :href="`https://github.com/AOSC-Dev/aosc-os-abbs/commit/${job.git_sha}`">
{{ job.git_sha }}
</a>
Expand Down Expand Up @@ -128,6 +130,7 @@ import prettyBytes from 'pretty-bytes';
require_min_total_mem: number;
require_min_total_mem_per_core: number;
require_min_disk: number;
assign_time: string;
git_branch: string;
git_sha: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
ALTER TABLE jobs DROP COLUMN assign_time;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Your SQL goes here
ALTER TABLE jobs ADD assign_time TIMESTAMP WITH TIME ZONE;
1 change: 1 addition & 0 deletions server/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub struct Job {
pub require_min_total_mem: Option<i64>,
pub require_min_total_mem_per_core: Option<f32>,
pub require_min_disk: Option<i64>,
pub assign_time: Option<chrono::DateTime<chrono::Utc>>,
}

#[derive(Insertable)]
Expand Down
2 changes: 2 additions & 0 deletions server/src/routes/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub struct JobInfoResponse {
require_min_total_mem: Option<i64>,
require_min_total_mem_per_core: Option<f32>,
require_min_disk: Option<i64>,
assign_time: Option<chrono::DateTime<chrono::Utc>>,

// from pipeline
git_branch: String,
Expand Down Expand Up @@ -203,6 +204,7 @@ pub async fn job_info(
require_min_total_mem: job.require_min_total_mem,
require_min_total_mem_per_core: job.require_min_total_mem_per_core,
require_min_disk: job.require_min_disk,
assign_time: job.assign_time,

// from pipeline
git_branch: pipeline.git_branch,
Expand Down
6 changes: 5 additions & 1 deletion server/src/routes/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ pub async fn worker_poll(
Some((job, pipeline)) => {
// allocate to the worker
diesel::update(&job)
.set((status.eq("running"), assigned_worker_id.eq(worker.id)))
.set((
status.eq("running"),
assigned_worker_id.eq(worker.id),
assign_time.eq(chrono::Utc::now()),
))
.execute(conn)?;

Ok(Some((pipeline, job)))
Expand Down
1 change: 1 addition & 0 deletions server/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ diesel::table! {
require_min_total_mem -> Nullable<Int8>,
require_min_total_mem_per_core -> Nullable<Float4>,
require_min_disk -> Nullable<Int8>,
assign_time -> Nullable<Timestamptz>,
}
}

Expand Down

0 comments on commit 372d744

Please sign in to comment.