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 62
/
node_execution.go
110 lines (102 loc) · 4.22 KB
/
node_execution.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package adminservice
import (
"context"
"github.com/flyteorg/flytestdlib/logger"
"github.com/flyteorg/flyteadmin/pkg/rpc/adminservice/util"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (m *AdminService) CreateNodeEvent(
ctx context.Context, request *admin.NodeExecutionEventRequest) (*admin.NodeExecutionEventResponse, error) {
defer m.interceptPanic(ctx, request)
if request == nil {
return nil, status.Errorf(codes.InvalidArgument, "Incorrect request, nil requests not allowed")
}
var response *admin.NodeExecutionEventResponse
var err error
m.Metrics.nodeExecutionEndpointMetrics.createEvent.Time(func() {
response, err = m.NodeExecutionManager.CreateNodeEvent(ctx, *request)
})
if err != nil {
return nil, util.TransformAndRecordError(err, &m.Metrics.nodeExecutionEndpointMetrics.createEvent)
}
m.Metrics.nodeExecutionEndpointMetrics.createEvent.Success()
return response, nil
}
func (m *AdminService) GetNodeExecution(
ctx context.Context, request *admin.NodeExecutionGetRequest) (*admin.NodeExecution, error) {
defer m.interceptPanic(ctx, request)
if request == nil {
return nil, status.Errorf(codes.InvalidArgument, "Incorrect request, nil requests not allowed")
}
var response *admin.NodeExecution
var err error
m.Metrics.nodeExecutionEndpointMetrics.get.Time(func() {
response, err = m.NodeExecutionManager.GetNodeExecution(ctx, *request)
})
if err != nil {
return nil, util.TransformAndRecordError(err, &m.Metrics.nodeExecutionEndpointMetrics.get)
}
m.Metrics.nodeExecutionEndpointMetrics.get.Success()
return response, nil
}
func (m *AdminService) ListNodeExecutions(
ctx context.Context, request *admin.NodeExecutionListRequest) (*admin.NodeExecutionList, error) {
defer m.interceptPanic(ctx, request)
if request == nil {
return nil, status.Errorf(codes.InvalidArgument, "Incorrect request, nil requests not allowed")
}
var response *admin.NodeExecutionList
var err error
m.Metrics.nodeExecutionEndpointMetrics.list.Time(func() {
response, err = m.NodeExecutionManager.ListNodeExecutions(ctx, *request)
})
if err != nil {
return nil, util.TransformAndRecordError(err, &m.Metrics.nodeExecutionEndpointMetrics.list)
}
m.Metrics.nodeExecutionEndpointMetrics.list.Success()
return response, nil
}
func (m *AdminService) ListNodeExecutionsForTask(
ctx context.Context, request *admin.NodeExecutionForTaskListRequest) (*admin.NodeExecutionList, error) {
defer m.interceptPanic(ctx, request)
if request == nil {
return nil, status.Errorf(codes.InvalidArgument, "Incorrect request, nil requests not allowed")
}
// NOTE: When the Get HTTP endpoint is called the resource type is implicit (from the URL) so we must add it
// to the request.
if request.TaskExecutionId != nil && request.TaskExecutionId.TaskId != nil &&
request.TaskExecutionId.TaskId.ResourceType == core.ResourceType_UNSPECIFIED {
logger.Info(ctx, "Adding resource type for unspecified value in request: [%+v]", request)
request.TaskExecutionId.TaskId.ResourceType = core.ResourceType_TASK
}
var response *admin.NodeExecutionList
var err error
m.Metrics.nodeExecutionEndpointMetrics.listChildren.Time(func() {
response, err = m.NodeExecutionManager.ListNodeExecutionsForTask(ctx, *request)
})
if err != nil {
return nil, util.TransformAndRecordError(err, &m.Metrics.nodeExecutionEndpointMetrics.listChildren)
}
m.Metrics.nodeExecutionEndpointMetrics.listChildren.Success()
return response, nil
}
func (m *AdminService) GetNodeExecutionData(
ctx context.Context, request *admin.NodeExecutionGetDataRequest) (*admin.NodeExecutionGetDataResponse, error) {
defer m.interceptPanic(ctx, request)
if request == nil {
return nil, status.Errorf(codes.InvalidArgument, "Incorrect request, nil requests not allowed")
}
var response *admin.NodeExecutionGetDataResponse
var err error
m.Metrics.nodeExecutionEndpointMetrics.getData.Time(func() {
response, err = m.NodeExecutionManager.GetNodeExecutionData(ctx, *request)
})
if err != nil {
return nil, util.TransformAndRecordError(err, &m.Metrics.nodeExecutionEndpointMetrics.getData)
}
m.Metrics.nodeExecutionEndpointMetrics.getData.Success()
return response, nil
}