@@ -100,6 +100,10 @@ type BatchSandboxStatus struct {
100100 TaskPending int32 `json:"taskPending"`
101101 // TaskUnknown is the number of Unknown task
102102 TaskUnknown int32 `json:"taskUnknown"`
103+ // TaskLastErrorMessage holds the most recent error message from a failed task.
104+ // This includes lifecycle hook failures (e.g., ossfs mount timeout or error output).
105+ // +optional
106+ TaskLastErrorMessage string `json:"taskLastErrorMessage,omitempty"`
103107}
104108
105109// +genclient
@@ -145,6 +149,17 @@ type TaskTemplateSpec struct {
145149 Spec TaskSpec `json:"spec,omitempty"`
146150}
147151
152+ // ExecMode defines where a process should be executed.
153+ // +kubebuilder:validation:Enum=Local;Remote
154+ type ExecMode string
155+
156+ const (
157+ // ExecModeLocal executes in the task-executor container.
158+ ExecModeLocal ExecMode = "Local"
159+ // ExecModeRemote executes in the main container via nsenter.
160+ ExecModeRemote ExecMode = "Remote"
161+ )
162+
148163type TaskSpec struct {
149164 // +optional
150165 Process * ProcessTask `json:"process,omitempty"`
@@ -169,6 +184,49 @@ type ProcessTask struct {
169184 // WorkingDir task working directory.
170185 // +optional
171186 WorkingDir string `json:"workingDir,omitempty"`
187+ // ExecMode controls where the process runs.
188+ // Local: inside task-executor container.
189+ // Remote: inside main container (via nsenter).
190+ // +optional
191+ // +kubebuilder:default=Local
192+ ExecMode ExecMode `json:"execMode,omitempty"`
193+ // Lifecycle defines actions to be executed before and after the main process.
194+ // +optional
195+ Lifecycle * ProcessLifecycle `json:"lifecycle,omitempty"`
196+ }
197+
198+ // ProcessLifecycle defines lifecycle hooks for a process.
199+ type ProcessLifecycle struct {
200+ // PreStart is executed before the main process starts.
201+ // +optional
202+ PreStart * LifecycleHandler `json:"preStart,omitempty"`
203+ // PostStop is executed after the main process stops.
204+ // +optional
205+ PostStop * LifecycleHandler `json:"postStop,omitempty"`
206+ }
207+
208+ // LifecycleHandler defines a lifecycle action.
209+ type LifecycleHandler struct {
210+ // Exec specifies the action to take.
211+ // +optional
212+ Exec * ExecAction `json:"exec,omitempty"`
213+ // ExecMode controls where the action runs.
214+ // +optional
215+ // +kubebuilder:default=Local
216+ ExecMode ExecMode `json:"execMode,omitempty"`
217+ // TimeoutSeconds is the maximum number of seconds the hook may run.
218+ // If the hook does not complete within this time, it is killed and the
219+ // enclosing operation (Start or Stop) is treated as failed.
220+ // If not set or zero, there is no timeout.
221+ // +optional
222+ TimeoutSeconds * int64 `json:"timeoutSeconds,omitempty"`
223+ }
224+
225+ // ExecAction describes a "run in container" action.
226+ type ExecAction struct {
227+ // Command is the command line to execute inside the container.
228+ // +kubebuilder:validation:Required
229+ Command []string `json:"command"`
172230}
173231
174232// TaskStatus task status
0 commit comments