|
| 1 | +package updatestatus |
| 2 | + |
| 3 | +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 4 | + |
| 5 | +// +genclient |
| 6 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 7 | + |
| 8 | +// UpdateStatus reports status for in-progress cluster version updates |
| 9 | +// |
| 10 | +// Compatibility level 4: No compatibility is provided, the API can change at any point for any reason. These capabilities should not be used by applications needing long term support. |
| 11 | +// +openshift:compatibility-gen:level=4 |
| 12 | +// +kubebuilder:object:root=true |
| 13 | +// +kubebuilder:subresource:status |
| 14 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 15 | +// +kubebuilder:resource:path=updatestatuses,scope=Namespaced |
| 16 | +// +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/2012 |
| 17 | +// +openshift:file-pattern=cvoRunLevel=0000_00,operatorName=cluster-version-operator,operatorOrdering=02 |
| 18 | +// +openshift:enable:FeatureGate=UpgradeStatus |
| 19 | +// +kubebuilder:metadata:annotations="description=Provides health and status information about OpenShift cluster updates." |
| 20 | +// +kubebuilder:metadata:annotations="displayName=UpdateStatuses" |
| 21 | +type UpdateStatus struct { |
| 22 | + metav1.TypeMeta `json:",inline"` |
| 23 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 24 | + |
| 25 | + // spec is empty for now, UpdateStatus is purely status-reporting API. In the future spec may be used to hold |
| 26 | + // configuration to drive what information is surfaced and how |
| 27 | + // +kubebuilder:validation:Required |
| 28 | + Spec UpdateStatusSpec `json:"spec"` |
| 29 | + // +optional |
| 30 | + Status UpdateStatusStatus `json:"status"` |
| 31 | +} |
| 32 | + |
| 33 | +// UpdateStatusSpec is empty for now, UpdateStatus is purely status-reporting API. In the future spec may be used |
| 34 | +// to hold configuration to drive what information is surfaced and how |
| 35 | +type UpdateStatusSpec struct { |
| 36 | +} |
| 37 | + |
| 38 | +// +k8s:deepcopy-gen=true |
| 39 | + |
| 40 | +// UpdateStatusStatus is the API about in-progress updates. It aggregates and summarizes UpdateInsights produced by |
| 41 | +// update informers |
| 42 | +type UpdateStatusStatus struct { |
| 43 | + // controlPlane contains a summary and insights related to the control plane update |
| 44 | + // +kubebuilder:validation:Required |
| 45 | + ControlPlane ControlPlane `json:"controlPlane"` |
| 46 | + |
| 47 | + // workerPools contains summaries and insights related to the worker pools update |
| 48 | + // +listType=map |
| 49 | + // +listMapKey=name |
| 50 | + // +optional |
| 51 | + WorkerPools []Pool `json:"workerPools,omitempty"` |
| 52 | + |
| 53 | + // conditions provide details about the controller operational matters |
| 54 | + // +listType=map |
| 55 | + // +listMapKey=type |
| 56 | + // +optional |
| 57 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 58 | +} |
| 59 | + |
| 60 | +// ControlPlane contains a summary and insights related to the control plane update |
| 61 | +type ControlPlane struct { |
| 62 | + // resource is the resource that represents the control plane. It will typically be a ClusterVersion resource |
| 63 | + // in standalone OpenShift and HostedCluster in Hosted Control Planes. |
| 64 | + // |
| 65 | + // Note: By OpenShift API conventions, in isolation this should probably be a specialized reference type that allows |
| 66 | + // only the "correct" resource types to be referenced (here, ClusterVersion and HostedCluster). However, because we |
| 67 | + // use resource references in many places and this API is intended to be consumed by clients, not produced, consistency |
| 68 | + // seems to be more valuable than type safety for producers. |
| 69 | + // +kubebuilder:validation:Required |
| 70 | + Resource ResourceRef `json:"resource"` |
| 71 | + |
| 72 | + // poolResource is the resource that represents control plane node pool, typically a MachineConfigPool. This field |
| 73 | + // is optional because some form factors (like Hosted Control Planes) do not have dedicated control plane node pools. |
| 74 | + // |
| 75 | + // Note: By OpenShift API conventions, in isolation this should probably be a specialized reference type that allows |
| 76 | + // only the "correct" resource types to be referenced (here, MachineConfigPool). However, because we use resource |
| 77 | + // references in many places and this API is intended to be consumed by clients, not produced, consistency seems to be |
| 78 | + // more valuable than type safety for producers. |
| 79 | + // +optional |
| 80 | + PoolResource *PoolResourceRef `json:"poolResource,omitempty"` |
| 81 | + |
| 82 | + // informers is a list of insight producers, each carries a list of insights relevant for control plane |
| 83 | + // +listType=map |
| 84 | + // +listMapKey=name |
| 85 | + // +optional |
| 86 | + Informers []Informer `json:"informers,omitempty"` |
| 87 | + |
| 88 | + // conditions provides details about the control plane update |
| 89 | + // +listType=map |
| 90 | + // +listMapKey=type |
| 91 | + // +optional |
| 92 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 93 | +} |
| 94 | + |
| 95 | +// ControlPlaneConditionType are types of conditions that can be reported on control plane level |
| 96 | +type ControlPlaneConditionType string |
| 97 | + |
| 98 | +const ( |
| 99 | + // Updating is the condition type that communicate whether the whole control plane is updating or not |
| 100 | + ControlPlaneUpdating ControlPlaneConditionType = "Updating" |
| 101 | +) |
| 102 | + |
| 103 | +// ControlPlaneUpdatingReason are well-known reasons for the Updating condition |
| 104 | +// +kubebuilder:validation:Enum=ClusterVersionProgressing;ClusterVersionNotProgressing;CannotDetermineUpdating |
| 105 | +type ControlPlaneUpdatingReason string |
| 106 | + |
| 107 | +const ( |
| 108 | + // ClusterVersionProgressing is used for Updating=True set because we observed a ClusterVersion resource to |
| 109 | + // have Progressing=True condition |
| 110 | + ReasonClusterVersionProgressing ControlPlaneUpdatingReason = "ClusterVersionProgressing" |
| 111 | + // ClusterVersionNotProgressing is used for Updating=False set because we observed a ClusterVersion resource to |
| 112 | + // have Progressing=False condition |
| 113 | + ReasonClusterVersionNotProgressing ControlPlaneUpdatingReason = "ClusterVersionNotProgressing" |
| 114 | + // CannotDetermineUpdating is used with Updating=Unknown. This covers many different actual reasons such as |
| 115 | + // missing or Unknown Progressing condition on ClusterVersion, but it does not seem useful to track the individual |
| 116 | + // reasons to that granularity for Updating=Unknown |
| 117 | + ReasonClusterVersionCannotDetermine ControlPlaneUpdatingReason = "CannotDetermineUpdating" |
| 118 | +) |
| 119 | + |
| 120 | +// Pool contains a summary and insights related to a node pool update |
| 121 | +type Pool struct { |
| 122 | + // name is the name of the pool |
| 123 | + // +kubebuilder:validation:Required |
| 124 | + Name string `json:"name"` |
| 125 | + |
| 126 | + // resource is the resource that represents the pool |
| 127 | + // |
| 128 | + // Note: By OpenShift API conventions, in isolation this should probably be a specialized reference type that allows |
| 129 | + // only the "correct" resource types to be referenced (here, MachineConfigPool or NodePool). However, because we use |
| 130 | + // resource references in many places and this API is intended to be consumed by clients, not produced, consistency |
| 131 | + // seems to be more valuable than type safety for producers. |
| 132 | + // +kubebuilder:validation:Required |
| 133 | + Resource PoolResourceRef `json:"resource"` |
| 134 | + |
| 135 | + // informers is a list of insight producers, each carries a list of insights |
| 136 | + // +listType=map |
| 137 | + // +listMapKey=name |
| 138 | + // +optional |
| 139 | + Informers []Informer `json:"informers,omitempty"` |
| 140 | + |
| 141 | + // conditions provide details about the pool |
| 142 | + // +listType=map |
| 143 | + // +listMapKey=type |
| 144 | + // +optional |
| 145 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 146 | +} |
| 147 | + |
| 148 | +// Informer is an insight producer identified by a name, carrying a list of insights it produced |
| 149 | +type Informer struct { |
| 150 | + // name is the name of the insight producer |
| 151 | + // +kubebuilder:validation:Required |
| 152 | + Name string `json:"name"` |
| 153 | + |
| 154 | + // insights is a list of insights produced by this producer |
| 155 | + // +optional |
| 156 | + // +listType=map |
| 157 | + // +listMapKey=uid |
| 158 | + Insights []Insight `json:"insights,omitempty"` |
| 159 | +} |
| 160 | + |
| 161 | +// Insight is a unique piece of either status/progress or update health information produced by update informer |
| 162 | +type Insight struct { |
| 163 | + // uid identifies the insight over time |
| 164 | + // +kubebuilder:validation:Required |
| 165 | + // +kubebuilder:validation:Type=string |
| 166 | + UID string `json:"uid"` |
| 167 | + |
| 168 | + // acquiredAt is the time when the data was acquired by the producer |
| 169 | + // +kubebuilder:validation:Required |
| 170 | + // +kubebuilder:validation:Type=string |
| 171 | + // +kubebuilder:validation:Format=date-time |
| 172 | + AcquiredAt metav1.Time `json:"acquiredAt"` |
| 173 | + |
| 174 | + InsightUnion `json:",inline"` |
| 175 | +} |
| 176 | + |
| 177 | +// InsightUnion is the discriminated union of all insights types, identified by type field |
| 178 | +type InsightUnion struct { |
| 179 | + // type identifies the type of the update insight |
| 180 | + // +unionDiscriminator |
| 181 | + // +kubebuilder:validation:Required |
| 182 | + // +kubebuilder:validation:Enum=ClusterVersion;ClusterOperator;MachineConfigPool;Node;Health |
| 183 | + Type InsightType `json:"type"` |
| 184 | + |
| 185 | + // clusterVersion is a status insight about the state of a control plane update, where |
| 186 | + // the control plane is represented by a ClusterVersion resource usually managed by CVO |
| 187 | + // +optional |
| 188 | + // +unionMember |
| 189 | + ClusterVersionStatusInsight *ClusterVersionStatusInsight `json:"clusterVersion,omitempty"` |
| 190 | + |
| 191 | + // clusterOperator is a status insight about the state of a control plane cluster operator update |
| 192 | + // represented by a ClusterOperator resource |
| 193 | + // +optional |
| 194 | + // +unionMember |
| 195 | + ClusterOperatorStatusInsight *ClusterOperatorStatusInsight `json:"clusterOperator,omitempty"` |
| 196 | + |
| 197 | + // machineConfigPool is a status insight about the state of a worker pool update, where the worker pool |
| 198 | + // is represented by a MachineConfigPool resource |
| 199 | + // +optional |
| 200 | + // +unionMember |
| 201 | + MachineConfigPoolStatusInsight *MachineConfigPoolStatusInsight `json:"machineConfigPool,omitempty"` |
| 202 | + |
| 203 | + // node is a status insight about the state of a worker node update, where the worker node is represented |
| 204 | + // by a Node resource |
| 205 | + // +optional |
| 206 | + // +unionMember |
| 207 | + NodeStatusInsight *NodeStatusInsight `json:"node,omitempty"` |
| 208 | + |
| 209 | + // health is a generic health insight about the update. It does not represent a status of any specific |
| 210 | + // resource but surfaces actionable information about the health of the cluster or an update |
| 211 | + // +optional |
| 212 | + // +unionMember |
| 213 | + HealthInsight *HealthInsight `json:"health,omitempty"` |
| 214 | +} |
| 215 | + |
| 216 | +// InsightType identifies the type of the update insight as either one of the resource-specific status insight, |
| 217 | +// or a generic health insight |
| 218 | +// +kubebuilder:validation:Enum=ClusterVersion;ClusterOperator;MachineConfigPool;Node;Health |
| 219 | +type InsightType string |
| 220 | + |
| 221 | +const ( |
| 222 | + // Resource-specific status insights should be reported continuously during the update process and mostly communicate |
| 223 | + // progress and high-level state |
| 224 | + |
| 225 | + // ClusterVersion status insight reports progress and high-level state of a ClusterVersion resource, representing |
| 226 | + // control plane in standalone clusters |
| 227 | + ClusterVersionStatusInsightType InsightType = "ClusterVersion" |
| 228 | + // ClusterOperator status insight reports progress and high-level state of a ClusterOperator, representing a control |
| 229 | + // plane component |
| 230 | + ClusterOperatorStatusInsightType InsightType = "ClusterOperator" |
| 231 | + // MachineConfigPool status insight reports progress and high-level state of a MachineConfigPool resource, representing |
| 232 | + // a pool of nodes in clusters using Machine API |
| 233 | + MachineConfigPoolStatusInsightType InsightType = "MachineConfigPool" |
| 234 | + // Node status insight reports progress and high-level state of a Node resource, representing a node (both control |
| 235 | + // plane and worker) in a cluster |
| 236 | + NodeStatusInsightType InsightType = "Node" |
| 237 | + |
| 238 | + // Health insights are reported only when an informer observes a condition that requires admin attention |
| 239 | + HealthInsightType InsightType = "Health" |
| 240 | +) |
| 241 | + |
| 242 | +// ResourceRef is a reference to a kubernetes resource, typically involved in an insight |
| 243 | +type ResourceRef struct { |
| 244 | + // group of the object being referenced, if any |
| 245 | + // +optional |
| 246 | + Group string `json:"group,omitempty"` |
| 247 | + |
| 248 | + // resource of object being referenced |
| 249 | + // +kubebuilder:validation:Required |
| 250 | + Resource string `json:"resource"` |
| 251 | + |
| 252 | + // name of the object being referenced |
| 253 | + // +kubebuilder:validation:Required |
| 254 | + Name string `json:"name"` |
| 255 | + |
| 256 | + // namespace of the object being referenced, if any |
| 257 | + // +optional |
| 258 | + Namespace string `json:"namespace,omitempty"` |
| 259 | +} |
| 260 | + |
| 261 | +// PoolResourceRef is a reference to a kubernetes resource that represents a node pool |
| 262 | +type PoolResourceRef struct { |
| 263 | + ResourceRef `json:",inline"` |
| 264 | +} |
| 265 | + |
| 266 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 267 | + |
| 268 | +// UpdateStatusList is a list of UpdateStatus resources |
| 269 | +// |
| 270 | +// Compatibility level 4: No compatibility is provided, the API can change at any point for any reason. These capabilities should not be used by applications needing long term support. |
| 271 | +// +openshift:compatibility-gen:level=4 |
| 272 | +type UpdateStatusList struct { |
| 273 | + metav1.TypeMeta `json:",inline"` |
| 274 | + metav1.ListMeta `json:"metadata"` |
| 275 | + |
| 276 | + Items []UpdateStatus `json:"items"` |
| 277 | +} |
0 commit comments