This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
/
handler.go
52 lines (43 loc) · 1.89 KB
/
handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package end
import (
"context"
"github.com/lyft/flytepropeller/pkg/apis/flyteworkflow/v1alpha1"
"github.com/lyft/flytepropeller/pkg/controller/nodes/errors"
"github.com/lyft/flytepropeller/pkg/controller/nodes/handler"
"github.com/lyft/flytestdlib/logger"
"github.com/lyft/flytestdlib/storage"
)
type endHandler struct {
store storage.ProtobufStore
}
func (e *endHandler) Initialize(ctx context.Context) error {
return nil
}
func (e *endHandler) StartNode(ctx context.Context, w v1alpha1.ExecutableWorkflow, node v1alpha1.ExecutableNode, nodeInputs *handler.Data) (handler.Status, error) {
if nodeInputs != nil {
logger.Debugf(ctx, "Workflow has outputs. Storing them.")
nodeStatus := w.GetNodeExecutionStatus(node.GetID())
o := v1alpha1.GetOutputsFile(nodeStatus.GetDataDir())
so := storage.Options{}
if err := e.store.WriteProtobuf(ctx, o, so, nodeInputs); err != nil {
logger.Errorf(ctx, "Failed to store workflow outputs. Error [%s]", err)
return handler.StatusUndefined, errors.Wrapf(errors.CausedByError, node.GetID(), err, "Failed to store workflow outputs, as end-node")
}
}
logger.Debugf(ctx, "End node success")
return handler.StatusSuccess, nil
}
func (e *endHandler) CheckNodeStatus(ctx context.Context, g v1alpha1.ExecutableWorkflow, node v1alpha1.ExecutableNode, nodeStatus v1alpha1.ExecutableNodeStatus) (handler.Status, error) {
return handler.StatusSuccess, nil
}
func (e *endHandler) HandleFailingNode(ctx context.Context, w v1alpha1.ExecutableWorkflow, node v1alpha1.ExecutableNode) (handler.Status, error) {
return handler.StatusFailed(errors.Errorf(errors.IllegalStateError, node.GetID(), "End node cannot enter a failing state")), nil
}
func (e *endHandler) AbortNode(ctx context.Context, w v1alpha1.ExecutableWorkflow, node v1alpha1.ExecutableNode) error {
return nil
}
func New(store storage.ProtobufStore) handler.IFace {
return &endHandler{
store: store,
}
}