Skip to content

Commit 8a55ae2

Browse files
committed
USC: Pull latest UpdateStatus API code
The `UpdateStatus` API PR was recently updated to a version proposed for review & potential approval and merge. openshift/api@4758efa
1 parent 81e4b97 commit 8a55ae2

File tree

4 files changed

+455
-225
lines changed

4 files changed

+455
-225
lines changed

pkg/updatestatus/types_update_status.go

Lines changed: 160 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,23 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1212
// +kubebuilder:object:root=true
1313
// +kubebuilder:subresource:status
1414
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
15-
// +kubebuilder:resource:path=updatestatuses,scope=Namespaced
15+
// +kubebuilder:resource:path=updatestatuses,scope=Cluster
1616
// +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/2012
1717
// +openshift:file-pattern=cvoRunLevel=0000_00,operatorName=cluster-version-operator,operatorOrdering=02
1818
// +openshift:enable:FeatureGate=UpgradeStatus
1919
// +kubebuilder:metadata:annotations="description=Provides health and status information about OpenShift cluster updates."
2020
// +kubebuilder:metadata:annotations="displayName=UpdateStatuses"
2121
type UpdateStatus struct {
22-
metav1.TypeMeta `json:",inline"`
22+
metav1.TypeMeta `json:",inline"`
23+
24+
// +optional
2325
metav1.ObjectMeta `json:"metadata,omitempty"`
2426

2527
// spec is empty for now, UpdateStatus is purely status-reporting API. In the future spec may be used to hold
2628
// configuration to drive what information is surfaced and how
27-
// +kubebuilder:validation:Required
29+
// +required
2830
Spec UpdateStatusSpec `json:"spec"`
31+
// status exposes the health and status of the ongoing cluster update
2932
// +optional
3033
Status UpdateStatusStatus `json:"status"`
3134
}
@@ -40,33 +43,48 @@ type UpdateStatusSpec struct {
4043
// UpdateStatusStatus is the API about in-progress updates. It aggregates and summarizes UpdateInsights produced by
4144
// update informers
4245
type UpdateStatusStatus struct {
46+
// conditions provide details about the controller operational matters
47+
// +listType=map
48+
// +listMapKey=type
49+
// +patchStrategy=merge
50+
// +patchMergeKey=type
51+
// +optional
52+
// +kubebuilder:validation:MaxItems=10
53+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
54+
4355
// controlPlane contains a summary and insights related to the control plane update
44-
// +kubebuilder:validation:Required
56+
// +required
4557
ControlPlane ControlPlane `json:"controlPlane"`
4658

4759
// workerPools contains summaries and insights related to the worker pools update
4860
// +listType=map
4961
// +listMapKey=name
62+
// +patchStrategy=merge
63+
// +patchMergeKey=name
5064
// +optional
51-
WorkerPools []Pool `json:"workerPools,omitempty"`
65+
// +kubebuilder:validation:MaxItems=32
66+
WorkerPools []Pool `json:"workerPools,omitempty" patchStrategy:"merge" patchMergeKey:"name"`
67+
}
5268

53-
// conditions provide details about the controller operational matters
69+
// ControlPlane contains a summary and insights related to the control plane update
70+
type ControlPlane struct {
71+
// conditions provides details about the control plane update
5472
// +listType=map
5573
// +listMapKey=type
74+
// +patchStrategy=merge
75+
// +patchMergeKey=type
5676
// +optional
57-
Conditions []metav1.Condition `json:"conditions,omitempty"`
58-
}
77+
// +kubebuilder:validation:MaxItems=10
78+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
5979

60-
// ControlPlane contains a summary and insights related to the control plane update
61-
type ControlPlane struct {
6280
// resource is the resource that represents the control plane. It will typically be a ClusterVersion resource
6381
// in standalone OpenShift and HostedCluster in Hosted Control Planes.
6482
//
6583
// Note: By OpenShift API conventions, in isolation this should probably be a specialized reference type that allows
6684
// only the "correct" resource types to be referenced (here, ClusterVersion and HostedCluster). However, because we
6785
// use resource references in many places and this API is intended to be consumed by clients, not produced, consistency
6886
// seems to be more valuable than type safety for producers.
69-
// +kubebuilder:validation:Required
87+
// +required
7088
Resource ResourceRef `json:"resource"`
7189

7290
// poolResource is the resource that represents control plane node pool, typically a MachineConfigPool. This field
@@ -82,14 +100,11 @@ type ControlPlane struct {
82100
// informers is a list of insight producers, each carries a list of insights relevant for control plane
83101
// +listType=map
84102
// +listMapKey=name
103+
// +patchStrategy=merge
104+
// +patchMergeKey=name
85105
// +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"`
106+
// +kubebuilder:validation:MaxItems=16
107+
Informers []ControlPlaneInformer `json:"informers,omitempty" patchStrategy:"merge" patchMergeKey:"name"`
93108
}
94109

95110
// ControlPlaneConditionType are types of conditions that can be reported on control plane level
@@ -107,20 +122,33 @@ type ControlPlaneUpdatingReason string
107122
const (
108123
// ClusterVersionProgressing is used for Updating=True set because we observed a ClusterVersion resource to
109124
// have Progressing=True condition
110-
ReasonClusterVersionProgressing ControlPlaneUpdatingReason = "ClusterVersionProgressing"
125+
ControlPlaneClusterVersionProgressing ControlPlaneUpdatingReason = "ClusterVersionProgressing"
111126
// ClusterVersionNotProgressing is used for Updating=False set because we observed a ClusterVersion resource to
112127
// have Progressing=False condition
113-
ReasonClusterVersionNotProgressing ControlPlaneUpdatingReason = "ClusterVersionNotProgressing"
128+
ControlPlaneClusterVersionNotProgressing ControlPlaneUpdatingReason = "ClusterVersionNotProgressing"
114129
// CannotDetermineUpdating is used with Updating=Unknown. This covers many different actual reasons such as
115130
// missing or Unknown Progressing condition on ClusterVersion, but it does not seem useful to track the individual
116131
// reasons to that granularity for Updating=Unknown
117-
ReasonClusterVersionCannotDetermine ControlPlaneUpdatingReason = "CannotDetermineUpdating"
132+
ControlPlaneCannotDetermineUpdating ControlPlaneUpdatingReason = "CannotDetermineUpdating"
118133
)
119134

120135
// Pool contains a summary and insights related to a node pool update
121136
type Pool struct {
137+
// conditions provide details about the pool
138+
// +listType=map
139+
// +listMapKey=type
140+
// +patchStrategy=merge
141+
// +patchMergeKey=type
142+
// +optional
143+
// +kubebuilder:validation:MaxItems=10
144+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
145+
122146
// name is the name of the pool
123-
// +kubebuilder:validation:Required
147+
// +required
148+
// +kubebuilder:validation:Type=string
149+
// +kubebuilder:validation:MinLength=1
150+
// +kubebuilder:validation:MaxLength=63
151+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
124152
Name string `json:"name"`
125153

126154
// resource is the resource that represents the pool
@@ -129,56 +157,103 @@ type Pool struct {
129157
// only the "correct" resource types to be referenced (here, MachineConfigPool or NodePool). However, because we use
130158
// resource references in many places and this API is intended to be consumed by clients, not produced, consistency
131159
// seems to be more valuable than type safety for producers.
132-
// +kubebuilder:validation:Required
160+
// +required
133161
Resource PoolResourceRef `json:"resource"`
134162

135163
// informers is a list of insight producers, each carries a list of insights
136164
// +listType=map
137165
// +listMapKey=name
166+
// +patchStrategy=merge
167+
// +patchMergeKey=name
138168
// +optional
139-
Informers []Informer `json:"informers,omitempty"`
169+
// +kubebuilder:validation:MaxItems=16
170+
Informers []WorkerPoolInformer `json:"informers,omitempty" patchStrategy:"merge" patchMergeKey:"name"`
171+
}
140172

141-
// conditions provide details about the pool
173+
// ControlPlaneInformer is an insight producer identified by a name, carrying a list of insights it produced
174+
type ControlPlaneInformer struct {
175+
// name is the name of the insight producer
176+
// +required
177+
// +kubebuilder:validation:Type=string
178+
// +kubebuilder:validation:MinLength=1
179+
// +kubebuilder:validation:MaxLength=63
180+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
181+
Name string `json:"name"`
182+
183+
// insights is a list of insights produced by this producer
142184
// +listType=map
143-
// +listMapKey=type
185+
// +listMapKey=uid
186+
// +patchStrategy=merge
187+
// +patchMergeKey=uid
144188
// +optional
145-
Conditions []metav1.Condition `json:"conditions,omitempty"`
189+
// +kubebuilder:validation:MaxItems=128
190+
Insights []ControlPlaneInsight `json:"insights,omitempty" patchStrategy:"merge" patchMergeKey:"uid"`
146191
}
147192

148-
// Informer is an insight producer identified by a name, carrying a list of insights it produced
149-
type Informer struct {
193+
// WorkerPoolInformer is an insight producer identified by a name, carrying a list of insights it produced
194+
type WorkerPoolInformer struct {
150195
// name is the name of the insight producer
151-
// +kubebuilder:validation:Required
196+
// +required
197+
// +kubebuilder:validation:Type=string
198+
// +kubebuilder:validation:MinLength=1
199+
// +kubebuilder:validation:MaxLength=63
200+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
152201
Name string `json:"name"`
153202

154203
// insights is a list of insights produced by this producer
155-
// +optional
156204
// +listType=map
157205
// +listMapKey=uid
158-
Insights []Insight `json:"insights,omitempty"`
206+
// +patchStrategy=merge
207+
// +patchMergeKey=uid
208+
// +optional
209+
// +kubebuilder:validation:MaxItems=1024
210+
Insights []WorkerPoolInsight `json:"insights,omitempty" patchStrategy:"merge" patchMergeKey:"uid"`
159211
}
160212

161-
// Insight is a unique piece of either status/progress or update health information produced by update informer
162-
type Insight struct {
213+
// ControlPlaneInsight is a unique piece of either status/progress or update health information produced by update informer
214+
type ControlPlaneInsight struct {
163215
// uid identifies the insight over time
164-
// +kubebuilder:validation:Required
216+
// +required
165217
// +kubebuilder:validation:Type=string
218+
// +kubebuilder:validation:MinLength=1
219+
// +kubebuilder:validation:MaxLength=63
220+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
166221
UID string `json:"uid"`
167222

168223
// acquiredAt is the time when the data was acquired by the producer
169-
// +kubebuilder:validation:Required
224+
// +required
170225
// +kubebuilder:validation:Type=string
171226
// +kubebuilder:validation:Format=date-time
172227
AcquiredAt metav1.Time `json:"acquiredAt"`
173228

174-
InsightUnion `json:",inline"`
229+
ControlPlaneInsightUnion `json:",inline"`
175230
}
176231

177-
// InsightUnion is the discriminated union of all insights types, identified by type field
178-
type InsightUnion struct {
232+
// WorkerPoolInsight is a unique piece of either status/progress or update health information produced by update informer
233+
type WorkerPoolInsight struct {
234+
// uid identifies the insight over time
235+
// +required
236+
// +kubebuilder:validation:Type=string
237+
// +kubebuilder:validation:MinLength=1
238+
// +kubebuilder:validation:MaxLength=63
239+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
240+
UID string `json:"uid"`
241+
242+
// acquiredAt is the time when the data was acquired by the producer
243+
// +required
244+
// +kubebuilder:validation:Type=string
245+
// +kubebuilder:validation:Format=date-time
246+
AcquiredAt metav1.Time `json:"acquiredAt"`
247+
248+
WorkerPoolInsightUnion `json:",inline"`
249+
}
250+
251+
// ControlPlaneInsightUnion is the discriminated union of all insights types that can be reported for the control plane,
252+
// identified by type field
253+
type ControlPlaneInsightUnion struct {
179254
// type identifies the type of the update insight
180255
// +unionDiscriminator
181-
// +kubebuilder:validation:Required
256+
// +required
182257
// +kubebuilder:validation:Enum=ClusterVersion;ClusterOperator;MachineConfigPool;Node;Health
183258
Type InsightType `json:"type"`
184259

@@ -213,9 +288,36 @@ type InsightUnion struct {
213288
HealthInsight *HealthInsight `json:"health,omitempty"`
214289
}
215290

291+
// WorkerPoolInsightUnion is the discriminated union of insights types that can be reported for a worker pool,
292+
// identified by type field
293+
type WorkerPoolInsightUnion struct {
294+
// type identifies the type of the update insight
295+
// +unionDiscriminator
296+
// +required
297+
// +kubebuilder:validation:Enum=MachineConfigPool;Node;Health
298+
Type InsightType `json:"type"`
299+
300+
// machineConfigPool is a status insight about the state of a worker pool update, where the worker pool
301+
// is represented by a MachineConfigPool resource
302+
// +optional
303+
// +unionMember
304+
MachineConfigPoolStatusInsight *MachineConfigPoolStatusInsight `json:"machineConfigPool,omitempty"`
305+
306+
// node is a status insight about the state of a worker node update, where the worker node is represented
307+
// by a Node resource
308+
// +optional
309+
// +unionMember
310+
NodeStatusInsight *NodeStatusInsight `json:"node,omitempty"`
311+
312+
// health is a generic health insight about the update. It does not represent a status of any specific
313+
// resource but surfaces actionable information about the health of the cluster or an update
314+
// +optional
315+
// +unionMember
316+
HealthInsight *HealthInsight `json:"health,omitempty"`
317+
}
318+
216319
// InsightType identifies the type of the update insight as either one of the resource-specific status insight,
217320
// or a generic health insight
218-
// +kubebuilder:validation:Enum=ClusterVersion;ClusterOperator;MachineConfigPool;Node;Health
219321
type InsightType string
220322

221323
const (
@@ -243,18 +345,29 @@ const (
243345
type ResourceRef struct {
244346
// group of the object being referenced, if any
245347
// +optional
348+
// +kubebuilder:validation:Type=string
349+
// +kubebuilder:validation:MaxLength=253
246350
Group string `json:"group,omitempty"`
247351

248352
// resource of object being referenced
249-
// +kubebuilder:validation:Required
353+
// +required
354+
// +kubebuilder:validation:Type=string
355+
// +kubebuilder:validation:MaxLength=253
356+
// +kubebuilder:validation:MinLength=1
250357
Resource string `json:"resource"`
251358

252359
// name of the object being referenced
253-
// +kubebuilder:validation:Required
360+
// +required
361+
// +kubebuilder:validation:Type=string
362+
// +kubebuilder:validation:MaxLength=253
363+
// +kubebuilder:validation:MinLength=1
254364
Name string `json:"name"`
255365

256366
// namespace of the object being referenced, if any
257367
// +optional
368+
// +kubebuilder:validation:Type=string
369+
// +kubebuilder:validation:MaxLength=253
370+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
258371
Namespace string `json:"namespace,omitempty"`
259372
}
260373

@@ -271,7 +384,11 @@ type PoolResourceRef struct {
271384
// +openshift:compatibility-gen:level=4
272385
type UpdateStatusList struct {
273386
metav1.TypeMeta `json:",inline"`
387+
// +optional
274388
metav1.ListMeta `json:"metadata"`
275389

390+
// items is a list of UpdateStatus resources
391+
// +optional
392+
// +kubebuilder:validation:MaxItems=32
276393
Items []UpdateStatus `json:"items"`
277394
}

0 commit comments

Comments
 (0)