Skip to content

Commit

Permalink
Fix initial dask job state (flyteorg#357)
Browse files Browse the repository at this point in the history
* Fix initial dask state

Signed-off-by: Bernhard Stadlbauer <[email protected]>

* Fix linting

Signed-off-by: Bernhard Stadlbauer <[email protected]>

---------

Signed-off-by: Bernhard Stadlbauer <[email protected]>
  • Loading branch information
bstadlbauer authored Jun 8, 2023
1 parent aa1ed67 commit 2a7a6f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion go/tasks/plugins/k8s/dask/dask.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,10 @@ func (p daskResourceHandler) GetTaskPhase(ctx context.Context, pluginContext k8s
OccurredAt: &occurredAt,
}

isQueued := status == daskAPI.DaskJobCreated ||
// There is a short period between the `DaskJob` resource being created and `Status.JobStatus` being set by the `dask-operator`.
// In that period, the `JobStatus` will be an empty string. We're treating this as Initializing/Queuing.
isQueued := status == "" ||
status == daskAPI.DaskJobCreated ||
status == daskAPI.DaskJobClusterCreated

if !isQueued {
Expand All @@ -337,6 +340,8 @@ func (p daskResourceHandler) GetTaskPhase(ctx context.Context, pluginContext k8s
}

switch status {
case "":
return pluginsCore.PhaseInfoInitializing(occurredAt, pluginsCore.DefaultPhaseVersion, "unknown", &info), nil
case daskAPI.DaskJobCreated:
return pluginsCore.PhaseInfoInitializing(occurredAt, pluginsCore.DefaultPhaseVersion, "job created", &info), nil
case daskAPI.DaskJobClusterCreated:
Expand Down
9 changes: 8 additions & 1 deletion go/tasks/plugins/k8s/dask/dask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,14 @@ func TestGetTaskPhaseDask(t *testing.T) {
daskResourceHandler := daskResourceHandler{}
ctx := context.TODO()

taskPhase, err := daskResourceHandler.GetTaskPhase(ctx, nil, dummyDaskJob(daskAPI.DaskJobCreated))
taskPhase, err := daskResourceHandler.GetTaskPhase(ctx, nil, dummyDaskJob(""))
assert.NoError(t, err)
assert.Equal(t, taskPhase.Phase(), pluginsCore.PhaseInitializing)
assert.NotNil(t, taskPhase.Info())
assert.Nil(t, taskPhase.Info().Logs)
assert.Nil(t, err)

taskPhase, err = daskResourceHandler.GetTaskPhase(ctx, nil, dummyDaskJob(daskAPI.DaskJobCreated))
assert.NoError(t, err)
assert.Equal(t, taskPhase.Phase(), pluginsCore.PhaseInitializing)
assert.NotNil(t, taskPhase.Info())
Expand Down

0 comments on commit 2a7a6f9

Please sign in to comment.