Skip to content

Commit

Permalink
fix: 允许作业startTime为空
Browse files Browse the repository at this point in the history
  • Loading branch information
tongchong committed Dec 26, 2024
1 parent 31c1cb9 commit 8df4161
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .changeset/brown-coats-appear.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
"@scow/mis-server": patch
"@scow/mis-web": patch
"@scow/portal-web": patch
---

slurm数据库中开始时间为空的作业也同步到 scow 数据库
slurm数据库中开始时间为空的作业也同步到 scow 数据库
5 changes: 5 additions & 0 deletions .changeset/empty-pumpkins-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scow/grpc-api": patch
---

mis-server 作业信息查询接口及导出接口中的 time_start 变为 optional
9 changes: 5 additions & 4 deletions apps/mis-server/src/entities/JobInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export class JobInfo {
timeSubmit!: Date;

@Index({ name: "time_start" })
@Property({ comment: "开始时间" })
timeStart!: Date;
@Property({ comment: "开始时间", nullable: true })
timeStart?: Date;

@Property({ comment: "结束时间", index: "time_end" })
timeEnd!: Date;
Expand Down Expand Up @@ -140,7 +140,8 @@ export class JobInfo {
this.nodesAlloc = job.nodesAlloc!;
this.timelimit = job.timeLimitMinutes;
this.timeUsed = job.elapsedSeconds!;
this.timeWait = ((new Date(job.startTime!)).getTime() - (new Date(job.submitTime!)).getTime()) / 1000;
this.timeWait = job.startTime ? ((new Date(job.startTime)).getTime() - (new Date(job.submitTime!)).getTime()) / 1000
: ((new Date(job.endTime!)).getTime() - (new Date(job.submitTime!)).getTime()) / 1000;
this.qos = job.qos;

this.tenantPrice = jobPriceInfo.tenant?.price ?? new Decimal(0);
Expand All @@ -149,7 +150,7 @@ export class JobInfo {
this.accountBillingItemId = jobPriceInfo.account?.billingItemId ?? UNKNOWN_PRICE_ITEM;

this.timeSubmit = new Date(job.submitTime!);
this.timeStart = new Date(job.startTime!);
this.timeStart = job.startTime ? new Date(job.startTime) : undefined;
this.timeEnd = new Date(job.endTime!);
}
}
2 changes: 1 addition & 1 deletion apps/mis-server/src/migrations/.snapshot-scow_server.json
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"length": 0,
"comment": "开始时间",
"mappedType": "datetime"
Expand Down
25 changes: 25 additions & 0 deletions apps/mis-server/src/migrations/Migration20241225023219.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2022 Peking University and Peking University Institute for Computing and Digital Economy
* OpenSCOW is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/

import { Migration } from "@mikro-orm/migrations";

export class Migration20241225023219 extends Migration {

override async up(): Promise<void> {
this.addSql("alter table `job_info` modify `time_start` datetime null comment '开始时间';");
}

override async down(): Promise<void> {
this.addSql("alter table `job_info` modify `time_start` datetime not null comment '开始时间';");
}

}
2 changes: 0 additions & 2 deletions apps/mis-server/src/tasks/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ const processGetJobsResult = (cluster: string, result: GetJobsResponse) => {
jobs.push({
cluster,
...job,
// 如果开始时间为空,这种作业属于被取消或者有故障的作业,未开始过,将其设置等于结束时间
startTime: job.startTime ?? job.endTime,
});
});

Expand Down
2 changes: 1 addition & 1 deletion apps/mis-server/src/utils/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function toGrpc(x: JobInfoEntity) {
qos: x.qos,
recordTime: x.recordTime.toISOString(),
timeEnd: x.timeEnd.toISOString(),
timeStart: x.timeStart.toISOString(),
timeStart: x.timeStart ? x.timeStart.toISOString() : undefined,
timeSubmit: x.timeSubmit.toISOString(),
timeUsed: x.timeUsed,
timeWait: x.timeWait,
Expand Down
2 changes: 1 addition & 1 deletion apps/mis-web/src/pageComponents/job/HistoryJobDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const HistoryJobDrawer: React.FC<Props> = (props) => {
[t(pCommon("workName")), "jobName"],
[t(pCommon("clusterName")), "cluster", getClusterName],
[t(p("timeSubmit")), "timeSubmit", formatDateTime],
[t(p("timeStart")), "timeStart", formatDateTime],
[t(p("timeStart")), "timeStart", (t) => (t ? formatDateTime(t) : "-")],
[t(p("timeEnd")), "timeEnd", formatDateTime],
[t(p("gpus")), "gpu"],
[t(p("cpusReq")), "cpusReq"],
Expand Down
2 changes: 1 addition & 1 deletion apps/portal-web/src/pageComponents/job/AllJobsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export const JobInfoTable: React.FC<JobInfoTableProps> = ({
dataIndex="submitTime"
width="8.6%"
title={t(p("submitTime"))}
render={(t) => formatDateTime(t)}
render={(t) => t ? formatDateTime(t) : "-"}
sorter={(a, b) => Number(dayjs(a.submitTime).isAfter(dayjs(b.submitTime))) }
/>
<Table.Column<JobInfo>
Expand Down
2 changes: 1 addition & 1 deletion protos/common/ended_job.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ message JobInfo {
string job_name = 7;
string cluster = 8;
google.protobuf.Timestamp time_submit = 9;
google.protobuf.Timestamp time_start = 10;
optional google.protobuf.Timestamp time_start = 10;
google.protobuf.Timestamp time_end = 11;
int32 gpu = 12;
uint32 cpus_req = 13;
Expand Down

0 comments on commit 8df4161

Please sign in to comment.