Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
use reason on the log
Browse files Browse the repository at this point in the history
Signed-off-by: Future Outlier <[email protected]>
  • Loading branch information
Future Outlier committed Sep 27, 2023
1 parent 9e709db commit 90cff0b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
2 changes: 0 additions & 2 deletions go/tasks/plugins/webapi/agent/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,8 @@ func (p Plugin) Status(ctx context.Context, taskCtx webapi.StatusContext) (phase

switch resource.State {
case admin.State_PENDING:
taskInfo.Logs = createTaskLog(resource.Message)
return core.PhaseInfoInitializing(time.Now(), core.DefaultPhaseVersion, resource.Message, taskInfo), nil
case admin.State_RUNNING:
taskInfo.Logs = createTaskLog(resource.Message)
return core.PhaseInfoRunning(core.DefaultPhaseVersion, taskInfo), nil
case admin.State_PERMANENT_FAILURE:
return core.PhaseInfoFailure(pluginErrors.TaskFailedWithError, "failed to run the job", taskInfo), nil
Expand Down
16 changes: 1 addition & 15 deletions go/tasks/plugins/webapi/agent/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestPlugin(t *testing.T) {
phase, err := plugin.Status(context.Background(), taskContext)
assert.NoError(t, err)
assert.Equal(t, pluginsCore.PhaseInitializing, phase.Phase())
assert.Equal(t, "Waiting for cluster", phase.Info().Logs[0].Name)
assert.Equal(t, "Waiting for cluster", phase.Reason())
})

t.Run("test RUNNING Status", func(t *testing.T) {
Expand All @@ -127,7 +127,6 @@ func TestPlugin(t *testing.T) {
phase, err := plugin.Status(context.Background(), taskContext)
assert.NoError(t, err)
assert.Equal(t, pluginsCore.PhaseRunning, phase.Phase())
assert.Equal(t, "Job is running", phase.Info().Logs[0].Name)
})

t.Run("test PERMANENT_FAILURE Status", func(t *testing.T) {
Expand Down Expand Up @@ -156,19 +155,6 @@ func TestPlugin(t *testing.T) {
assert.Equal(t, pluginsCore.PhaseRetryableFailure, phase.Phase())
})

t.Run("test SUCCEEDED Status", func(t *testing.T) {
taskContext := new(webapiPlugin.StatusContext)
taskContext.On("Resource").Return(&ResourceWrapper{
State: admin.State_SUCCEEDED,
Outputs: nil,
Message: "",
})

phase, err := plugin.Status(context.Background(), taskContext)
assert.NoError(t, err)
assert.Equal(t, pluginsCore.PhaseSuccess, phase.Phase())
})

t.Run("test UNDEFINED Status", func(t *testing.T) {
taskContext := new(webapiPlugin.StatusContext)
taskContext.On("Resource").Return(&ResourceWrapper{
Expand Down

0 comments on commit 90cff0b

Please sign in to comment.