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 63
/
node_execution_validator.go
77 lines (71 loc) · 2.77 KB
/
node_execution_validator.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package validation
import (
"github.com/flyteorg/flyteadmin/pkg/common"
"github.com/flyteorg/flyteadmin/pkg/manager/impl/shared"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
)
func ValidateNodeExecutionIdentifier(identifier *core.NodeExecutionIdentifier) error {
if identifier == nil {
return shared.GetMissingArgumentError(shared.ID)
}
if identifier.ExecutionId == nil {
return shared.GetMissingArgumentError(shared.ExecutionID)
}
if identifier.NodeId == "" {
return shared.GetMissingArgumentError(shared.NodeID)
}
return ValidateWorkflowExecutionIdentifier(identifier.ExecutionId)
}
// Validates that NodeExecutionEventRequests handled by admin include a valid node execution identifier.
// In the case the event specifies a DynamicWorkflow in the TaskNodeMetadata, this method also validates the contents of
// the dynamic workflow.
func ValidateNodeExecutionEventRequest(request *admin.NodeExecutionEventRequest, maxOutputSizeInBytes int64) error {
if request.Event == nil {
return shared.GetMissingArgumentError(shared.Event)
}
err := ValidateNodeExecutionIdentifier(request.Event.Id)
if err != nil {
return err
}
if request.Event.GetTaskNodeMetadata() != nil && request.Event.GetTaskNodeMetadata().DynamicWorkflow != nil {
dynamicWorkflowNodeMetadata := request.Event.GetTaskNodeMetadata().DynamicWorkflow
if err := ValidateIdentifier(dynamicWorkflowNodeMetadata.Id, common.Workflow); err != nil {
return err
}
if dynamicWorkflowNodeMetadata.CompiledWorkflow == nil {
return shared.GetMissingArgumentError("compiled dynamic workflow")
}
if dynamicWorkflowNodeMetadata.CompiledWorkflow.Primary == nil {
return shared.GetMissingArgumentError("primary dynamic workflow")
}
if dynamicWorkflowNodeMetadata.CompiledWorkflow.Primary.Template == nil {
return shared.GetMissingArgumentError("primary dynamic workflow template")
}
if err := ValidateIdentifier(dynamicWorkflowNodeMetadata.CompiledWorkflow.Primary.Template.Id, common.Workflow); err != nil {
return err
}
}
if err := ValidateOutputData(request.Event.GetOutputData(), maxOutputSizeInBytes); err != nil {
return err
}
return nil
}
func ValidateNodeExecutionListRequest(request admin.NodeExecutionListRequest) error {
if err := ValidateWorkflowExecutionIdentifier(request.WorkflowExecutionId); err != nil {
return shared.GetMissingArgumentError(shared.ExecutionID)
}
if err := ValidateLimit(request.Limit); err != nil {
return err
}
return nil
}
func ValidateNodeExecutionForTaskListRequest(request admin.NodeExecutionForTaskListRequest) error {
if err := ValidateTaskExecutionIdentifier(request.TaskExecutionId); err != nil {
return err
}
if err := ValidateLimit(request.Limit); err != nil {
return err
}
return nil
}