@@ -23,24 +23,185 @@ import (
2323// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
2424// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
2525
26+ // ========== DPU operation types ==========
27+
28+ type DpuOperationType string
29+
30+ const (
31+ // DpuOpNone No operation (default)
32+ DpuOpNone DpuOperationType = "None"
33+ // DpuOpFirmwareUpgrade Firmware upgrade operation
34+ DpuOpFirmwareUpgrade DpuOperationType = "FirmwareUpgrade"
35+ // DpuOpReboot DPU reboot operation (mandatory after firmware upgrade)
36+ DpuOpReboot DpuOperationType = "Reboot"
37+ )
38+
39+ // ========== Firmware types ==========
40+
41+ type DpuFirmwareType string
42+
43+ const (
44+ // DpuFirmwareTypeOAM OAM type firmware
45+ DpuFirmwareTypeOAM DpuFirmwareType = "OAM"
46+ // DpuFirmwareTypeSDK SDK type firmware
47+ DpuFirmwareTypeSDK DpuFirmwareType = "SDK"
48+ )
49+
50+ // ========== Operation status phases ==========
51+
52+ type DpuOperationStatusPhase string
53+
54+ const (
55+ // DpuPhasePending Operation pending execution (default)
56+ DpuPhasePending DpuOperationStatusPhase = "Pending"
57+ // DpuPhaseRunning Operation is in progress
58+ DpuPhaseRunning DpuOperationStatusPhase = "Running"
59+ // DpuPhaseRebooting DPU is rebooting (waiting for it to come back online)
60+ DpuPhaseRebooting DpuOperationStatusPhase = "Rebooting"
61+ // DpuPhaseSucceeded Operation completed successfully
62+ DpuPhaseSucceeded DpuOperationStatusPhase = "Succeeded"
63+ // DpuPhaseFailed Operation execution failed
64+ DpuPhaseFailed DpuOperationStatusPhase = "Failed"
65+ // DpuPhaseCancelled Operation was cancelled
66+ DpuPhaseCancelled DpuOperationStatusPhase = "Cancelled"
67+ )
68+
69+ // ========== Health status ==========
70+
71+ type DpuHealthStatus string
72+
73+ const (
74+ // HealthStatusHealthy DPU is healthy and responding
75+ HealthStatusHealthy DpuHealthStatus = "Healthy"
76+ // HealthStatusUnhealthy DPU is not responding
77+ HealthStatusUnhealthy DpuHealthStatus = "Unhealthy"
78+ // HealthStatusUnknown DPU health is unknown
79+ HealthStatusUnknown DpuHealthStatus = "Unknown"
80+ )
81+
82+ // ========== Firmware specification ==========
83+
84+ // DpuFirmwareSpec defines the firmware upgrade parameters.
85+ type DpuFirmwareSpec struct {
86+ // Firmware type (OAM/SDK)
87+ // +kubebuilder:validation:Required
88+ // +kubebuilder:validation:Enum=OAM;SDK
89+ Type DpuFirmwareType `json:"type"`
90+
91+ // Target firmware version number
92+ // +kubebuilder:validation:Required
93+ TargetVersion string `json:"targetVersion"`
94+
95+ // Firmware image path or URI (e.g. quay.io/openshift/firmware/dpu:v1.0.8)
96+ // +optional
97+ FirmwarePath string `json:"firmwarePath,omitempty"`
98+ }
99+
100+ // ========== DPU management (spec) ==========
101+
102+ // DataProcessingUnitManagement defines the desired management operation on a DPU.
103+ type DataProcessingUnitManagement struct {
104+ // DPU operation type to execute: None, FirmwareUpgrade, or Reboot.
105+ // +kubebuilder:validation:Enum=None;FirmwareUpgrade;Reboot
106+ // +kubebuilder:default=None
107+ Operation DpuOperationType `json:"operation,omitempty"`
108+
109+ // Detailed configuration for firmware upgrade.
110+ // Required when Operation is FirmwareUpgrade.
111+ // +optional
112+ Firmware * DpuFirmwareSpec `json:"firmware,omitempty"`
113+ }
114+
115+ // ========== Spec ==========
116+
26117// DataProcessingUnitConfigSpec defines the desired state of DataProcessingUnitConfig.
27118type DataProcessingUnitConfigSpec struct {
28- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29- // Important: Run "make" to regenerate code after modifying this file
30-
31- // DpuSelector specifies which DPUs this DpuConfig CR should target.
32- // If empty, the DpuConfig will target all DPUs.
119+ // DpuSelector specifies which DPUs this config should target.
120+ // Must include a pci-address label to uniquely identify the DPU on
121+ // nodes that have more than one DPU of the same vendor.
33122 // +optional
34123 DpuSelector * metav1.LabelSelector `json:"dpuSelector,omitempty"`
35124
36- // Foo is an example field of DataProcessingUnitConfig. Edit dataprocessingunitconfig_types.go to remove/update
37- Foo string `json:"foo ,omitempty"`
125+ // DpuManagement specifies the management operation to perform.
126+ DpuManagement DataProcessingUnitManagement `json:"dpuManagement ,omitempty"`
38127}
39128
129+ // ========== Status ==========
130+
131+ // DpuNodeOperationStatus tracks the status of the current management operation.
132+ type DpuNodeOperationStatus struct {
133+ // SubOperation type: distinguishes FirmwareUpgrade from Reboot.
134+ SubOperation DpuOperationType `json:"subOperation,omitempty"`
135+
136+ // FirmwareType (valid only when SubOperation is FirmwareUpgrade): OAM/SDK
137+ FirmwareType DpuFirmwareType `json:"firmwareType,omitempty"`
138+
139+ // Phase is the current status of the operation: Pending/Running/Succeeded/Failed.
140+ Phase DpuOperationStatusPhase `json:"phase,omitempty"`
141+
142+ // StartTime is when the operation started.
143+ // +optional
144+ StartTime * metav1.Time `json:"startTime,omitempty"`
145+
146+ // CompletionTime is when the operation completed (success or failure).
147+ // +optional
148+ CompletionTime * metav1.Time `json:"completionTime,omitempty"`
149+
150+ // PreviousVersion is the firmware version before upgrade.
151+ // +optional
152+ PreviousVersion string `json:"previousVersion,omitempty"`
153+
154+ // TargetVersion is the desired firmware version for upgrade.
155+ // +optional
156+ TargetVersion string `json:"targetVersion,omitempty"`
157+
158+ // Message is a human-readable summary of the operation result.
159+ // +optional
160+ Message string `json:"message,omitempty"`
161+
162+ // ErrorMessage contains error details when the operation fails.
163+ // +optional
164+ ErrorMessage string `json:"errorMessage,omitempty"`
165+ }
166+
167+ // DpuHealthInfo tracks the health / liveness of the DPU.
168+ type DpuHealthInfo struct {
169+ // Status is the current health of the DPU: Healthy/Unhealthy/Unknown.
170+ Status DpuHealthStatus `json:"status,omitempty"`
171+
172+ // Message is a human-readable health description.
173+ // +optional
174+ Message string `json:"message,omitempty"`
175+
176+ // LastProbeTime is the last time the health was checked.
177+ // +optional
178+ LastProbeTime * metav1.Time `json:"lastProbeTime,omitempty"`
179+ }
180+
181+ // ConditionTypeReady is the standard K8s condition used for kubectl-wait support.
182+ //
183+ // kubectl wait dpuconfig/<name> --for=condition=Ready --timeout=600s
184+ //
185+ // Condition values:
186+ // - True: phase=Succeeded and DPU is healthy
187+ // - False: phase=Failed or DPU is unreachable
188+ // - Unknown: operation in progress (Rebooting/Running)
189+ const ConditionTypeReady = "Ready"
190+
40191// DataProcessingUnitConfigStatus defines the observed state of DataProcessingUnitConfig.
41192type DataProcessingUnitConfigStatus struct {
42- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
43- // Important: Run "make" to regenerate code after modifying this file
193+ // NodeStatus tracks the current management-operation status.
194+ NodeStatus DpuNodeOperationStatus `json:"nodeStatus,omitempty"`
195+
196+ // Health tracks the DPU liveness information.
197+ Health DpuHealthInfo `json:"health,omitempty"`
198+
199+ // Conditions holds standard Kubernetes status conditions.
200+ // The "Ready" condition supports `kubectl wait --for=condition=Ready`.
201+ // +optional
202+ // +listType=map
203+ // +listMapKey=type
204+ Conditions []metav1.Condition `json:"conditions,omitempty"`
44205}
45206
46207// +kubebuilder:object:root=true
0 commit comments