Skip to content

Commit 0b20ee5

Browse files
Merge pull request #8819 from muraee/controlplanecomponent-observergeneartion
CNTRLPLANE-3686: feat(api,cpo): add observedGeneration to ControlPlaneComponentStatus
2 parents 74c07cf + 27d3b42 commit 0b20ee5

10 files changed

Lines changed: 92 additions & 35 deletions

File tree

api/hypershift/v1beta1/controlplanecomponent_types.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type ControlPlaneComponentStatus struct {
5454
// conditions contains details for the current state of the ControlPlane Component.
5555
// If there is an error, then the Available condition will be false.
5656
//
57-
// Current condition types are: "Available"
57+
// Current condition types are: "Available", "RolloutComplete"
5858
// +optional
5959
// +listType=map
6060
// +listMapKey=type
@@ -72,6 +72,12 @@ type ControlPlaneComponentStatus struct {
7272
// +optional
7373
// +kubebuilder:validation:MaxItems=100
7474
Resources []ComponentResource `json:"resources,omitempty"`
75+
76+
// observedGeneration reports which generation of the HostedControlPlane spec has been reconciled by this component.
77+
// +optional
78+
// +kubebuilder:validation:Minimum=1
79+
// +kubebuilder:validation:Maximum=9007199254740992
80+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
7581
}
7682

7783
// +kubebuilder:object:root=true
@@ -80,9 +86,9 @@ type ControlPlaneComponentStatus struct {
8086
// +kubebuilder:subresource:status
8187
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".status.version",description="Version"
8288
// +kubebuilder:printcolumn:name="Available",type="string",JSONPath=".status.conditions[?(@.type==\"Available\")].status",description="Available"
83-
// +kubebuilder:printcolumn:name="Progressing",type="string",JSONPath=".status.conditions[?(@.type==\"Progressing\")].status",description="Progressing"
89+
// +kubebuilder:printcolumn:name="RolloutComplete",type="string",JSONPath=".status.conditions[?(@.type==\"RolloutComplete\")].status",description="RolloutComplete"
8490
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type==\"Available\")].message",description="Message"
85-
// +kubebuilder:printcolumn:name="ProgressingMessage",type="string",priority=1,JSONPath=".status.conditions[?(@.type==\"Progressing\")].message",description="ProgressingMessage"
91+
// +kubebuilder:printcolumn:name="RolloutCompleteMessage",type="string",priority=1,JSONPath=".status.conditions[?(@.type==\"RolloutComplete\")].message",description="RolloutCompleteMessage"
8692
// ControlPlaneComponent specifies the state of a ControlPlane Component
8793
type ControlPlaneComponent struct {
8894
metav1.TypeMeta `json:",inline"`

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/controlplanecomponents.hypershift.openshift.io/AAA_ungated.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ spec:
2525
jsonPath: .status.conditions[?(@.type=="Available")].status
2626
name: Available
2727
type: string
28-
- description: Progressing
29-
jsonPath: .status.conditions[?(@.type=="Progressing")].status
30-
name: Progressing
28+
- description: RolloutComplete
29+
jsonPath: .status.conditions[?(@.type=="RolloutComplete")].status
30+
name: RolloutComplete
3131
type: string
3232
- description: Message
3333
jsonPath: .status.conditions[?(@.type=="Available")].message
3434
name: Message
3535
type: string
36-
- description: ProgressingMessage
37-
jsonPath: .status.conditions[?(@.type=="Progressing")].message
38-
name: ProgressingMessage
36+
- description: RolloutCompleteMessage
37+
jsonPath: .status.conditions[?(@.type=="RolloutComplete")].message
38+
name: RolloutCompleteMessage
3939
priority: 1
4040
type: string
4141
name: v1beta1
@@ -71,7 +71,7 @@ spec:
7171
conditions contains details for the current state of the ControlPlane Component.
7272
If there is an error, then the Available condition will be false.
7373
74-
Current condition types are: "Available"
74+
Current condition types are: "Available", "RolloutComplete"
7575
items:
7676
description: Condition contains details for one aspect of the current
7777
state of this API Resource.
@@ -131,6 +131,13 @@ spec:
131131
x-kubernetes-list-map-keys:
132132
- type
133133
x-kubernetes-list-type: map
134+
observedGeneration:
135+
description: observedGeneration reports which generation of the HostedControlPlane
136+
spec has been reconciled by this component.
137+
format: int64
138+
maximum: 9007199254740992
139+
minimum: 1
140+
type: integer
134141
resources:
135142
description: resources is a list of the resources reconciled by this
136143
component.

cmd/install/assets/crds/hypershift-operator/zz_generated.crd-manifests/controlplanecomponents.crd.yaml

Lines changed: 14 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/content/reference/aggregated-docs.md

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/content/reference/api.md

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

support/controlplane-component/status.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ func (c *controlPlaneWorkload[T]) reconcileComponentStatus(cpContext ControlPlan
134134
component.Status.Version = cpContext.ReleaseImageProvider.Version()
135135
}
136136

137+
component.Status.ObservedGeneration = cpContext.HCP.Generation
138+
137139
return nil
138140
}
139141

support/controlplane-component/status_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,13 @@ func TestReconcileComponentStatus(t *testing.T) {
194194
WithObjects(tc.deployment).
195195
Build()
196196

197+
var hcpGeneration int64 = 5
197198
cpContext := ControlPlaneContext{
198199
Client: client,
199200
HCP: &hyperv1.HostedControlPlane{
200201
ObjectMeta: metav1.ObjectMeta{
201-
Namespace: namespace,
202+
Namespace: namespace,
203+
Generation: hcpGeneration,
202204
},
203205
},
204206
ReleaseImageProvider: testutil.FakeImageProvider(),
@@ -235,6 +237,9 @@ func TestReconcileComponentStatus(t *testing.T) {
235237

236238
// Check version
237239
g.Expect(componentStatus.Status.Version).To(Equal(tc.expectedVersion))
240+
241+
// Check observedGeneration is always set to the HCP generation
242+
g.Expect(componentStatus.Status.ObservedGeneration).To(Equal(hcpGeneration))
238243
})
239244
}
240245
}

vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/controlplanecomponent_types.go

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/openshift/hypershift/api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)