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 53
/
state.go
59 lines (43 loc) · 2 KB
/
state.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 webapi
import (
"time"
"github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/webapi"
)
//go:generate enumer -type=Phase -trimprefix=Phase
// Phase represents current phase of the execution
type Phase int
const (
// PhaseNotStarted the default phase.
PhaseNotStarted Phase = iota
// PhaseAllocationTokenAcquired once all required tokens have been acquired. The task is ready to be executed
// remotely.
PhaseAllocationTokenAcquired
// PhaseResourcesCreated indicates the task has been created remotely.
PhaseResourcesCreated
// The resource has successfully been executed remotely.
PhaseSucceeded
// The resource has failed to be executed.
PhaseUserFailure
// The resource has failed to be executed due to a system error.
PhaseSystemFailure
)
func (i Phase) IsTerminal() bool {
return i == PhaseSucceeded || i == PhaseUserFailure || i == PhaseSystemFailure
}
// State is the persisted State of the resource.
type State struct {
// Phase current phase of the resource.
Phase Phase `json:"phase,omitempty"`
// ResourceMeta contain metadata about resource this task created. This can be a complex structure or a simple type
// (e.g. a string). It should contain enough information for the plugin to interact (retrieve, check status, delete)
// with the resource through the remote service.
ResourceMeta webapi.ResourceMeta `json:"resourceMeta,omitempty"`
// This number keeps track of the number of failures within the sync function. Without this, what happens in
// the sync function is entirely opaque. Note that this field is completely orthogonal to Flyte system/node/task
// level retries, just errors from hitting API, inside the sync loop
SyncFailureCount int `json:"syncFailureCount,omitempty"`
// In creating the resource, this is the number of failures
CreationFailureCount int `json:"creationFailureCount,omitempty"`
// The time the execution first requests for an allocation token
AllocationTokenRequestStartTime time.Time `json:"allocationTokenRequestStartTime,omitempty"`
}