Skip to content

Commit

Permalink
fix(backend): Add default values to timestamps. Fixes kubeflow#8845 (k…
Browse files Browse the repository at this point in the history
…ubeflow#8857)

* Add default values to timestamps

* Force not-null create, null-able other timestamps
  • Loading branch information
gkcalat authored and jlyaoyuli committed Mar 9, 2023
1 parent 2878734 commit 4fac435
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion backend/src/apiserver/model/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type Job struct {
MaxConcurrency int64 `gorm:"column:MaxConcurrency; not null;"`
NoCatchup bool `gorm:"column:NoCatchup; not null;"`
CreatedAtInSec int64 `gorm:"column:CreatedAtInSec; not null;"` /* The time this record is stored in DB*/
UpdatedAtInSec int64 `gorm:"column:UpdatedAtInSec; not null;"`
UpdatedAtInSec int64 `gorm:"column:UpdatedAtInSec; default:0;"`
Enabled bool `gorm:"column:Enabled; not null;"`
ExperimentId string `gorm:"column:ExperimentUUID; not null;"`
// ResourceReferences are deprecated. Use Namespace, ExperimentId
Expand Down
4 changes: 2 additions & 2 deletions backend/src/apiserver/model/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ type Task struct {
RunId string `gorm:"column:RunUUID; not null;"`
MLMDExecutionID string `gorm:"column:MLMDExecutionID; not null;"`
CreatedTimestamp int64 `gorm:"column:CreatedTimestamp; not null;"`
StartedTimestamp int64 `gorm:"column:StartedTimestamp;"`
FinishedTimestamp int64 `gorm:"column:FinishedTimestamp;"`
StartedTimestamp int64 `gorm:"column:StartedTimestamp; default:0;"`
FinishedTimestamp int64 `gorm:"column:FinishedTimestamp; default:0;"`
Fingerprint string `gorm:"column:Fingerprint; not null;"`
Name string `gorm:"column:Name; default:null"`
ParentTaskId string `gorm:"column:ParentTaskUUID; default:null"`
Expand Down
4 changes: 2 additions & 2 deletions backend/src/apiserver/storage/experiment_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (s *ExperimentStore) scanRows(rows *sql.Rows) ([]*model.Experiment, error)
var experiments []*model.Experiment
for rows.Next() {
var uuid, name, description, namespace, storageState string
var createdAtInSec int64
var createdAtInSec sql.NullInt64
err := rows.Scan(&uuid, &name, &description, &createdAtInSec, &namespace, &storageState)
if err != nil {
return experiments, err
Expand All @@ -201,7 +201,7 @@ func (s *ExperimentStore) scanRows(rows *sql.Rows) ([]*model.Experiment, error)
UUID: uuid,
Name: name,
Description: description,
CreatedAtInSec: createdAtInSec,
CreatedAtInSec: createdAtInSec.Int64,
Namespace: namespace,
StorageState: model.StorageState(storageState).ToV2(),
}
Expand Down
10 changes: 5 additions & 5 deletions backend/src/apiserver/storage/job_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ func (s *JobStore) scanRows(r *sql.Rows) ([]*model.Job, error) {
for r.Next() {
var uuid, displayName, name, namespace, pipelineId, pipelineName, conditions, serviceAccount,
description, parameters, pipelineSpecManifest, workflowSpecManifest string
var cronScheduleStartTimeInSec, cronScheduleEndTimeInSec,
periodicScheduleStartTimeInSec, periodicScheduleEndTimeInSec, intervalSecond sql.NullInt64
var cronScheduleStartTimeInSec, cronScheduleEndTimeInSec, createdAtInSec,
periodicScheduleStartTimeInSec, periodicScheduleEndTimeInSec, intervalSecond, updatedAtInSec sql.NullInt64
var cron, resourceReferencesInString, runtimeParameters, pipelineRoot sql.NullString
var experimentId, pipelineVersionId sql.NullString
var enabled, noCatchup bool
var createdAtInSec, updatedAtInSec, maxConcurrency int64
var maxConcurrency int64
err := r.Scan(
&uuid, &displayName, &name, &namespace, &serviceAccount, &description,
&maxConcurrency, &noCatchup, &createdAtInSec, &updatedAtInSec, &enabled,
Expand Down Expand Up @@ -299,8 +299,8 @@ func (s *JobStore) scanRows(r *sql.Rows) ([]*model.Job, error) {
Parameters: parameters,
RuntimeConfig: runtimeConfig,
},
CreatedAtInSec: createdAtInSec,
UpdatedAtInSec: updatedAtInSec,
CreatedAtInSec: createdAtInSec.Int64,
UpdatedAtInSec: updatedAtInSec.Int64,
}
job = job.ToV1().ToV2()
jobs = append(jobs, job)
Expand Down
5 changes: 2 additions & 3 deletions backend/src/apiserver/storage/pipeline_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,9 @@ func (s *PipelineStore) scanJoinedRows(rows *sql.Rows) ([]*model.Pipeline, []*mo
for rows.Next() {
var uuid, name, description string
var namespace sql.NullString
var createdAtInSec int64
var status model.PipelineStatus
var versionUUID, versionName, versionParameters, versionPipelineId, versionCodeSourceUrl, versionStatus, versionDescription, pipelineSpec, pipelineSpecURI sql.NullString
var versionCreatedAtInSec sql.NullInt64
var createdAtInSec, versionCreatedAtInSec sql.NullInt64
if err := rows.Scan(
&uuid,
&createdAtInSec,
Expand All @@ -407,7 +406,7 @@ func (s *PipelineStore) scanJoinedRows(rows *sql.Rows) ([]*model.Pipeline, []*mo
pipelines,
&model.Pipeline{
UUID: uuid,
CreatedAtInSec: createdAtInSec,
CreatedAtInSec: createdAtInSec.Int64,
Name: name,
Description: description,
Status: status,
Expand Down
8 changes: 4 additions & 4 deletions backend/src/apiserver/storage/run_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func (s *RunStore) scanRowsToRuns(rows *sql.Rows) ([]*model.Run, error) {
var uuid, experimentUUID, displayName, name, storageState, namespace, serviceAccount, conditions, description, pipelineId,
pipelineName, pipelineSpecManifest, workflowSpecManifest, parameters, pipelineRuntimeManifest,
workflowRuntimeManifest string
var createdAtInSec, scheduledAtInSec, finishedAtInSec int64
var createdAtInSec, scheduledAtInSec, finishedAtInSec sql.NullInt64
var metricsInString, resourceReferencesInString, runtimeParameters, pipelineRoot, jobId, state, stateHistory, pipelineVersionId sql.NullString
err := rows.Scan(
&uuid,
Expand Down Expand Up @@ -370,9 +370,9 @@ func (s *RunStore) scanRowsToRuns(rows *sql.Rows) ([]*model.Run, error) {
Description: description,
RecurringRunId: jId,
RunDetails: model.RunDetails{
CreatedAtInSec: createdAtInSec,
ScheduledAtInSec: scheduledAtInSec,
FinishedAtInSec: finishedAtInSec,
CreatedAtInSec: createdAtInSec.Int64,
ScheduledAtInSec: scheduledAtInSec.Int64,
FinishedAtInSec: finishedAtInSec.Int64,
Conditions: conditions,
State: model.RuntimeState(state.String),
PipelineRuntimeManifest: pipelineRuntimeManifest,
Expand Down
8 changes: 4 additions & 4 deletions backend/src/apiserver/storage/task_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (s *TaskStore) scanRows(rows *sql.Rows) ([]*model.Task, error) {
for rows.Next() {
var uuid, namespace, pipelineName, runUUID, mlmdExecutionID, fingerprint string
var name, parentTaskId, state, stateHistory, inputs, outputs sql.NullString
var createdTimestamp, startedTimestamp, finishedTimestamp int64
var createdTimestamp, startedTimestamp, finishedTimestamp sql.NullInt64
err := rows.Scan(
&uuid,
&namespace,
Expand Down Expand Up @@ -147,9 +147,9 @@ func (s *TaskStore) scanRows(rows *sql.Rows) ([]*model.Task, error) {
PipelineName: pipelineName,
RunId: runUUID,
MLMDExecutionID: mlmdExecutionID,
CreatedTimestamp: createdTimestamp,
StartedTimestamp: startedTimestamp,
FinishedTimestamp: finishedTimestamp,
CreatedTimestamp: createdTimestamp.Int64,
StartedTimestamp: startedTimestamp.Int64,
FinishedTimestamp: finishedTimestamp.Int64,
Fingerprint: fingerprint,
Name: name.String,
ParentTaskId: parentTaskId.String,
Expand Down

0 comments on commit 4fac435

Please sign in to comment.