Skip to content

Commit 0ee8d35

Browse files
committed
CAPI v1beta2 conditions and deprecations for OSC
Add CAPI v1beta2 conditions for the OpenStackCluster and deprecate error and failure messages as well as the Ready condition. This also adds the status.initialization.provisioned field. Signed-off-by: Lennart Jern <[email protected]>
1 parent 33d80a2 commit 0ee8d35

File tree

11 files changed

+362
-5
lines changed

11 files changed

+362
-5
lines changed

.golangci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@ linters:
186186
- linters:
187187
- staticcheck
188188
text: 'SA1019: "sigs.k8s.io/cluster-api/util/deprecated/v1beta1/conditions" is deprecated: This package is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.'
189+
- linters:
190+
- staticcheck
191+
text: 'SA1019: .*.Status.Ready is deprecated: This field is deprecated and will be removed in a future API version. Use status.conditions to determine the ready state of the cluster.'
192+
- linters:
193+
- staticcheck
194+
text: 'SA1019: .*.Status.FailureReason is deprecated: This field is deprecated and will be removed in a future API version. Use status.conditions to report failures.'
195+
- linters:
196+
- staticcheck
197+
text: 'SA1019: .*.Status.FailureMessage is deprecated: This field is deprecated and will be removed in a future API version. Use status.conditions to report failures.'
189198
paths:
190199
- zz_generated.*\.go$
191200
- third_party$

api/v1beta1/openstackcluster_types.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,27 @@ type OpenStackClusterSpec struct {
196196
IdentityRef OpenStackIdentityReference `json:"identityRef"`
197197
}
198198

199+
// ClusterInitialization represents the initialization status of the cluster.
200+
type ClusterInitialization struct {
201+
// Provisioned is set to true when the initial provisioning of the cluster infrastructure is completed.
202+
// The value of this field is never updated after provisioning is completed.
203+
// +optional
204+
Provisioned bool `json:"provisioned,omitempty"`
205+
}
206+
199207
// OpenStackClusterStatus defines the observed state of OpenStackCluster.
200208
type OpenStackClusterStatus struct {
201209
// Ready is true when the cluster infrastructure is ready.
210+
//
211+
// Deprecated: This field is deprecated and will be removed in a future API version.
212+
// Use status.conditions to determine the ready state of the cluster.
202213
// +kubebuilder:default=false
203214
Ready bool `json:"ready"`
204215

216+
// Initialization contains information about the initialization status of the cluster.
217+
// +optional
218+
Initialization *ClusterInitialization `json:"initialization,omitempty"`
219+
205220
// Network contains information about the created OpenStack Network.
206221
// +optional
207222
Network *NetworkStatusWithSubnets `json:"network,omitempty"`
@@ -257,6 +272,9 @@ type OpenStackClusterStatus struct {
257272
// Any transient errors that occur during the reconciliation of
258273
// OpenStackClusters can be added as events to the OpenStackCluster object
259274
// and/or logged in the controller's output.
275+
//
276+
// Deprecated: This field is deprecated and will be removed in a future API version.
277+
// Use status.conditions to report failures.
260278
// +optional
261279
FailureReason *capoerrors.DeprecatedCAPIClusterStatusError `json:"failureReason,omitempty"`
262280

@@ -276,8 +294,18 @@ type OpenStackClusterStatus struct {
276294
// Any transient errors that occur during the reconciliation of
277295
// OpenStackClusters can be added as events to the OpenStackCluster object
278296
// and/or logged in the controller's output.
297+
//
298+
// Deprecated: This field is deprecated and will be removed in a future API version.
299+
// Use status.conditions to report failures.
279300
// +optional
280301
FailureMessage *string `json:"failureMessage,omitempty"`
302+
303+
// Conditions defines current service state of the OpenStackCluster.
304+
// This field surfaces into Cluster's status.conditions[InfrastructureReady] condition.
305+
// The Ready condition must surface issues during the entire lifecycle of the OpenStackCluster
306+
// (both during initial provisioning and after the initial provisioning is completed).
307+
// +optional
308+
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
281309
}
282310

283311
// +genclient
@@ -344,6 +372,16 @@ type ManagedSecurityGroups struct {
344372

345373
var _ IdentityRefProvider = &OpenStackCluster{}
346374

375+
// GetConditions returns the observations of the operational state of the OpenStackCluster resource.
376+
func (c *OpenStackCluster) GetConditions() clusterv1beta1.Conditions {
377+
return c.Status.Conditions
378+
}
379+
380+
// SetConditions sets the underlying service state of the OpenStackCluster to the predescribed clusterv1.Conditions.
381+
func (c *OpenStackCluster) SetConditions(conditions clusterv1beta1.Conditions) {
382+
c.Status.Conditions = conditions
383+
}
384+
347385
// GetIdentifyRef returns the cluster's namespace and IdentityRef.
348386
func (c *OpenStackCluster) GetIdentityRef() (*string, *OpenStackIdentityReference) {
349387
return &c.Namespace, &c.Spec.IdentityRef

api/v1beta1/zz_generated.deepcopy.go

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

cmd/models-schema/zz_generated.openapi.go

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

0 commit comments

Comments
 (0)