Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions pkg/apis/flow/v1alpha1/jobflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type JobFlowSpec struct {
Flows []Flow `json:"flows,omitempty"`
// +optional
JobRetainPolicy RetainPolicy `json:"jobRetainPolicy,omitempty"`
// +optional
RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"`
}

// Flow defines the dependent of jobs
Expand All @@ -37,6 +39,8 @@ type Flow struct {
Name string `json:"name"`
// +optional
DependsOn *DependsOn `json:"dependsOn,omitempty"`
// +optional
RetryPolicy *RetryPolicy `json:"retryPolicy,omitempty"`
}

type DependsOn struct {
Expand All @@ -46,6 +50,48 @@ type DependsOn struct {
Probe *Probe `json:"probe,omitempty"`
}

type RetryPolicy struct {
// Maximum number of retries allowed (default: 0 = no retry)
// +optional
// +kubebuilder:validation:Minimum=0
MaxRetries int32 `json:"maxRetries,omitempty"`

// +optional
// +kubebuilder:validation:Enum=Always;OnFailure;Never
Policy RetryStrategy `json:"policy,omitempty"`

// +optional
Backoff *BackoffPolicy `json:"backoff,omitempty"`
}

type RetryStrategy string

const (
RetryAlways RetryStrategy = "Always"
RetryOnFailure RetryStrategy = "OnFailure"
RetryNever RetryStrategy = "Never"
)

type BackoffPolicy struct {
// +kubebuilder:validation:Enum=Constant;Exponential
Type BackoffType `json:"type,omitempty"`

// Base delay before retry (e.g., 30s)
// +optional
BaseDelay metav1.Duration `json:"baseDelay,omitempty"`

// Max delay cap (optional, mainly for exponential backoff)
// +optional
MaxDelay *metav1.Duration `json:"maxDelay,omitempty"`
}

type BackoffType string

const (
BackoffConstant BackoffType = "Constant"
BackoffExponential BackoffType = "Exponential"
)

type Probe struct {
// +optional
HttpGetList []HttpGet `json:"httpGetList,omitempty"`
Expand Down Expand Up @@ -119,6 +165,10 @@ type JobStatus struct {
RestartCount int32 `json:"restartCount,omitempty"`
// +optional
RunningHistories []JobRunningHistory `json:"runningHistories,omitempty"`
// +optional
RetryCount int32 `json:"retryCount,omitempty"`
// +optional
LastFailureReason string `json:"lastFailureReason,omitempty"`
}

type JobRunningHistory struct {
Expand Down