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
/
task_execution_validator.go
59 lines (50 loc) · 1.68 KB
/
task_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
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 ValidateTaskExecutionRequest(request admin.TaskExecutionEventRequest, maxOutputSizeInBytes int64) error {
if request.Event == nil {
return shared.GetMissingArgumentError(shared.Event)
}
if request.Event.OccurredAt == nil {
return shared.GetMissingArgumentError(shared.OccurredAt)
}
if err := ValidateOutputData(request.Event.GetOutputData(), maxOutputSizeInBytes); err != nil {
return err
}
return ValidateTaskExecutionIdentifier(&core.TaskExecutionIdentifier{
TaskId: request.Event.TaskId,
NodeExecutionId: request.Event.ParentNodeExecutionId,
RetryAttempt: request.Event.RetryAttempt,
})
}
func ValidateTaskExecutionIdentifier(identifier *core.TaskExecutionIdentifier) error {
if identifier == nil {
return shared.GetMissingArgumentError(shared.ID)
}
if identifier.NodeExecutionId == nil {
return shared.GetMissingArgumentError(shared.NodeExecutionID)
}
if err := ValidateNodeExecutionIdentifier(identifier.NodeExecutionId); err != nil {
return err
}
if identifier.TaskId == nil {
return shared.GetMissingArgumentError(shared.TaskID)
}
if err := ValidateIdentifier(identifier.TaskId, common.Task); err != nil {
return err
}
return nil
}
func ValidateTaskExecutionListRequest(request admin.TaskExecutionListRequest) error {
if err := ValidateNodeExecutionIdentifier(request.NodeExecutionId); err != nil {
return err
}
if err := ValidateLimit(request.Limit); err != nil {
return err
}
return nil
}