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

Commit

Permalink
Add Get Message in Agent
Browse files Browse the repository at this point in the history
Signed-off-by: Future Outlier <eric901201@gmai.com>
  • Loading branch information
Future Outlier committed Sep 14, 2023
1 parent d0c1602 commit 6b69092
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go/tasks/plugins/webapi/agent/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Plugin struct {
type ResourceWrapper struct {
State admin.State
Outputs *flyteIdl.LiteralMap
Message string
}

type ResourceMetaWrapper struct {
Expand Down Expand Up @@ -133,6 +134,7 @@ func (p Plugin) Get(ctx context.Context, taskCtx webapi.GetContext) (latest weba
return &ResourceWrapper{
State: res.Resource.State,
Outputs: res.Resource.Outputs,
Message: res.Resource.Message,

Check failure on line 137 in go/tasks/plugins/webapi/agent/plugin.go

View workflow job for this annotation

GitHub Actions / Run lint

res.Resource.Message undefined (type *admin.Resource has no field or method Message) (typecheck)
}, nil
}

Expand Down Expand Up @@ -164,7 +166,7 @@ func (p Plugin) Status(ctx context.Context, taskCtx webapi.StatusContext) (phase

switch resource.State {
case admin.State_PENDING:
return core.PhaseInfoInitializing(time.Now(), core.DefaultPhaseVersion, "job submitted", taskInfo), nil
return core.PhaseInfoInitializing(time.Now(), core.DefaultPhaseVersion, resource.Message, taskInfo), nil
case admin.State_RUNNING:
return core.PhaseInfoRunning(core.DefaultPhaseVersion, taskInfo), nil
case admin.State_PERMANENT_FAILURE:
Expand Down
6 changes: 6 additions & 0 deletions go/tasks/plugins/webapi/agent/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func TestPlugin(t *testing.T) {
taskContext.On("Resource").Return(&ResourceWrapper{
State: admin.State_PENDING,
Outputs: nil,
Message: "Waiting for cluster",
})

phase, err := plugin.Status(context.Background(), taskContext)
Expand All @@ -119,6 +120,7 @@ func TestPlugin(t *testing.T) {
taskContext.On("Resource").Return(&ResourceWrapper{
State: admin.State_RUNNING,
Outputs: nil,
Message: "",
})

phase, err := plugin.Status(context.Background(), taskContext)
Expand All @@ -131,6 +133,7 @@ func TestPlugin(t *testing.T) {
taskContext.On("Resource").Return(&ResourceWrapper{
State: admin.State_PERMANENT_FAILURE,
Outputs: nil,
Message: "",
})

phase, err := plugin.Status(context.Background(), taskContext)
Expand All @@ -143,6 +146,7 @@ func TestPlugin(t *testing.T) {
taskContext.On("Resource").Return(&ResourceWrapper{
State: admin.State_RETRYABLE_FAILURE,
Outputs: nil,
Message: "",
})

phase, err := plugin.Status(context.Background(), taskContext)
Expand All @@ -155,6 +159,7 @@ func TestPlugin(t *testing.T) {
taskContext.On("Resource").Return(&ResourceWrapper{
State: admin.State_SUCCEEDED,
Outputs: nil,
Message: "",
})

phase, err := plugin.Status(context.Background(), taskContext)
Expand All @@ -167,6 +172,7 @@ func TestPlugin(t *testing.T) {
taskContext.On("Resource").Return(&ResourceWrapper{
State: 5,
Outputs: nil,
Message: "",
})

phase, err := plugin.Status(context.Background(), taskContext)
Expand Down

0 comments on commit 6b69092

Please sign in to comment.