volcano.sh/apis@v1.8.2/pkg/apis/flow/v1alpha1/jobflow_types.go (about) 1 /* 2 Copyright 2021. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1alpha1 18 19 import ( 20 v1 "k8s.io/api/core/v1" 21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 "volcano.sh/apis/pkg/apis/batch/v1alpha1" 23 ) 24 25 // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! 26 // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. 27 28 // JobFlowSpec defines the desired state of JobFlow 29 type JobFlowSpec struct { 30 // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster 31 // Important: Run "make" to regenerate code after modifying this file 32 33 // Foo is an example field of JobFlow. Edit jobflow_types.go to remove/update 34 Flows []Flow `json:"flows,omitempty"` 35 JobRetainPolicy string `json:"jobRetainPolicy,omitempty"` 36 } 37 38 // Flow defines the dependent of jobs 39 type Flow struct { 40 Name string `json:"name"` 41 DependsOn *DependsOn `json:"dependsOn,omitempty"` 42 } 43 44 type DependsOn struct { 45 Targets []string `json:"targets,omitempty"` 46 Probe *Probe `json:"probe,omitempty"` 47 } 48 49 type Probe struct { 50 HttpGetList []HttpGet `json:"httpGetList,omitempty"` 51 TcpSocketList []TcpSocket `json:"tcpSocketList,omitempty"` 52 TaskStatusList []TaskStatus `json:"taskStatusList,omitempty"` 53 } 54 55 type HttpGet struct { 56 TaskName string `json:"taskName,omitempty"` 57 Path string `json:"path,omitempty"` 58 Port int `json:"port,omitempty"` 59 HTTPHeader v1.HTTPHeader `json:"httpHeader,omitempty"` 60 } 61 62 type TcpSocket struct { 63 TaskName string `json:"taskName,omitempty"` 64 Port int `json:"port"` 65 } 66 67 type TaskStatus struct { 68 TaskName string `json:"taskName,omitempty"` 69 Phase string `json:"phase,omitempty"` 70 } 71 72 // JobFlowStatus defines the observed state of JobFlow 73 type JobFlowStatus struct { 74 // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster 75 // Important: Run "make" to regenerate code after modifying this file 76 77 PendingJobs []string `json:"pendingJobs,omitempty"` 78 RunningJobs []string `json:"runningJobs,omitempty"` 79 FailedJobs []string `json:"failedJobs,omitempty"` 80 CompletedJobs []string `json:"completedJobs,omitempty"` 81 TerminatedJobs []string `json:"terminatedJobs,omitempty"` 82 UnKnowJobs []string `json:"unKnowJobs,omitempty"` 83 JobStatusList []JobStatus `json:"jobStatusList,omitempty"` 84 Conditions map[string]Condition `json:"conditions,omitempty"` 85 State State `json:"state,omitempty"` 86 } 87 88 type JobStatus struct { 89 Name string `json:"name,omitempty"` 90 State v1alpha1.JobPhase `json:"state,omitempty"` 91 StartTimestamp metav1.Time `json:"startTimestamp,omitempty"` 92 EndTimestamp metav1.Time `json:"endTimestamp,omitempty"` 93 RestartCount int32 `json:"restartCount,omitempty"` 94 RunningHistories []JobRunningHistory `json:"runningHistories,omitempty"` 95 } 96 97 type JobRunningHistory struct { 98 StartTimestamp metav1.Time `json:"startTimestamp,omitempty"` 99 EndTimestamp metav1.Time `json:"endTimestamp,omitempty"` 100 State v1alpha1.JobPhase `json:"state,omitempty"` 101 } 102 103 type State struct { 104 Phase Phase `json:"phase,omitempty"` 105 } 106 107 type Phase string 108 109 const ( 110 Retain = "retain" 111 Delete = "delete" 112 ) 113 114 const ( 115 Succeed Phase = "Succeed" 116 Terminating Phase = "Terminating" 117 Failed Phase = "Failed" 118 Running Phase = "Running" 119 Pending Phase = "Pending" 120 ) 121 122 type Condition struct { 123 Phase v1alpha1.JobPhase `json:"phase,omitempty"` 124 CreateTimestamp metav1.Time `json:"createTime,omitempty"` 125 RunningDuration *metav1.Duration `json:"runningDuration,omitempty"` 126 TaskStatusCount map[string]v1alpha1.TaskState `json:"taskStatusCount,omitempty"` 127 } 128 129 // +genclient 130 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 131 //+kubebuilder:object:root=true 132 //+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.state.phase" 133 // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" 134 // +kubebuilder:resource:path=jobflows,shortName=jf 135 //+kubebuilder:subresource:status 136 137 // JobFlow is the Schema for the jobflows API 138 type JobFlow struct { 139 metav1.TypeMeta `json:",inline"` 140 metav1.ObjectMeta `json:"metadata,omitempty"` 141 142 Spec JobFlowSpec `json:"spec,omitempty"` 143 Status JobFlowStatus `json:"status,omitempty"` 144 } 145 146 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 147 //+kubebuilder:object:root=true 148 149 // JobFlowList contains a list of JobFlow 150 type JobFlowList struct { 151 metav1.TypeMeta `json:",inline"` 152 metav1.ListMeta `json:"metadata,omitempty"` 153 Items []JobFlow `json:"items"` 154 }