diff --git a/docs/assets/schemas/computetask.state.mmd b/docs/assets/schemas/computetask.state.mmd index fa703e0e..890f1b79 100644 --- a/docs/assets/schemas/computetask.state.mmd +++ b/docs/assets/schemas/computetask.state.mmd @@ -3,7 +3,7 @@ stateDiagram-v2 building: BUILDING waitingParent: WAITING_FOR_PARENT_TASKS waitingExecutor: WAITING_FOR_EXECUTOR_SLOT - doing: DOING + executing: EXECUTING canceled: CANCELED failed: FAILED done: DONE @@ -19,18 +19,18 @@ stateDiagram-v2 waitingBuilding --> building building --> waitingParent waitingParent --> waitingExecutor - waitingExecutor --> doing - doing --> done + waitingExecutor --> executing + executing --> done done --> [*] building --> failed - doing --> failed + executing --> failed failed --> [*] waitingBuilding --> canceled building --> canceled waitingParent --> canceled waitingExecutor --> canceled - doing --> canceled + executing --> canceled canceled --> [*] \ No newline at end of file diff --git a/e2e/client/client.go b/e2e/client/client.go index d7ab7ac6..73fb757f 100644 --- a/e2e/client/client.go +++ b/e2e/client/client.go @@ -319,7 +319,7 @@ func (c *TestClient) FailableRegisterTasks(optList ...Taskable) (*asset.Register } func (c *TestClient) StartTask(keyRef string) { - c.applyTaskTransition(keyRef, asset.ComputeTaskAction_TASK_ACTION_DOING) + c.applyTaskTransition(keyRef, asset.ComputeTaskAction_TASK_ACTION_EXECUTING) } func (c *TestClient) CancelTask(keyRef string) { diff --git a/lib/asset/computetask.proto b/lib/asset/computetask.proto index 7400d86d..590f6ecb 100644 --- a/lib/asset/computetask.proto +++ b/lib/asset/computetask.proto @@ -14,7 +14,7 @@ enum ComputeTaskStatus { STATUS_UNKNOWN = 0; STATUS_WAITING_FOR_PARENT_TASKS = 1; STATUS_WAITING_FOR_EXECUTOR_SLOT = 2; - STATUS_DOING = 3; + STATUS_EXECUTING = 3; STATUS_DONE = 4; STATUS_CANCELED = 5; STATUS_FAILED = 6; @@ -114,7 +114,7 @@ message GetTaskParam { enum ComputeTaskAction { TASK_ACTION_UNKNOWN = 0; - TASK_ACTION_DOING = 1; + TASK_ACTION_EXECUTING = 1; TASK_ACTION_CANCELED = 2; TASK_ACTION_FAILED = 3; TASK_ACTION_DONE = 4; diff --git a/lib/asset/computetask_validation.go b/lib/asset/computetask_validation.go index 7286eb5d..f69b3a42 100644 --- a/lib/asset/computetask_validation.go +++ b/lib/asset/computetask_validation.go @@ -26,7 +26,7 @@ func (p *ApplyTaskActionParam) Validate() error { validation.Field(&p.ComputeTaskKey, validation.Required, is.UUID), validation.Field(&p.Action, validation.Required, validation.In( // TASK_ACTION_BUILDING, TASK_ACTION_WAITING_FOR_EXECUTION are managed internally based on function status - ComputeTaskAction_TASK_ACTION_DOING, + ComputeTaskAction_TASK_ACTION_EXECUTING, ComputeTaskAction_TASK_ACTION_FAILED, ComputeTaskAction_TASK_ACTION_CANCELED, ComputeTaskAction_TASK_ACTION_DONE, diff --git a/lib/asset/computetask_validation_test.go b/lib/asset/computetask_validation_test.go index ccac2675..57903080 100644 --- a/lib/asset/computetask_validation_test.go +++ b/lib/asset/computetask_validation_test.go @@ -172,10 +172,10 @@ func TestApplyTaskActionParam(t *testing.T) { empty := &ApplyTaskActionParam{} valid := &ApplyTaskActionParam{ ComputeTaskKey: "972bef4c-1b42-4743-bbe9-cc3f4a69952f", - Action: ComputeTaskAction_TASK_ACTION_DOING, + Action: ComputeTaskAction_TASK_ACTION_EXECUTING, } missingKey := &ApplyTaskActionParam{ - Action: ComputeTaskAction_TASK_ACTION_DOING, + Action: ComputeTaskAction_TASK_ACTION_EXECUTING, } missingAction := &ApplyTaskActionParam{ ComputeTaskKey: "972bef4c-1b42-4743-bbe9-cc3f4a69952f", diff --git a/lib/asset/sql_test.go b/lib/asset/sql_test.go index 12b4dfed..751bd3e6 100644 --- a/lib/asset/sql_test.go +++ b/lib/asset/sql_test.go @@ -36,7 +36,7 @@ func TestPermissionValue(t *testing.T) { } func TestComputeTaskStatusValue(t *testing.T) { - s := ComputeTaskStatus_STATUS_DOING + s := ComputeTaskStatus_STATUS_EXECUTING status := &s value, err := status.Value() diff --git a/lib/service/computetask.go b/lib/service/computetask.go index b87fb9ea..542d68f3 100644 --- a/lib/service/computetask.go +++ b/lib/service/computetask.go @@ -14,7 +14,7 @@ import ( // Task statuses in which the inputs are defined var inputDefinedStatus = []asset.ComputeTaskStatus{ - asset.ComputeTaskStatus_STATUS_DOING, + asset.ComputeTaskStatus_STATUS_EXECUTING, asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT, asset.ComputeTaskStatus_STATUS_FAILED, } diff --git a/lib/service/computetask_test.go b/lib/service/computetask_test.go index 3fde2cc3..7def85d7 100644 --- a/lib/service/computetask_test.go +++ b/lib/service/computetask_test.go @@ -72,7 +72,7 @@ func TestQueryTasks(t *testing.T) { pagination := common.NewPagination("", 2) filter := &asset.TaskQueryFilter{ - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, } returnedTasks := []*asset.ComputeTask{{}, {}} @@ -333,7 +333,7 @@ func TestRegisterCompositeTaskWithCompositeParents(t *testing.T) { parent1 := &asset.ComputeTask{ Key: "aaaaaaaa-cccc-bbbb-eeee-111111111111", ComputePlanKey: "867852b4-8419-4d52-8862-d5db823095be", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, FunctionKey: functionParent1.Key, Outputs: map[string]*asset.ComputeTaskOutput{ "shared": {Permissions: sharedPerms}, @@ -343,7 +343,7 @@ func TestRegisterCompositeTaskWithCompositeParents(t *testing.T) { parent2 := &asset.ComputeTask{ Key: "aaaaaaaa-cccc-bbbb-eeee-222222222222", ComputePlanKey: "867852b4-8419-4d52-8862-d5db823095be", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, FunctionKey: functionParent2.Key, Outputs: map[string]*asset.ComputeTaskOutput{ "shared": {Permissions: sharedPerms}, @@ -1196,7 +1196,7 @@ func TestDisableOutputs(t *testing.T) { }) t.Run("task not in terminal state", func(t *testing.T) { task := &asset.ComputeTask{ - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "myorg", } @@ -1312,7 +1312,7 @@ func TestDisableOutputs(t *testing.T) { } child := &asset.ComputeTask{ - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, } outputAsset := &asset.ComputeTaskOutputAsset{AssetKind: asset.AssetKind_ASSET_MODEL} diff --git a/lib/service/computetaskstate.go b/lib/service/computetaskstate.go index a2d84797..b0031bcd 100644 --- a/lib/service/computetaskstate.go +++ b/lib/service/computetaskstate.go @@ -20,7 +20,7 @@ const ( transitionDone taskTransition = "transitionDone" transitionCanceled taskTransition = "transitionCanceled" transitionFailed taskTransition = "transitionFailed" - transitionDoing taskTransition = "transitionDoing" + transitionExecuting taskTransition = "transitionExecuting" ) // taskStateEvents is the definition of the state machine representing task states @@ -37,7 +37,7 @@ var taskStateEvents = fsm.Events{ }, { Name: string(transitionCanceled), - Src: []string{asset.ComputeTaskStatus_STATUS_WAITING_FOR_BUILDER_SLOT.String(), asset.ComputeTaskStatus_STATUS_BUILDING.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_PARENT_TASKS.String(), asset.ComputeTaskStatus_STATUS_DOING.String()}, + Src: []string{asset.ComputeTaskStatus_STATUS_WAITING_FOR_BUILDER_SLOT.String(), asset.ComputeTaskStatus_STATUS_BUILDING.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_PARENT_TASKS.String(), asset.ComputeTaskStatus_STATUS_EXECUTING.String()}, Dst: asset.ComputeTaskStatus_STATUS_CANCELED.String(), }, { @@ -46,18 +46,18 @@ var taskStateEvents = fsm.Events{ Dst: asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), }, { - Name: string(transitionDoing), + Name: string(transitionExecuting), Src: []string{asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String()}, - Dst: asset.ComputeTaskStatus_STATUS_DOING.String(), + Dst: asset.ComputeTaskStatus_STATUS_EXECUTING.String(), }, { Name: string(transitionDone), - Src: []string{asset.ComputeTaskStatus_STATUS_DOING.String()}, + Src: []string{asset.ComputeTaskStatus_STATUS_EXECUTING.String()}, Dst: asset.ComputeTaskStatus_STATUS_DONE.String(), }, { Name: string(transitionFailed), - Src: []string{asset.ComputeTaskStatus_STATUS_WAITING_FOR_BUILDER_SLOT.String(), asset.ComputeTaskStatus_STATUS_BUILDING.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_PARENT_TASKS.String(), asset.ComputeTaskStatus_STATUS_DOING.String()}, + Src: []string{asset.ComputeTaskStatus_STATUS_WAITING_FOR_BUILDER_SLOT.String(), asset.ComputeTaskStatus_STATUS_BUILDING.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_PARENT_TASKS.String(), asset.ComputeTaskStatus_STATUS_EXECUTING.String()}, Dst: asset.ComputeTaskStatus_STATUS_FAILED.String(), }, } @@ -130,8 +130,8 @@ func (s *ComputeTaskService) applyTaskAction(task *asset.ComputeTask, action ass switch action { case asset.ComputeTaskAction_TASK_ACTION_CANCELED: transition = transitionCanceled - case asset.ComputeTaskAction_TASK_ACTION_DOING: - transition = transitionDoing + case asset.ComputeTaskAction_TASK_ACTION_EXECUTING: + transition = transitionExecuting case asset.ComputeTaskAction_TASK_ACTION_FAILED: transition = transitionFailed case asset.ComputeTaskAction_TASK_ACTION_DONE: @@ -419,7 +419,7 @@ func updateAllowed(task *asset.ComputeTask, action asset.ComputeTaskAction, requ switch action { case asset.ComputeTaskAction_TASK_ACTION_CANCELED, asset.ComputeTaskAction_TASK_ACTION_FAILED: return requester == task.Owner || requester == task.Worker - case asset.ComputeTaskAction_TASK_ACTION_DOING, asset.ComputeTaskAction_TASK_ACTION_DONE: + case asset.ComputeTaskAction_TASK_ACTION_EXECUTING, asset.ComputeTaskAction_TASK_ACTION_DONE: return requester == task.Worker default: return false diff --git a/lib/service/computetaskstate_test.go b/lib/service/computetaskstate_test.go index f967efca..1df2dc15 100644 --- a/lib/service/computetaskstate_test.go +++ b/lib/service/computetaskstate_test.go @@ -102,7 +102,7 @@ func TestOnStateChange(t *testing.T) { state := newState(updater, &asset.ComputeTask{Status: asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT, Key: "uuid"}) - err := state.Event(context.Background(), string(transitionDoing), &asset.ComputeTask{}) + err := state.Event(context.Background(), string(transitionExecuting), &asset.ComputeTask{}) assert.NoError(t, err) updater.AssertExpectations(t) @@ -112,9 +112,9 @@ func TestOnStateChange(t *testing.T) { func TestFailedStateChange(t *testing.T) { updater := new(mockTaskStateUpdater) - state := newState(updater, &asset.ComputeTask{Status: asset.ComputeTaskStatus_STATUS_DOING, Key: "uuid"}) + state := newState(updater, &asset.ComputeTask{Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Key: "uuid"}) - err := state.Event(context.Background(), string(transitionDoing), &asset.ComputeTask{}) + err := state.Event(context.Background(), string(transitionExecuting), &asset.ComputeTask{}) assert.IsType(t, fsm.InvalidEventError{}, err) state = newState(updater, &asset.ComputeTask{Status: asset.ComputeTaskStatus_STATUS_DONE, Key: "uuid"}) @@ -143,7 +143,7 @@ func TestDispatchOnTransition(t *testing.T) { expectedTask := &asset.ComputeTask{ Key: "uuid", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "worker", ComputePlanKey: "uuidcp", } @@ -160,7 +160,7 @@ func TestDispatchOnTransition(t *testing.T) { } es.On("RegisterEvents", expectedEvent).Once().Return(nil) - err := service.ApplyTaskAction("uuid", asset.ComputeTaskAction_TASK_ACTION_DOING, "", "worker") + err := service.ApplyTaskAction("uuid", asset.ComputeTaskAction_TASK_ACTION_EXECUTING, "", "worker") assert.NoError(t, err) es.AssertExpectations(t) @@ -205,7 +205,7 @@ func TestUpdateTaskStateDone(t *testing.T) { dbal.On("GetComputeTask", "uuid").Return(&asset.ComputeTask{ Key: "uuid", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Owner: "owner", Worker: "worker", }, nil) @@ -239,7 +239,7 @@ func TestCascadeStatusDone(t *testing.T) { task := &asset.ComputeTask{ Key: "uuid", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Owner: "owner", Worker: "worker", } @@ -301,14 +301,14 @@ func TestUpdateAllowed(t *testing.T) { action: asset.ComputeTaskAction_TASK_ACTION_BUILD_FINISHED, outcome: false, }, - "owner doing": { + "owner executing": { requester: task.Owner, - action: asset.ComputeTaskAction_TASK_ACTION_DOING, + action: asset.ComputeTaskAction_TASK_ACTION_EXECUTING, outcome: false, }, - "worker doing": { + "worker executing": { requester: "worker", - action: asset.ComputeTaskAction_TASK_ACTION_DOING, + action: asset.ComputeTaskAction_TASK_ACTION_EXECUTING, outcome: true, }, "owner cancel": { diff --git a/lib/service/failure_report.go b/lib/service/failure_report.go index 2b87fd91..10bb5a36 100644 --- a/lib/service/failure_report.go +++ b/lib/service/failure_report.go @@ -93,7 +93,7 @@ func checkTaskPermissions(task *asset.ComputeTask, requester string) error { return errors.NewPermissionDenied(fmt.Sprintf("only %q worker can register failure report for compute task", task.Worker)) } - if task.Status != asset.ComputeTaskStatus_STATUS_DOING { + if task.Status != asset.ComputeTaskStatus_STATUS_EXECUTING { return errors.NewBadRequest(fmt.Sprintf("cannot register failure report for task with status %q", task.Status.String())) } diff --git a/lib/service/failure_report_test.go b/lib/service/failure_report_test.go index c9aa3ae5..e1e9f0b3 100644 --- a/lib/service/failure_report_test.go +++ b/lib/service/failure_report_test.go @@ -40,7 +40,7 @@ func TestRegisterComputeTaskFailureReport(t *testing.T) { taskService.On("GetTask", newFailureReport.AssetKey).Once().Return(&asset.ComputeTask{ Key: newFailureReport.AssetKey, - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "test", }, nil) diff --git a/lib/service/model.go b/lib/service/model.go index 134cef13..e96b0cad 100644 --- a/lib/service/model.go +++ b/lib/service/model.go @@ -75,7 +75,7 @@ func (s *ModelService) registerModel(newModel *asset.NewModel, requester string, return nil, errors.NewPermissionDenied(fmt.Sprintf("only %q worker can register model", task.Worker)) } - if task.Status != asset.ComputeTaskStatus_STATUS_DOING { + if task.Status != asset.ComputeTaskStatus_STATUS_EXECUTING { return nil, errors.NewBadRequest(fmt.Sprintf("cannot register model for task with status %q", task.Status.String())) } diff --git a/lib/service/model_test.go b/lib/service/model_test.go index 11e3a437..57a010c2 100644 --- a/lib/service/model_test.go +++ b/lib/service/model_test.go @@ -181,7 +181,7 @@ func TestRegisterTrainModel(t *testing.T) { task := &asset.ComputeTask{ Key: "08680966-97ae-4573-8b2d-6c4db2b3c532", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "test", Outputs: map[string]*asset.ComputeTaskOutput{ "model": { @@ -284,7 +284,7 @@ func TestRegisterAggregateModel(t *testing.T) { task := &asset.ComputeTask{ Key: "08680966-97ae-4573-8b2d-6c4db2b3c532", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "test", Outputs: map[string]*asset.ComputeTaskOutput{ "model": { @@ -383,7 +383,7 @@ func TestRegisterDuplicateModel(t *testing.T) { persistence.ComputeTaskOutputCounter{"model": 1}, &asset.ComputeTask{ Key: "08680966-97ae-4573-8b2d-6c4db2b3c532", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "test", Outputs: map[string]*asset.ComputeTaskOutput{ "model": { @@ -441,7 +441,7 @@ func TestRegisterHeadModel(t *testing.T) { task := &asset.ComputeTask{ Key: "08680966-97ae-4573-8b2d-6c4db2b3c532", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "test", Outputs: map[string]*asset.ComputeTaskOutput{ "shared": { @@ -562,7 +562,7 @@ func TestRegisterMultipleHeads(t *testing.T) { persistence.ComputeTaskOutputCounter{"local": 1}, &asset.ComputeTask{ Key: "08680966-97ae-4573-8b2d-6c4db2b3c532", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "test", Outputs: map[string]*asset.ComputeTaskOutput{ "shared": { @@ -616,7 +616,7 @@ func TestRegisterInvalidOutput(t *testing.T) { task := &asset.ComputeTask{ Key: "08680966-97ae-4573-8b2d-6c4db2b3c532", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "test", Outputs: map[string]*asset.ComputeTaskOutput{ "model": { @@ -696,7 +696,7 @@ func TestRegisterModelsTrainTask(t *testing.T) { task := &asset.ComputeTask{ Key: "08680966-97ae-4573-8b2d-6c4db2b3c532", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "test", Outputs: map[string]*asset.ComputeTaskOutput{ "model": { @@ -804,7 +804,7 @@ func TestRegisterHeadAndTrunkModel(t *testing.T) { task := &asset.ComputeTask{ Key: "08680966-97ae-4573-8b2d-6c4db2b3c532", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "test", Outputs: map[string]*asset.ComputeTaskOutput{ "shared": { @@ -939,7 +939,7 @@ func TestRegisterMissingOutput(t *testing.T) { task := &asset.ComputeTask{ Key: "08680966-97ae-4573-8b2d-6c4db2b3c532", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "test", Outputs: map[string]*asset.ComputeTaskOutput{}, } diff --git a/lib/service/performance.go b/lib/service/performance.go index 5bddca19..180376aa 100644 --- a/lib/service/performance.go +++ b/lib/service/performance.go @@ -58,7 +58,7 @@ func (s *PerformanceService) RegisterPerformance(newPerf *asset.NewPerformance, return nil, errors.NewPermissionDenied(fmt.Sprintf("only %q worker can register performance", task.Worker)) } - if task.Status != asset.ComputeTaskStatus_STATUS_DOING { + if task.Status != asset.ComputeTaskStatus_STATUS_EXECUTING { return nil, errors.NewBadRequest(fmt.Sprintf("cannot register performance for task with status %q", task.Status.String())) } diff --git a/lib/service/performance_test.go b/lib/service/performance_test.go index ef7a0e07..5a6ea55e 100644 --- a/lib/service/performance_test.go +++ b/lib/service/performance_test.go @@ -26,7 +26,7 @@ func TestRegisterPerformance(t *testing.T) { task := &asset.ComputeTask{ Key: "taskTest", - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "test", Outputs: map[string]*asset.ComputeTaskOutput{ "auc": {}, @@ -84,7 +84,7 @@ func TestRegisterPerformanceInvalidTask(t *testing.T) { service := NewPerformanceService(provider) cts.On("GetTask", "08680966-97ae-4573-8b2d-6c4db2b3c532").Return(&asset.ComputeTask{ - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "test", }, nil) diff --git a/server/standalone/dbal/computeplan.go b/server/standalone/dbal/computeplan.go index 493796af..7575aeae 100644 --- a/server/standalone/dbal/computeplan.go +++ b/server/standalone/dbal/computeplan.go @@ -178,7 +178,7 @@ func (d *DBAL) IsPlanRunning(key string) (bool, error) { Select("COUNT(*)"). From("compute_tasks"). Where(sq.Eq{ - "status": []string{asset.ComputeTaskStatus_STATUS_WAITING_FOR_BUILDER_SLOT.String(), asset.ComputeTaskStatus_STATUS_BUILDING.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_PARENT_TASKS.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), asset.ComputeTaskStatus_STATUS_DOING.String()}, + "status": []string{asset.ComputeTaskStatus_STATUS_WAITING_FOR_BUILDER_SLOT.String(), asset.ComputeTaskStatus_STATUS_BUILDING.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_PARENT_TASKS.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), asset.ComputeTaskStatus_STATUS_EXECUTING.String()}, "compute_plan_key": key, "channel": d.channel, }) diff --git a/server/standalone/dbal/computeplan_test.go b/server/standalone/dbal/computeplan_test.go index 5ab39e1d..fd766ef6 100644 --- a/server/standalone/dbal/computeplan_test.go +++ b/server/standalone/dbal/computeplan_test.go @@ -152,7 +152,7 @@ func TestIsPlanRunning(t *testing.T) { rows := pgxmock.NewRows([]string{"count"}).AddRow(1) mock. ExpectQuery(`SELECT COUNT(*) FROM compute_tasks WHERE channel = $1 AND compute_plan_key = $2 AND status IN ($3,$4,$5,$6,$7)`). - WithArgs(testChannel, cpKey, asset.ComputeTaskStatus_STATUS_WAITING_FOR_BUILDER_SLOT.String(), asset.ComputeTaskStatus_STATUS_BUILDING.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_PARENT_TASKS.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), asset.ComputeTaskStatus_STATUS_DOING.String()). + WithArgs(testChannel, cpKey, asset.ComputeTaskStatus_STATUS_WAITING_FOR_BUILDER_SLOT.String(), asset.ComputeTaskStatus_STATUS_BUILDING.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_PARENT_TASKS.String(), asset.ComputeTaskStatus_STATUS_WAITING_FOR_EXECUTOR_SLOT.String(), asset.ComputeTaskStatus_STATUS_EXECUTING.String()). WillReturnRows(rows) tx, err := mock.Begin(context.Background()) diff --git a/server/standalone/dbal/computetask_test.go b/server/standalone/dbal/computetask_test.go index ea824fc5..d693325d 100644 --- a/server/standalone/dbal/computetask_test.go +++ b/server/standalone/dbal/computetask_test.go @@ -36,7 +36,7 @@ func TestToComputeTask(t *testing.T) { Owner: "owner", ComputePlanKey: "cp_key", Rank: 0, - Status: asset.ComputeTaskStatus_STATUS_DOING, + Status: asset.ComputeTaskStatus_STATUS_EXECUTING, Worker: "worker", CreationDate: time.Unix(100, 10).UTC(), LogsPermission: asset.Permission{ diff --git a/server/standalone/migration/000062_rename_task_status_doing_to_executing.up.sql b/server/standalone/migration/000062_rename_task_status_doing_to_executing.up.sql new file mode 100644 index 00000000..714cdcab --- /dev/null +++ b/server/standalone/migration/000062_rename_task_status_doing_to_executing.up.sql @@ -0,0 +1,20 @@ +SELECT execute($$ + -- As we use the status as foreign key, we need to: + -- 1. add the new name of the renamed ones + the new ones + -- 2. change compute tasks to use the new names of the renamed ones + -- 3. delete the previous values of the renamed ones + INSERT INTO compute_task_statuses(status) + VALUES ('STATUS_EXECUTING'); + + UPDATE compute_tasks + SET status = 'STATUS_EXECUTING' + WHERE status = 'STATUS_DOING'; + + DELETE FROM compute_task_statuses + WHERE status in ('STATUS_DOING'); + + UPDATE events e + SET asset = jsonb_set(asset, '{status}', to_jsonb('STATUS_EXECUTING'::text)) + WHERE asset_kind = 'ASSET_COMPUTE_TASK' AND asset->>'status' = 'STATUS_DOING'; + +$$) WHERE exists(SELECT 1 FROM compute_task_statuses WHERE status = 'STATUS_DOING'); \ No newline at end of file