From f447599e5d8616291faae11426fdd1b56aa4cf32 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Mon, 7 Apr 2025 08:29:38 +0200 Subject: [PATCH 01/11] Promote v1beta2 conditions, deprecate failureReason and Message, promote new replica counters --- .../v1beta2/clusterresourceset_types.go | 58 ++- api/addons/v1beta2/zz_generated.deepcopy.go | 38 +- api/v1beta2/cluster_types.go | 108 +++-- api/v1beta2/clusterclass_types.go | 62 +-- api/v1beta2/machine_types.go | 153 ++++--- api/v1beta2/machinedeployment_types.go | 117 +++-- api/v1beta2/machinehealthcheck_types.go | 58 ++- api/v1beta2/machineset_types.go | 114 +++-- api/v1beta2/zz_generated.deepcopy.go | 400 ++++++++++++------ .../api/v1beta2/kubeadmconfig_types.go | 86 ++-- .../api/v1beta2/zz_generated.deepcopy.go | 48 ++- .../v1beta2/kubeadm_control_plane_types.go | 152 ++++--- .../api/v1beta2/zz_generated.deepcopy.go | 84 ++-- exp/api/v1beta2/machinepool_types.go | 134 +++--- exp/api/v1beta2/zz_generated.deepcopy.go | 88 ++-- exp/ipam/api/v1beta2/ipaddressclaim_types.go | 56 ++- exp/ipam/api/v1beta2/zz_generated.deepcopy.go | 40 +- 17 files changed, 1097 insertions(+), 699 deletions(-) diff --git a/api/addons/v1beta2/clusterresourceset_types.go b/api/addons/v1beta2/clusterresourceset_types.go index 5a289b5ffb50..a337958cbd52 100644 --- a/api/addons/v1beta2/clusterresourceset_types.go +++ b/api/addons/v1beta2/clusterresourceset_types.go @@ -119,57 +119,71 @@ func (c *ClusterResourceSetSpec) SetTypedStrategy(p ClusterResourceSetStrategy) // ClusterResourceSetStatus defines the observed state of ClusterResourceSet. type ClusterResourceSetStatus struct { + // conditions represents the observations of a ClusterResourceSet's current state. + // Known condition types are ResourceSetApplied, Deleting. + // +optional + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=32 + Conditions []metav1.Condition `json:"conditions,omitempty"` + // observedGeneration reflects the generation of the most recently observed ClusterResourceSet. // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty"` - // conditions defines current state of the ClusterResourceSet. + // deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed. // +optional - Conditions clusterv1.Conditions `json:"conditions,omitempty"` + Deprecated *ClusterResourceSetDeprecatedStatus `json:"deprecated,omitempty"` +} - // v1beta2 groups all the fields that will be added or modified in ClusterResourceSet's status with the V1Beta2 version. +// ClusterResourceSetDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type ClusterResourceSetDeprecatedStatus struct { + // v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. // +optional - V1Beta2 *ClusterResourceSetV1Beta2Status `json:"v1beta2,omitempty"` + V1Beta1 *ClusterResourceSetV1Beta1DeprecatedStatus `json:"v1beta1,omitempty"` } -// ClusterResourceSetV1Beta2Status groups all the fields that will be added or modified in ClusterResourceSet with the V1Beta2 version. +// ClusterResourceSetV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. // See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. -type ClusterResourceSetV1Beta2Status struct { - // conditions represents the observations of a ClusterResourceSet's current state. - // Known condition types are ResourceSetApplied, Deleting. +type ClusterResourceSetV1Beta1DeprecatedStatus struct { + // conditions defines current state of the ClusterResourceSet. + // + // Deprecated: This field 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. + // // +optional - // +listType=map - // +listMapKey=type - // +kubebuilder:validation:MaxItems=32 - Conditions []metav1.Condition `json:"conditions,omitempty"` + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } // ANCHOR_END: ClusterResourceSetStatus // GetConditions returns the set of conditions for this object. func (m *ClusterResourceSet) GetConditions() clusterv1.Conditions { - return m.Status.Conditions + if m.Status.Deprecated == nil || m.Status.Deprecated.V1Beta1 == nil { + return nil + } + return m.Status.Deprecated.V1Beta1.Conditions } // SetConditions sets the conditions on this object. func (m *ClusterResourceSet) SetConditions(conditions clusterv1.Conditions) { - m.Status.Conditions = conditions + if m.Status.Deprecated == nil { + m.Status.Deprecated = &ClusterResourceSetDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &ClusterResourceSetV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.Conditions = conditions } // GetV1Beta2Conditions returns the set of conditions for this object. func (m *ClusterResourceSet) GetV1Beta2Conditions() []metav1.Condition { - if m.Status.V1Beta2 == nil { - return nil - } - return m.Status.V1Beta2.Conditions + return m.Status.Conditions } // SetV1Beta2Conditions sets conditions for an API object. func (m *ClusterResourceSet) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil { - m.Status.V1Beta2 = &ClusterResourceSetV1Beta2Status{} - } - m.Status.V1Beta2.Conditions = conditions + m.Status.Conditions = conditions } // +kubebuilder:object:root=true diff --git a/api/addons/v1beta2/zz_generated.deepcopy.go b/api/addons/v1beta2/zz_generated.deepcopy.go index 5728f9a3309e..b54338b174a3 100644 --- a/api/addons/v1beta2/zz_generated.deepcopy.go +++ b/api/addons/v1beta2/zz_generated.deepcopy.go @@ -137,6 +137,26 @@ func (in *ClusterResourceSetBindingSpec) DeepCopy() *ClusterResourceSetBindingSp return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterResourceSetDeprecatedStatus) DeepCopyInto(out *ClusterResourceSetDeprecatedStatus) { + *out = *in + if in.V1Beta1 != nil { + in, out := &in.V1Beta1, &out.V1Beta1 + *out = new(ClusterResourceSetV1Beta1DeprecatedStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterResourceSetDeprecatedStatus. +func (in *ClusterResourceSetDeprecatedStatus) DeepCopy() *ClusterResourceSetDeprecatedStatus { + if in == nil { + return nil + } + out := new(ClusterResourceSetDeprecatedStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterResourceSetList) DeepCopyInto(out *ClusterResourceSetList) { *out = *in @@ -195,14 +215,14 @@ func (in *ClusterResourceSetStatus) DeepCopyInto(out *ClusterResourceSetStatus) *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make(apiv1beta2.Conditions, len(*in)) + *out = make([]v1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.V1Beta2 != nil { - in, out := &in.V1Beta2, &out.V1Beta2 - *out = new(ClusterResourceSetV1Beta2Status) + if in.Deprecated != nil { + in, out := &in.Deprecated, &out.Deprecated + *out = new(ClusterResourceSetDeprecatedStatus) (*in).DeepCopyInto(*out) } } @@ -218,23 +238,23 @@ func (in *ClusterResourceSetStatus) DeepCopy() *ClusterResourceSetStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterResourceSetV1Beta2Status) DeepCopyInto(out *ClusterResourceSetV1Beta2Status) { +func (in *ClusterResourceSetV1Beta1DeprecatedStatus) DeepCopyInto(out *ClusterResourceSetV1Beta1DeprecatedStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make(apiv1beta2.Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterResourceSetV1Beta2Status. -func (in *ClusterResourceSetV1Beta2Status) DeepCopy() *ClusterResourceSetV1Beta2Status { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterResourceSetV1Beta1DeprecatedStatus. +func (in *ClusterResourceSetV1Beta1DeprecatedStatus) DeepCopy() *ClusterResourceSetV1Beta1DeprecatedStatus { if in == nil { return nil } - out := new(ClusterResourceSetV1Beta2Status) + out := new(ClusterResourceSetV1Beta1DeprecatedStatus) in.DeepCopyInto(out) return out } diff --git a/api/v1beta2/cluster_types.go b/api/v1beta2/cluster_types.go index d90919f6dc87..bf2fe8488b61 100644 --- a/api/v1beta2/cluster_types.go +++ b/api/v1beta2/cluster_types.go @@ -956,28 +956,27 @@ func (n NetworkRanges) String() string { // ClusterStatus defines the observed state of Cluster. type ClusterStatus struct { - // failureDomains is a slice of failure domain objects synced from the infrastructure provider. + // conditions represents the observations of a Cluster's current state. + // Known condition types are Available, InfrastructureReady, ControlPlaneInitialized, ControlPlaneAvailable, WorkersAvailable, MachinesReady + // MachinesUpToDate, RemoteConnectionProbe, ScalingUp, ScalingDown, Remediating, Deleting, Paused. + // Additionally, a TopologyReconciled condition will be added in case the Cluster is referencing a ClusterClass / defining a managed Topology. // +optional - FailureDomains FailureDomains `json:"failureDomains,omitempty"` + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=32 + Conditions []metav1.Condition `json:"conditions,omitempty"` - // failureReason indicates that there is a fatal problem reconciling the - // state, and will be set to a token value suitable for - // programmatic interpretation. - // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - // + // controlPlane groups all the observations about Cluster's ControlPlane current state. // +optional - FailureReason *capierrors.ClusterStatusError `json:"failureReason,omitempty"` + ControlPlane *ClusterControlPlaneStatus `json:"controlPlane,omitempty"` - // failureMessage indicates that there is a fatal problem reconciling the - // state, and will be set to a descriptive error message. - // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - // + // workers groups all the observations about Cluster's Workers current state. // +optional - // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:MaxLength=10240 - FailureMessage *string `json:"failureMessage,omitempty"` + Workers *WorkersStatus `json:"workers,omitempty"` + + // failureDomains is a slice of failure domain objects synced from the infrastructure provider. + // +optional + FailureDomains FailureDomains `json:"failureDomains,omitempty"` // phase represents the current phase of cluster actuation. // +optional @@ -996,39 +995,51 @@ type ClusterStatus struct { // +optional ControlPlaneReady bool `json:"controlPlaneReady"` - // conditions defines current service state of the cluster. - // +optional - Conditions Conditions `json:"conditions,omitempty"` - // observedGeneration is the latest generation observed by the controller. // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty"` - // v1beta2 groups all the fields that will be added or modified in Cluster's status with the V1Beta2 version. + // deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed. // +optional - V1Beta2 *ClusterV1Beta2Status `json:"v1beta2,omitempty"` + Deprecated *ClusterDeprecatedStatus `json:"deprecated,omitempty"` } -// ClusterV1Beta2Status groups all the fields that will be added or modified in Cluster with the V1Beta2 version. +// ClusterDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. // See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. -type ClusterV1Beta2Status struct { - // conditions represents the observations of a Cluster's current state. - // Known condition types are Available, InfrastructureReady, ControlPlaneInitialized, ControlPlaneAvailable, WorkersAvailable, MachinesReady - // MachinesUpToDate, RemoteConnectionProbe, ScalingUp, ScalingDown, Remediating, Deleting, Paused. - // Additionally, a TopologyReconciled condition will be added in case the Cluster is referencing a ClusterClass / defining a managed Topology. +type ClusterDeprecatedStatus struct { + // v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. // +optional - // +listType=map - // +listMapKey=type - // +kubebuilder:validation:MaxItems=32 - Conditions []metav1.Condition `json:"conditions,omitempty"` + V1Beta1 *ClusterV1Beta1DeprecatedStatus `json:"v1beta1,omitempty"` +} - // controlPlane groups all the observations about Cluster's ControlPlane current state. +// ClusterV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type ClusterV1Beta1DeprecatedStatus struct { + // conditions defines current service state of the cluster. + // + // Deprecated: This field 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. + // // +optional - ControlPlane *ClusterControlPlaneStatus `json:"controlPlane,omitempty"` + Conditions Conditions `json:"conditions,omitempty"` - // workers groups all the observations about Cluster's Workers current state. + // failureReason indicates that there is a fatal problem reconciling the + // state, and will be set to a token value suitable for + // programmatic interpretation. + // + // Deprecated: This field 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. + // // +optional - Workers *WorkersStatus `json:"workers,omitempty"` + FailureReason *capierrors.ClusterStatusError `json:"failureReason,omitempty"` + + // failureMessage indicates that there is a fatal problem reconciling the + // state, and will be set to a descriptive error message. + // + // Deprecated: This field 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. + // + // +optional + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=10240 + FailureMessage *string `json:"failureMessage,omitempty"` } // ClusterControlPlaneStatus groups all the observations about control plane current state. @@ -1171,28 +1182,31 @@ func (c *Cluster) GetClassKey() types.NamespacedName { // GetConditions returns the set of conditions for this object. func (c *Cluster) GetConditions() Conditions { - return c.Status.Conditions + if c.Status.Deprecated == nil || c.Status.Deprecated.V1Beta1 == nil { + return nil + } + return c.Status.Deprecated.V1Beta1.Conditions } // SetConditions sets the conditions on this object. func (c *Cluster) SetConditions(conditions Conditions) { - c.Status.Conditions = conditions + if c.Status.Deprecated == nil { + c.Status.Deprecated = &ClusterDeprecatedStatus{} + } + if c.Status.Deprecated.V1Beta1 == nil { + c.Status.Deprecated.V1Beta1 = &ClusterV1Beta1DeprecatedStatus{} + } + c.Status.Deprecated.V1Beta1.Conditions = conditions } // GetV1Beta2Conditions returns the set of conditions for this object. func (c *Cluster) GetV1Beta2Conditions() []metav1.Condition { - if c.Status.V1Beta2 == nil { - return nil - } - return c.Status.V1Beta2.Conditions + return c.Status.Conditions } // SetV1Beta2Conditions sets conditions for an API object. func (c *Cluster) SetV1Beta2Conditions(conditions []metav1.Condition) { - if c.Status.V1Beta2 == nil { - c.Status.V1Beta2 = &ClusterV1Beta2Status{} - } - c.Status.V1Beta2.Conditions = conditions + c.Status.Conditions = conditions } // GetIPFamily returns a ClusterIPFamily from the configuration provided. diff --git a/api/v1beta2/clusterclass_types.go b/api/v1beta2/clusterclass_types.go index 846f345ac0e9..ec3321f57796 100644 --- a/api/v1beta2/clusterclass_types.go +++ b/api/v1beta2/clusterclass_types.go @@ -1140,34 +1140,45 @@ type LocalObjectTemplate struct { // ClusterClassStatus defines the observed state of the ClusterClass. type ClusterClassStatus struct { + // conditions represents the observations of a ClusterClass's current state. + // Known condition types are VariablesReady, RefVersionsUpToDate, Paused. + // +optional + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=32 + Conditions []metav1.Condition `json:"conditions,omitempty"` + // variables is a list of ClusterClassStatusVariable that are defined for the ClusterClass. // +optional // +kubebuilder:validation:MaxItems=1000 Variables []ClusterClassStatusVariable `json:"variables,omitempty"` - // conditions defines current observed state of the ClusterClass. - // +optional - Conditions Conditions `json:"conditions,omitempty"` - // observedGeneration is the latest generation observed by the controller. // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty"` - // v1beta2 groups all the fields that will be added or modified in ClusterClass's status with the V1Beta2 version. + // deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed. // +optional - V1Beta2 *ClusterClassV1Beta2Status `json:"v1beta2,omitempty"` + Deprecated *ClusterClassDeprecatedStatus `json:"deprecated,omitempty"` } -// ClusterClassV1Beta2Status groups all the fields that will be added or modified in ClusterClass with the V1Beta2 version. +// ClusterClassDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. // See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. -type ClusterClassV1Beta2Status struct { - // conditions represents the observations of a ClusterClass's current state. - // Known condition types are VariablesReady, RefVersionsUpToDate, Paused. +type ClusterClassDeprecatedStatus struct { + // v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. // +optional - // +listType=map - // +listMapKey=type - // +kubebuilder:validation:MaxItems=32 - Conditions []metav1.Condition `json:"conditions,omitempty"` + V1Beta1 *ClusterClassV1Beta1DeprecatedStatus `json:"v1beta1,omitempty"` +} + +// ClusterClassV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type ClusterClassV1Beta1DeprecatedStatus struct { + // conditions defines current observed state of the ClusterClass. + // + // Deprecated: This field 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. + // + // +optional + Conditions Conditions `json:"conditions,omitempty"` } // ClusterClassStatusVariable defines a variable which appears in the status of a ClusterClass. @@ -1221,28 +1232,31 @@ type ClusterClassStatusVariableDefinition struct { // GetConditions returns the set of conditions for this object. func (c *ClusterClass) GetConditions() Conditions { - return c.Status.Conditions + if c.Status.Deprecated == nil || c.Status.Deprecated.V1Beta1 == nil { + return nil + } + return c.Status.Deprecated.V1Beta1.Conditions } // SetConditions sets the conditions on this object. func (c *ClusterClass) SetConditions(conditions Conditions) { - c.Status.Conditions = conditions + if c.Status.Deprecated == nil { + c.Status.Deprecated = &ClusterClassDeprecatedStatus{} + } + if c.Status.Deprecated.V1Beta1 == nil { + c.Status.Deprecated.V1Beta1 = &ClusterClassV1Beta1DeprecatedStatus{} + } + c.Status.Deprecated.V1Beta1.Conditions = conditions } // GetV1Beta2Conditions returns the set of conditions for this object. func (c *ClusterClass) GetV1Beta2Conditions() []metav1.Condition { - if c.Status.V1Beta2 == nil { - return nil - } - return c.Status.V1Beta2.Conditions + return c.Status.Conditions } // SetV1Beta2Conditions sets conditions for an API object. func (c *ClusterClass) SetV1Beta2Conditions(conditions []metav1.Condition) { - if c.Status.V1Beta2 == nil { - c.Status.V1Beta2 = &ClusterClassV1Beta2Status{} - } - c.Status.V1Beta2.Conditions = conditions + c.Status.Conditions = conditions } // ANCHOR_END: ClusterClassStatus diff --git a/api/v1beta2/machine_types.go b/api/v1beta2/machine_types.go index 99213962abcb..497440bb57c7 100644 --- a/api/v1beta2/machine_types.go +++ b/api/v1beta2/machine_types.go @@ -497,6 +497,18 @@ type MachineReadinessGate struct { // MachineStatus defines the observed state of Machine. type MachineStatus struct { + // conditions represents the observations of a Machine's current state. + // Known condition types are Available, Ready, UpToDate, BootstrapConfigReady, InfrastructureReady, NodeReady, + // NodeHealthy, Deleting, Paused. + // If a MachineHealthCheck is targeting this machine, also HealthCheckSucceeded, OwnerRemediated conditions are added. + // Additionally control plane Machines controlled by KubeadmControlPlane will have following additional conditions: + // APIServerPodHealthy, ControllerManagerPodHealthy, SchedulerPodHealthy, EtcdPodHealthy, EtcdMemberHealthy. + // +optional + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=32 + Conditions []metav1.Condition `json:"conditions,omitempty"` + // nodeRef will point to the corresponding Node if it exists. // +optional NodeRef *corev1.ObjectReference `json:"nodeRef,omitempty"` @@ -510,6 +522,64 @@ type MachineStatus struct { // +optional LastUpdated *metav1.Time `json:"lastUpdated,omitempty"` + // addresses is a list of addresses assigned to the machine. + // This field is copied from the infrastructure provider reference. + // +optional + Addresses MachineAddresses `json:"addresses,omitempty"` + + // phase represents the current phase of machine actuation. + // +optional + // +kubebuilder:validation:Enum=Pending;Provisioning;Provisioned;Running;Deleting;Deleted;Failed;Unknown + Phase string `json:"phase,omitempty"` + + // certificatesExpiryDate is the expiry date of the machine certificates. + // This value is only set for control plane machines. + // +optional + CertificatesExpiryDate *metav1.Time `json:"certificatesExpiryDate,omitempty"` + + // bootstrapReady is the state of the bootstrap provider. + // +optional + BootstrapReady bool `json:"bootstrapReady"` + + // infrastructureReady is the state of the infrastructure provider. + // +optional + InfrastructureReady bool `json:"infrastructureReady"` + + // observedGeneration is the latest generation observed by the controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // deletion contains information relating to removal of the Machine. + // Only present when the Machine has a deletionTimestamp and drain or wait for volume detach started. + // +optional + Deletion *MachineDeletionStatus `json:"deletion,omitempty"` + + // deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed. + // +optional + Deprecated *MachineDeprecatedStatus `json:"deprecated,omitempty"` +} + +// MachineDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type MachineDeprecatedStatus struct { + // v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. + // + // Deprecated: This field 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. + // + // +optional + V1Beta1 *MachineV1Beta1DeprecatedStatus `json:"v1beta1,omitempty"` +} + +// MachineV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type MachineV1Beta1DeprecatedStatus struct { + // conditions defines current service state of the Machine. + // + // Deprecated: This field 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. + // + // +optional + Conditions Conditions `json:"conditions,omitempty"` + // failureReason will be set in the event that there is a terminal problem // reconciling the Machine and will contain a succinct value suitable // for machine interpretation. @@ -527,7 +597,7 @@ type MachineStatus struct { // can be added as events to the Machine object and/or logged in the // controller's output. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional FailureReason *capierrors.MachineStatusError `json:"failureReason,omitempty"` @@ -549,68 +619,12 @@ type MachineStatus struct { // can be added as events to the Machine object and/or logged in the // controller's output. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=10240 FailureMessage *string `json:"failureMessage,omitempty"` - - // addresses is a list of addresses assigned to the machine. - // This field is copied from the infrastructure provider reference. - // +optional - Addresses MachineAddresses `json:"addresses,omitempty"` - - // phase represents the current phase of machine actuation. - // +optional - // +kubebuilder:validation:Enum=Pending;Provisioning;Provisioned;Running;Deleting;Deleted;Failed;Unknown - Phase string `json:"phase,omitempty"` - - // certificatesExpiryDate is the expiry date of the machine certificates. - // This value is only set for control plane machines. - // +optional - CertificatesExpiryDate *metav1.Time `json:"certificatesExpiryDate,omitempty"` - - // bootstrapReady is the state of the bootstrap provider. - // +optional - BootstrapReady bool `json:"bootstrapReady"` - - // infrastructureReady is the state of the infrastructure provider. - // +optional - InfrastructureReady bool `json:"infrastructureReady"` - - // observedGeneration is the latest generation observed by the controller. - // +optional - ObservedGeneration int64 `json:"observedGeneration,omitempty"` - - // conditions defines current service state of the Machine. - // +optional - Conditions Conditions `json:"conditions,omitempty"` - - // deletion contains information relating to removal of the Machine. - // Only present when the Machine has a deletionTimestamp and drain or wait for volume detach started. - // +optional - Deletion *MachineDeletionStatus `json:"deletion,omitempty"` - - // v1beta2 groups all the fields that will be added or modified in Machine's status with the V1Beta2 version. - // +optional - V1Beta2 *MachineV1Beta2Status `json:"v1beta2,omitempty"` -} - -// MachineV1Beta2Status groups all the fields that will be added or modified in MachineStatus with the V1Beta2 version. -// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. -type MachineV1Beta2Status struct { - // conditions represents the observations of a Machine's current state. - // Known condition types are Available, Ready, UpToDate, BootstrapConfigReady, InfrastructureReady, NodeReady, - // NodeHealthy, Deleting, Paused. - // If a MachineHealthCheck is targeting this machine, also HealthCheckSucceeded, OwnerRemediated conditions are added. - // Additionally control plane Machines controlled by KubeadmControlPlane will have following additional conditions: - // APIServerPodHealthy, ControllerManagerPodHealthy, SchedulerPodHealthy, EtcdPodHealthy, EtcdMemberHealthy. - // +optional - // +listType=map - // +listMapKey=type - // +kubebuilder:validation:MaxItems=32 - Conditions []metav1.Condition `json:"conditions,omitempty"` } // ANCHOR_END: MachineStatus @@ -705,28 +719,31 @@ type Machine struct { // GetConditions returns the set of conditions for this object. func (m *Machine) GetConditions() Conditions { - return m.Status.Conditions + if m.Status.Deprecated == nil || m.Status.Deprecated.V1Beta1 == nil { + return nil + } + return m.Status.Deprecated.V1Beta1.Conditions } // SetConditions sets the conditions on this object. func (m *Machine) SetConditions(conditions Conditions) { - m.Status.Conditions = conditions + if m.Status.Deprecated == nil { + m.Status.Deprecated = &MachineDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &MachineV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.Conditions = conditions } // GetV1Beta2Conditions returns the set of conditions for this object. func (m *Machine) GetV1Beta2Conditions() []metav1.Condition { - if m.Status.V1Beta2 == nil { - return nil - } - return m.Status.V1Beta2.Conditions + return m.Status.Conditions } // SetV1Beta2Conditions sets conditions for an API object. func (m *Machine) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil { - m.Status.V1Beta2 = &MachineV1Beta2Status{} - } - m.Status.V1Beta2.Conditions = conditions + m.Status.Conditions = conditions } // +kubebuilder:object:root=true diff --git a/api/v1beta2/machinedeployment_types.go b/api/v1beta2/machinedeployment_types.go index 404cc800ec1e..89197ed5adec 100644 --- a/api/v1beta2/machinedeployment_types.go +++ b/api/v1beta2/machinedeployment_types.go @@ -451,6 +451,14 @@ type MachineNamingStrategy struct { // MachineDeploymentStatus defines the observed state of MachineDeployment. type MachineDeploymentStatus struct { + // conditions represents the observations of a MachineDeployment's current state. + // Known condition types are Available, MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused. + // +optional + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=32 + Conditions []metav1.Condition `json:"conditions,omitempty"` + // observedGeneration is the generation observed by the deployment controller. // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty"` @@ -468,67 +476,79 @@ type MachineDeploymentStatus struct { // +optional Replicas int32 `json:"replicas"` - // updatedReplicas is the total number of non-terminated machines targeted by this deployment - // that have the desired template spec. - // +optional - UpdatedReplicas int32 `json:"updatedReplicas"` - - // readyReplicas is the total number of ready machines targeted by this deployment. + // readyReplicas is the number of ready replicas for this MachineDeployment. A machine is considered ready when Machine's Ready condition is true. // +optional - ReadyReplicas int32 `json:"readyReplicas"` + ReadyReplicas *int32 `json:"readyReplicas,omitempty"` - // availableReplicas is the total number of available machines (ready for at least minReadySeconds) - // targeted by this deployment. + // availableReplicas is the number of available replicas for this MachineDeployment. A machine is considered available when Machine's Available condition is true. // +optional - AvailableReplicas int32 `json:"availableReplicas"` + AvailableReplicas *int32 `json:"availableReplicas,omitempty"` - // unavailableReplicas is the total number of unavailable machines targeted by this deployment. - // This is the total number of machines that are still required for - // the deployment to have 100% available capacity. They may either - // be machines that are running but not yet available or machines - // that still have not been created. - // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - // + // upToDateReplicas is the number of up-to-date replicas targeted by this deployment. A machine is considered up-to-date when Machine's UpToDate condition is true. // +optional - UnavailableReplicas int32 `json:"unavailableReplicas"` + UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"` // phase represents the current phase of a MachineDeployment (ScalingUp, ScalingDown, Running, Failed, or Unknown). // +optional // +kubebuilder:validation:Enum=ScalingUp;ScalingDown;Running;Failed;Unknown Phase string `json:"phase,omitempty"` - // conditions defines current service state of the MachineDeployment. + // deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed. // +optional - Conditions Conditions `json:"conditions,omitempty"` + Deprecated *MachineDeploymentDeprecatedStatus `json:"deprecated,omitempty"` +} - // v1beta2 groups all the fields that will be added or modified in MachineDeployment's status with the V1Beta2 version. +// MachineDeploymentDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type MachineDeploymentDeprecatedStatus struct { + // v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. // +optional - V1Beta2 *MachineDeploymentV1Beta2Status `json:"v1beta2,omitempty"` + V1Beta1 *MachineDeploymentV1Beta1DeprecatedStatus `json:"v1beta1,omitempty"` } -// MachineDeploymentV1Beta2Status groups all the fields that will be added or modified in MachineDeployment with the V1Beta2 version. +// MachineDeploymentV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. // See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. -type MachineDeploymentV1Beta2Status struct { - // conditions represents the observations of a MachineDeployment's current state. - // Known condition types are Available, MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused. +type MachineDeploymentV1Beta1DeprecatedStatus struct { + // conditions defines current service state of the MachineDeployment. + // + // Deprecated: This field 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. + // // +optional - // +listType=map - // +listMapKey=type - // +kubebuilder:validation:MaxItems=32 - Conditions []metav1.Condition `json:"conditions,omitempty"` + Conditions Conditions `json:"conditions,omitempty"` - // readyReplicas is the number of ready replicas for this MachineDeployment. A machine is considered ready when Machine's Ready condition is true. + // updatedReplicas is the total number of non-terminated machines targeted by this deployment + // that have the desired template spec. + // + // Deprecated: This field 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. + // // +optional - ReadyReplicas *int32 `json:"readyReplicas,omitempty"` + UpdatedReplicas int32 `json:"updatedReplicas"` - // availableReplicas is the number of available replicas for this MachineDeployment. A machine is considered available when Machine's Available condition is true. + // readyReplicas is the total number of ready machines targeted by this deployment. + // + // Deprecated: This field 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. + // // +optional - AvailableReplicas *int32 `json:"availableReplicas,omitempty"` + ReadyReplicas int32 `json:"readyReplicas"` - // upToDateReplicas is the number of up-to-date replicas targeted by this deployment. A machine is considered up-to-date when Machine's UpToDate condition is true. + // availableReplicas is the total number of available machines (ready for at least minReadySeconds) + // targeted by this deployment. + // + // Deprecated: This field 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. + // // +optional - UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"` + AvailableReplicas int32 `json:"availableReplicas"` + + // unavailableReplicas is the total number of unavailable machines targeted by this deployment. + // This is the total number of machines that are still required for + // the deployment to have 100% available capacity. They may either + // be machines that are running but not yet available or machines + // that still have not been created. + // + // Deprecated: This field 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. + // + // +optional + UnavailableReplicas int32 `json:"unavailableReplicas"` } // ANCHOR_END: MachineDeploymentStatus @@ -623,26 +643,29 @@ func init() { // GetConditions returns the set of conditions for the machinedeployment. func (m *MachineDeployment) GetConditions() Conditions { - return m.Status.Conditions + if m.Status.Deprecated == nil || m.Status.Deprecated.V1Beta1 == nil { + return nil + } + return m.Status.Deprecated.V1Beta1.Conditions } // SetConditions updates the set of conditions on the machinedeployment. func (m *MachineDeployment) SetConditions(conditions Conditions) { - m.Status.Conditions = conditions + if m.Status.Deprecated == nil { + m.Status.Deprecated = &MachineDeploymentDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &MachineDeploymentV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.Conditions = conditions } // GetV1Beta2Conditions returns the set of conditions for this object. func (m *MachineDeployment) GetV1Beta2Conditions() []metav1.Condition { - if m.Status.V1Beta2 == nil { - return nil - } - return m.Status.V1Beta2.Conditions + return m.Status.Conditions } // SetV1Beta2Conditions sets conditions for an API object. func (m *MachineDeployment) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil { - m.Status.V1Beta2 = &MachineDeploymentV1Beta2Status{} - } - m.Status.V1Beta2.Conditions = conditions + m.Status.Conditions = conditions } diff --git a/api/v1beta2/machinehealthcheck_types.go b/api/v1beta2/machinehealthcheck_types.go index 794b4cd6ecec..c06537c9ebe6 100644 --- a/api/v1beta2/machinehealthcheck_types.go +++ b/api/v1beta2/machinehealthcheck_types.go @@ -152,6 +152,14 @@ type UnhealthyCondition struct { // MachineHealthCheckStatus defines the observed state of MachineHealthCheck. type MachineHealthCheckStatus struct { + // conditions represents the observations of a MachineHealthCheck's current state. + // Known condition types are RemediationAllowed, Paused. + // +optional + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=32 + Conditions []metav1.Condition `json:"conditions,omitempty"` + // expectedMachines is the total number of machines counted by this machine health check // +kubebuilder:validation:Minimum=0 // +optional @@ -179,25 +187,28 @@ type MachineHealthCheckStatus struct { // +kubebuilder:validation:items:MaxLength=253 Targets []string `json:"targets,omitempty"` - // conditions defines current service state of the MachineHealthCheck. + // deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed. // +optional - Conditions Conditions `json:"conditions,omitempty"` + Deprecated *MachineHealthCheckDeprecatedStatus `json:"deprecated,omitempty"` +} - // v1beta2 groups all the fields that will be added or modified in MachineHealthCheck's status with the V1Beta2 version. +// MachineHealthCheckDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type MachineHealthCheckDeprecatedStatus struct { + // v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. // +optional - V1Beta2 *MachineHealthCheckV1Beta2Status `json:"v1beta2,omitempty"` + V1Beta1 *MachineHealthCheckV1Beta1DeprecatedStatus `json:"v1beta1,omitempty"` } -// MachineHealthCheckV1Beta2Status groups all the fields that will be added or modified in MachineHealthCheck with the V1Beta2 version. +// MachineHealthCheckV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. // See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. -type MachineHealthCheckV1Beta2Status struct { - // conditions represents the observations of a MachineHealthCheck's current state. - // Known condition types are RemediationAllowed, Paused. +type MachineHealthCheckV1Beta1DeprecatedStatus struct { + // conditions defines current service state of the MachineHealthCheck. + // + // Deprecated: This field 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. + // // +optional - // +listType=map - // +listMapKey=type - // +kubebuilder:validation:MaxItems=32 - Conditions []metav1.Condition `json:"conditions,omitempty"` + Conditions Conditions `json:"conditions,omitempty"` } // ANCHOR_END: MachineHealthCheckStatus @@ -231,28 +242,31 @@ type MachineHealthCheck struct { // GetConditions returns the set of conditions for this object. func (m *MachineHealthCheck) GetConditions() Conditions { - return m.Status.Conditions + if m.Status.Deprecated == nil || m.Status.Deprecated.V1Beta1 == nil { + return nil + } + return m.Status.Deprecated.V1Beta1.Conditions } // SetConditions sets the conditions on this object. func (m *MachineHealthCheck) SetConditions(conditions Conditions) { - m.Status.Conditions = conditions + if m.Status.Deprecated == nil { + m.Status.Deprecated = &MachineHealthCheckDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &MachineHealthCheckV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.Conditions = conditions } // GetV1Beta2Conditions returns the set of conditions for this object. func (m *MachineHealthCheck) GetV1Beta2Conditions() []metav1.Condition { - if m.Status.V1Beta2 == nil { - return nil - } - return m.Status.V1Beta2.Conditions + return m.Status.Conditions } // SetV1Beta2Conditions sets conditions for an API object. func (m *MachineHealthCheck) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil { - m.Status.V1Beta2 = &MachineHealthCheckV1Beta2Status{} - } - m.Status.V1Beta2.Conditions = conditions + m.Status.Conditions = conditions } // +kubebuilder:object:root=true diff --git a/api/v1beta2/machineset_types.go b/api/v1beta2/machineset_types.go index 8fe17f18eae5..120b94dfec72 100644 --- a/api/v1beta2/machineset_types.go +++ b/api/v1beta2/machineset_types.go @@ -283,6 +283,14 @@ const ( // MachineSetStatus defines the observed state of MachineSet. type MachineSetStatus struct { + // conditions represents the observations of a MachineSet's current state. + // Known condition types are MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused. + // +optional + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=32 + Conditions []metav1.Condition `json:"conditions,omitempty"` + // selector is the same as the label selector but in the string format to avoid introspection // by clients. The string will be in the same format as the query-param syntax. // More info about label selectors: http://kubernetes.io/docs/user-guide/labels#label-selectors @@ -295,25 +303,45 @@ type MachineSetStatus struct { // +optional Replicas int32 `json:"replicas"` - // fullyLabeledReplicas is the number of replicas that have labels matching the labels of the machine template of the MachineSet. - // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - // + // readyReplicas is the number of ready replicas for this MachineSet. A machine is considered ready when Machine's Ready condition is true. // +optional - FullyLabeledReplicas int32 `json:"fullyLabeledReplicas"` + ReadyReplicas *int32 `json:"readyReplicas,omitempty"` - // readyReplicas is the number of ready replicas for this MachineSet. A machine is considered ready when the node has been created and is "Ready". + // availableReplicas is the number of available replicas for this MachineSet. A machine is considered available when Machine's Available condition is true. // +optional - ReadyReplicas int32 `json:"readyReplicas"` + AvailableReplicas *int32 `json:"availableReplicas,omitempty"` - // availableReplicas is the number of available replicas (ready for at least minReadySeconds) for this MachineSet. + // upToDateReplicas is the number of up-to-date replicas for this MachineSet. A machine is considered up-to-date when Machine's UpToDate condition is true. // +optional - AvailableReplicas int32 `json:"availableReplicas"` + UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"` // observedGeneration reflects the generation of the most recently observed MachineSet. // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty"` + // deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed. + // +optional + Deprecated *MachineSetDeprecatedStatus `json:"deprecated,omitempty"` +} + +// MachineSetDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type MachineSetDeprecatedStatus struct { + // v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. + // +optional + V1Beta1 *MachineSetV1Beta1DeprecatedStatus `json:"v1beta1,omitempty"` +} + +// MachineSetV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type MachineSetV1Beta1DeprecatedStatus struct { + // conditions defines current service state of the MachineSet. + // + // Deprecated: This field 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. + // + // +optional + Conditions Conditions `json:"conditions,omitempty"` + // failureReason will be set in the event that there is a terminal problem // reconciling the Machine and will contain a succinct value suitable // for machine interpretation. @@ -337,7 +365,7 @@ type MachineSetStatus struct { // can be added as events to the MachineSet object and/or logged in the // controller's output. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional FailureReason *capierrors.MachineSetStatusError `json:"failureReason,omitempty"` @@ -346,44 +374,33 @@ type MachineSetStatus struct { // reconciling the Machine and will contain a more verbose string suitable // for logging and human consumption. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=10240 FailureMessage *string `json:"failureMessage,omitempty"` - // conditions defines current service state of the MachineSet. - // +optional - Conditions Conditions `json:"conditions,omitempty"` - - // v1beta2 groups all the fields that will be added or modified in MachineSet's status with the V1Beta2 version. - // +optional - V1Beta2 *MachineSetV1Beta2Status `json:"v1beta2,omitempty"` -} - -// MachineSetV1Beta2Status groups all the fields that will be added or modified in MachineSetStatus with the V1Beta2 version. -// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. -type MachineSetV1Beta2Status struct { - // conditions represents the observations of a MachineSet's current state. - // Known condition types are MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused. - // +optional - // +listType=map - // +listMapKey=type - // +kubebuilder:validation:MaxItems=32 - Conditions []metav1.Condition `json:"conditions,omitempty"` - - // readyReplicas is the number of ready replicas for this MachineSet. A machine is considered ready when Machine's Ready condition is true. + // fullyLabeledReplicas is the number of replicas that have labels matching the labels of the machine template of the MachineSet. + // + // Deprecated: This field 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. + // // +optional - ReadyReplicas *int32 `json:"readyReplicas,omitempty"` + FullyLabeledReplicas int32 `json:"fullyLabeledReplicas"` - // availableReplicas is the number of available replicas for this MachineSet. A machine is considered available when Machine's Available condition is true. + // readyReplicas is the number of ready replicas for this MachineSet. A machine is considered ready when the node has been created and is "Ready". + // + // Deprecated: This field 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. + // // +optional - AvailableReplicas *int32 `json:"availableReplicas,omitempty"` + ReadyReplicas int32 `json:"readyReplicas"` - // upToDateReplicas is the number of up-to-date replicas for this MachineSet. A machine is considered up-to-date when Machine's UpToDate condition is true. + // availableReplicas is the number of available replicas (ready for at least minReadySeconds) for this MachineSet. + // + // Deprecated: This field 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. + // // +optional - UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"` + AvailableReplicas int32 `json:"availableReplicas"` } // ANCHOR_END: MachineSetStatus @@ -442,28 +459,31 @@ type MachineSet struct { // GetConditions returns the set of conditions for the MachineSet. func (m *MachineSet) GetConditions() Conditions { - return m.Status.Conditions + if m.Status.Deprecated == nil || m.Status.Deprecated.V1Beta1 == nil { + return nil + } + return m.Status.Deprecated.V1Beta1.Conditions } // SetConditions updates the set of conditions on the MachineSet. func (m *MachineSet) SetConditions(conditions Conditions) { - m.Status.Conditions = conditions + if m.Status.Deprecated == nil { + m.Status.Deprecated = &MachineSetDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &MachineSetV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.Conditions = conditions } // GetV1Beta2Conditions returns the set of conditions for this object. func (m *MachineSet) GetV1Beta2Conditions() []metav1.Condition { - if m.Status.V1Beta2 == nil { - return nil - } - return m.Status.V1Beta2.Conditions + return m.Status.Conditions } // SetV1Beta2Conditions sets conditions for an API object. func (m *MachineSet) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil { - m.Status.V1Beta2 = &MachineSetV1Beta2Status{} - } - m.Status.V1Beta2.Conditions = conditions + m.Status.Conditions = conditions } // +kubebuilder:object:root=true diff --git a/api/v1beta2/zz_generated.deepcopy.go b/api/v1beta2/zz_generated.deepcopy.go index 4715cf35e53e..02d4f467186e 100644 --- a/api/v1beta2/zz_generated.deepcopy.go +++ b/api/v1beta2/zz_generated.deepcopy.go @@ -138,6 +138,26 @@ func (in *ClusterClass) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterClassDeprecatedStatus) DeepCopyInto(out *ClusterClassDeprecatedStatus) { + *out = *in + if in.V1Beta1 != nil { + in, out := &in.V1Beta1, &out.V1Beta1 + *out = new(ClusterClassV1Beta1DeprecatedStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterClassDeprecatedStatus. +func (in *ClusterClassDeprecatedStatus) DeepCopy() *ClusterClassDeprecatedStatus { + if in == nil { + return nil + } + out := new(ClusterClassDeprecatedStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterClassList) DeepCopyInto(out *ClusterClassList) { *out = *in @@ -247,23 +267,23 @@ func (in *ClusterClassSpec) DeepCopy() *ClusterClassSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterClassStatus) DeepCopyInto(out *ClusterClassStatus) { *out = *in - if in.Variables != nil { - in, out := &in.Variables, &out.Variables - *out = make([]ClusterClassStatusVariable, len(*in)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make(Conditions, len(*in)) + if in.Variables != nil { + in, out := &in.Variables, &out.Variables + *out = make([]ClusterClassStatusVariable, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.V1Beta2 != nil { - in, out := &in.V1Beta2, &out.V1Beta2 - *out = new(ClusterClassV1Beta2Status) + if in.Deprecated != nil { + in, out := &in.Deprecated, &out.Deprecated + *out = new(ClusterClassDeprecatedStatus) (*in).DeepCopyInto(*out) } } @@ -318,23 +338,23 @@ func (in *ClusterClassStatusVariableDefinition) DeepCopy() *ClusterClassStatusVa } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterClassV1Beta2Status) DeepCopyInto(out *ClusterClassV1Beta2Status) { +func (in *ClusterClassV1Beta1DeprecatedStatus) DeepCopyInto(out *ClusterClassV1Beta1DeprecatedStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) + *out = make(Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterClassV1Beta2Status. -func (in *ClusterClassV1Beta2Status) DeepCopy() *ClusterClassV1Beta2Status { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterClassV1Beta1DeprecatedStatus. +func (in *ClusterClassV1Beta1DeprecatedStatus) DeepCopy() *ClusterClassV1Beta1DeprecatedStatus { if in == nil { return nil } - out := new(ClusterClassV1Beta2Status) + out := new(ClusterClassV1Beta1DeprecatedStatus) in.DeepCopyInto(out) return out } @@ -425,6 +445,26 @@ func (in *ClusterControlPlaneStatus) DeepCopy() *ClusterControlPlaneStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterDeprecatedStatus) DeepCopyInto(out *ClusterDeprecatedStatus) { + *out = *in + if in.V1Beta1 != nil { + in, out := &in.V1Beta1, &out.V1Beta1 + *out = new(ClusterV1Beta1DeprecatedStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterDeprecatedStatus. +func (in *ClusterDeprecatedStatus) DeepCopy() *ClusterDeprecatedStatus { + if in == nil { + return nil + } + out := new(ClusterDeprecatedStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterList) DeepCopyInto(out *ClusterList) { *out = *in @@ -531,6 +571,23 @@ func (in *ClusterSpec) DeepCopy() *ClusterSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterStatus) DeepCopyInto(out *ClusterStatus) { *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ControlPlane != nil { + in, out := &in.ControlPlane, &out.ControlPlane + *out = new(ClusterControlPlaneStatus) + (*in).DeepCopyInto(*out) + } + if in.Workers != nil { + in, out := &in.Workers, &out.Workers + *out = new(WorkersStatus) + (*in).DeepCopyInto(*out) + } if in.FailureDomains != nil { in, out := &in.FailureDomains, &out.FailureDomains *out = make(FailureDomains, len(*in)) @@ -538,26 +595,9 @@ func (in *ClusterStatus) DeepCopyInto(out *ClusterStatus) { (*out)[key] = *val.DeepCopy() } } - if in.FailureReason != nil { - in, out := &in.FailureReason, &out.FailureReason - *out = new(errors.ClusterStatusError) - **out = **in - } - if in.FailureMessage != nil { - in, out := &in.FailureMessage, &out.FailureMessage - *out = new(string) - **out = **in - } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make(Conditions, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.V1Beta2 != nil { - in, out := &in.V1Beta2, &out.V1Beta2 - *out = new(ClusterV1Beta2Status) + if in.Deprecated != nil { + in, out := &in.Deprecated, &out.Deprecated + *out = new(ClusterDeprecatedStatus) (*in).DeepCopyInto(*out) } } @@ -573,33 +613,33 @@ func (in *ClusterStatus) DeepCopy() *ClusterStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterV1Beta2Status) DeepCopyInto(out *ClusterV1Beta2Status) { +func (in *ClusterV1Beta1DeprecatedStatus) DeepCopyInto(out *ClusterV1Beta1DeprecatedStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) + *out = make(Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.ControlPlane != nil { - in, out := &in.ControlPlane, &out.ControlPlane - *out = new(ClusterControlPlaneStatus) - (*in).DeepCopyInto(*out) + if in.FailureReason != nil { + in, out := &in.FailureReason, &out.FailureReason + *out = new(errors.ClusterStatusError) + **out = **in } - if in.Workers != nil { - in, out := &in.Workers, &out.Workers - *out = new(WorkersStatus) - (*in).DeepCopyInto(*out) + if in.FailureMessage != nil { + in, out := &in.FailureMessage, &out.FailureMessage + *out = new(string) + **out = **in } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterV1Beta2Status. -func (in *ClusterV1Beta2Status) DeepCopy() *ClusterV1Beta2Status { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterV1Beta1DeprecatedStatus. +func (in *ClusterV1Beta1DeprecatedStatus) DeepCopy() *ClusterV1Beta1DeprecatedStatus { if in == nil { return nil } - out := new(ClusterV1Beta2Status) + out := new(ClusterV1Beta1DeprecatedStatus) in.DeepCopyInto(out) return out } @@ -1312,6 +1352,26 @@ func (in *MachineDeploymentClassTemplate) DeepCopy() *MachineDeploymentClassTemp return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineDeploymentDeprecatedStatus) DeepCopyInto(out *MachineDeploymentDeprecatedStatus) { + *out = *in + if in.V1Beta1 != nil { + in, out := &in.V1Beta1, &out.V1Beta1 + *out = new(MachineDeploymentV1Beta1DeprecatedStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineDeploymentDeprecatedStatus. +func (in *MachineDeploymentDeprecatedStatus) DeepCopy() *MachineDeploymentDeprecatedStatus { + if in == nil { + return nil + } + out := new(MachineDeploymentDeprecatedStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineDeploymentList) DeepCopyInto(out *MachineDeploymentList) { *out = *in @@ -1400,14 +1460,29 @@ func (in *MachineDeploymentStatus) DeepCopyInto(out *MachineDeploymentStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make(Conditions, len(*in)) + *out = make([]metav1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.V1Beta2 != nil { - in, out := &in.V1Beta2, &out.V1Beta2 - *out = new(MachineDeploymentV1Beta2Status) + if in.ReadyReplicas != nil { + in, out := &in.ReadyReplicas, &out.ReadyReplicas + *out = new(int32) + **out = **in + } + if in.AvailableReplicas != nil { + in, out := &in.AvailableReplicas, &out.AvailableReplicas + *out = new(int32) + **out = **in + } + if in.UpToDateReplicas != nil { + in, out := &in.UpToDateReplicas, &out.UpToDateReplicas + *out = new(int32) + **out = **in + } + if in.Deprecated != nil { + in, out := &in.Deprecated, &out.Deprecated + *out = new(MachineDeploymentDeprecatedStatus) (*in).DeepCopyInto(*out) } } @@ -1514,38 +1589,23 @@ func (in *MachineDeploymentTopology) DeepCopy() *MachineDeploymentTopology { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MachineDeploymentV1Beta2Status) DeepCopyInto(out *MachineDeploymentV1Beta2Status) { +func (in *MachineDeploymentV1Beta1DeprecatedStatus) DeepCopyInto(out *MachineDeploymentV1Beta1DeprecatedStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) + *out = make(Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.ReadyReplicas != nil { - in, out := &in.ReadyReplicas, &out.ReadyReplicas - *out = new(int32) - **out = **in - } - if in.AvailableReplicas != nil { - in, out := &in.AvailableReplicas, &out.AvailableReplicas - *out = new(int32) - **out = **in - } - if in.UpToDateReplicas != nil { - in, out := &in.UpToDateReplicas, &out.UpToDateReplicas - *out = new(int32) - **out = **in - } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineDeploymentV1Beta2Status. -func (in *MachineDeploymentV1Beta2Status) DeepCopy() *MachineDeploymentV1Beta2Status { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineDeploymentV1Beta1DeprecatedStatus. +func (in *MachineDeploymentV1Beta1DeprecatedStatus) DeepCopy() *MachineDeploymentV1Beta1DeprecatedStatus { if in == nil { return nil } - out := new(MachineDeploymentV1Beta2Status) + out := new(MachineDeploymentV1Beta1DeprecatedStatus) in.DeepCopyInto(out) return out } @@ -1572,6 +1632,26 @@ func (in *MachineDeploymentVariables) DeepCopy() *MachineDeploymentVariables { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineDeprecatedStatus) DeepCopyInto(out *MachineDeprecatedStatus) { + *out = *in + if in.V1Beta1 != nil { + in, out := &in.V1Beta1, &out.V1Beta1 + *out = new(MachineV1Beta1DeprecatedStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineDeprecatedStatus. +func (in *MachineDeprecatedStatus) DeepCopy() *MachineDeprecatedStatus { + if in == nil { + return nil + } + out := new(MachineDeprecatedStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineDrainRule) DeepCopyInto(out *MachineDrainRule) { *out = *in @@ -1797,6 +1877,26 @@ func (in *MachineHealthCheckClass) DeepCopy() *MachineHealthCheckClass { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineHealthCheckDeprecatedStatus) DeepCopyInto(out *MachineHealthCheckDeprecatedStatus) { + *out = *in + if in.V1Beta1 != nil { + in, out := &in.V1Beta1, &out.V1Beta1 + *out = new(MachineHealthCheckV1Beta1DeprecatedStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineHealthCheckDeprecatedStatus. +func (in *MachineHealthCheckDeprecatedStatus) DeepCopy() *MachineHealthCheckDeprecatedStatus { + if in == nil { + return nil + } + out := new(MachineHealthCheckDeprecatedStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineHealthCheckList) DeepCopyInto(out *MachineHealthCheckList) { *out = *in @@ -1873,21 +1973,21 @@ func (in *MachineHealthCheckSpec) DeepCopy() *MachineHealthCheckSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineHealthCheckStatus) DeepCopyInto(out *MachineHealthCheckStatus) { *out = *in - if in.Targets != nil { - in, out := &in.Targets, &out.Targets - *out = make([]string, len(*in)) - copy(*out, *in) - } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make(Conditions, len(*in)) + *out = make([]metav1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.V1Beta2 != nil { - in, out := &in.V1Beta2, &out.V1Beta2 - *out = new(MachineHealthCheckV1Beta2Status) + if in.Targets != nil { + in, out := &in.Targets, &out.Targets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Deprecated != nil { + in, out := &in.Deprecated, &out.Deprecated + *out = new(MachineHealthCheckDeprecatedStatus) (*in).DeepCopyInto(*out) } } @@ -1924,23 +2024,23 @@ func (in *MachineHealthCheckTopology) DeepCopy() *MachineHealthCheckTopology { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MachineHealthCheckV1Beta2Status) DeepCopyInto(out *MachineHealthCheckV1Beta2Status) { +func (in *MachineHealthCheckV1Beta1DeprecatedStatus) DeepCopyInto(out *MachineHealthCheckV1Beta1DeprecatedStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) + *out = make(Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineHealthCheckV1Beta2Status. -func (in *MachineHealthCheckV1Beta2Status) DeepCopy() *MachineHealthCheckV1Beta2Status { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineHealthCheckV1Beta1DeprecatedStatus. +func (in *MachineHealthCheckV1Beta1DeprecatedStatus) DeepCopy() *MachineHealthCheckV1Beta1DeprecatedStatus { if in == nil { return nil } - out := new(MachineHealthCheckV1Beta2Status) + out := new(MachineHealthCheckV1Beta1DeprecatedStatus) in.DeepCopyInto(out) return out } @@ -2221,6 +2321,26 @@ func (in *MachineSet) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachineSetDeprecatedStatus) DeepCopyInto(out *MachineSetDeprecatedStatus) { + *out = *in + if in.V1Beta1 != nil { + in, out := &in.V1Beta1, &out.V1Beta1 + *out = new(MachineSetV1Beta1DeprecatedStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineSetDeprecatedStatus. +func (in *MachineSetDeprecatedStatus) DeepCopy() *MachineSetDeprecatedStatus { + if in == nil { + return nil + } + out := new(MachineSetDeprecatedStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineSetList) DeepCopyInto(out *MachineSetList) { *out = *in @@ -2283,26 +2403,31 @@ func (in *MachineSetSpec) DeepCopy() *MachineSetSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineSetStatus) DeepCopyInto(out *MachineSetStatus) { *out = *in - if in.FailureReason != nil { - in, out := &in.FailureReason, &out.FailureReason - *out = new(errors.MachineSetStatusError) - **out = **in - } - if in.FailureMessage != nil { - in, out := &in.FailureMessage, &out.FailureMessage - *out = new(string) - **out = **in - } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make(Conditions, len(*in)) + *out = make([]metav1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.V1Beta2 != nil { - in, out := &in.V1Beta2, &out.V1Beta2 - *out = new(MachineSetV1Beta2Status) + if in.ReadyReplicas != nil { + in, out := &in.ReadyReplicas, &out.ReadyReplicas + *out = new(int32) + **out = **in + } + if in.AvailableReplicas != nil { + in, out := &in.AvailableReplicas, &out.AvailableReplicas + *out = new(int32) + **out = **in + } + if in.UpToDateReplicas != nil { + in, out := &in.UpToDateReplicas, &out.UpToDateReplicas + *out = new(int32) + **out = **in + } + if in.Deprecated != nil { + in, out := &in.Deprecated, &out.Deprecated + *out = new(MachineSetDeprecatedStatus) (*in).DeepCopyInto(*out) } } @@ -2318,38 +2443,33 @@ func (in *MachineSetStatus) DeepCopy() *MachineSetStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MachineSetV1Beta2Status) DeepCopyInto(out *MachineSetV1Beta2Status) { +func (in *MachineSetV1Beta1DeprecatedStatus) DeepCopyInto(out *MachineSetV1Beta1DeprecatedStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) + *out = make(Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.ReadyReplicas != nil { - in, out := &in.ReadyReplicas, &out.ReadyReplicas - *out = new(int32) - **out = **in - } - if in.AvailableReplicas != nil { - in, out := &in.AvailableReplicas, &out.AvailableReplicas - *out = new(int32) + if in.FailureReason != nil { + in, out := &in.FailureReason, &out.FailureReason + *out = new(errors.MachineSetStatusError) **out = **in } - if in.UpToDateReplicas != nil { - in, out := &in.UpToDateReplicas, &out.UpToDateReplicas - *out = new(int32) + if in.FailureMessage != nil { + in, out := &in.FailureMessage, &out.FailureMessage + *out = new(string) **out = **in } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineSetV1Beta2Status. -func (in *MachineSetV1Beta2Status) DeepCopy() *MachineSetV1Beta2Status { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineSetV1Beta1DeprecatedStatus. +func (in *MachineSetV1Beta1DeprecatedStatus) DeepCopy() *MachineSetV1Beta1DeprecatedStatus { if in == nil { return nil } - out := new(MachineSetV1Beta2Status) + out := new(MachineSetV1Beta1DeprecatedStatus) in.DeepCopyInto(out) return out } @@ -2409,6 +2529,13 @@ func (in *MachineSpec) DeepCopy() *MachineSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachineStatus) DeepCopyInto(out *MachineStatus) { *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } if in.NodeRef != nil { in, out := &in.NodeRef, &out.NodeRef *out = new(v1.ObjectReference) @@ -2423,16 +2550,6 @@ func (in *MachineStatus) DeepCopyInto(out *MachineStatus) { in, out := &in.LastUpdated, &out.LastUpdated *out = (*in).DeepCopy() } - if in.FailureReason != nil { - in, out := &in.FailureReason, &out.FailureReason - *out = new(errors.MachineStatusError) - **out = **in - } - if in.FailureMessage != nil { - in, out := &in.FailureMessage, &out.FailureMessage - *out = new(string) - **out = **in - } if in.Addresses != nil { in, out := &in.Addresses, &out.Addresses *out = make(MachineAddresses, len(*in)) @@ -2442,21 +2559,14 @@ func (in *MachineStatus) DeepCopyInto(out *MachineStatus) { in, out := &in.CertificatesExpiryDate, &out.CertificatesExpiryDate *out = (*in).DeepCopy() } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make(Conditions, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } if in.Deletion != nil { in, out := &in.Deletion, &out.Deletion *out = new(MachineDeletionStatus) (*in).DeepCopyInto(*out) } - if in.V1Beta2 != nil { - in, out := &in.V1Beta2, &out.V1Beta2 - *out = new(MachineV1Beta2Status) + if in.Deprecated != nil { + in, out := &in.Deprecated, &out.Deprecated + *out = new(MachineDeprecatedStatus) (*in).DeepCopyInto(*out) } } @@ -2489,23 +2599,33 @@ func (in *MachineTemplateSpec) DeepCopy() *MachineTemplateSpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MachineV1Beta2Status) DeepCopyInto(out *MachineV1Beta2Status) { +func (in *MachineV1Beta1DeprecatedStatus) DeepCopyInto(out *MachineV1Beta1DeprecatedStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) + *out = make(Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.FailureReason != nil { + in, out := &in.FailureReason, &out.FailureReason + *out = new(errors.MachineStatusError) + **out = **in + } + if in.FailureMessage != nil { + in, out := &in.FailureMessage, &out.FailureMessage + *out = new(string) + **out = **in + } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineV1Beta2Status. -func (in *MachineV1Beta2Status) DeepCopy() *MachineV1Beta2Status { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachineV1Beta1DeprecatedStatus. +func (in *MachineV1Beta1DeprecatedStatus) DeepCopy() *MachineV1Beta1DeprecatedStatus { if in == nil { return nil } - out := new(MachineV1Beta2Status) + out := new(MachineV1Beta1DeprecatedStatus) in.DeepCopyInto(out) return out } diff --git a/bootstrap/kubeadm/api/v1beta2/kubeadmconfig_types.go b/bootstrap/kubeadm/api/v1beta2/kubeadmconfig_types.go index 72e44f4a11c6..294770db43d8 100644 --- a/bootstrap/kubeadm/api/v1beta2/kubeadmconfig_types.go +++ b/bootstrap/kubeadm/api/v1beta2/kubeadmconfig_types.go @@ -452,6 +452,14 @@ type ContainerLinuxConfig struct { // KubeadmConfigStatus defines the observed state of KubeadmConfig. type KubeadmConfigStatus struct { + // conditions represents the observations of a KubeadmConfig's current state. + // Known condition types are Ready, DataSecretAvailable, CertificatesAvailable. + // +optional + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=32 + Conditions []metav1.Condition `json:"conditions,omitempty"` + // ready indicates the BootstrapData field is ready to be consumed // +optional Ready bool `json:"ready"` @@ -462,9 +470,36 @@ type KubeadmConfigStatus struct { // +kubebuilder:validation:MaxLength=253 DataSecretName *string `json:"dataSecretName,omitempty"` + // observedGeneration is the latest generation observed by the controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed. + // +optional + Deprecated *KubeadmConfigDeprecatedStatus `json:"deprecated,omitempty"` +} + +// KubeadmConfigDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type KubeadmConfigDeprecatedStatus struct { + // v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. + // +optional + V1Beta1 *KubeadmConfigV1Beta1DeprecatedStatus `json:"v1beta1,omitempty"` +} + +// KubeadmConfigV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type KubeadmConfigV1Beta1DeprecatedStatus struct { + // conditions defines current service state of the KubeadmConfig. + // + // Deprecated: This field 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. + // + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` + // failureReason will be set on non-retryable errors // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional // +kubebuilder:validation:MinLength=1 @@ -473,36 +508,12 @@ type KubeadmConfigStatus struct { // failureMessage will be set on non-retryable errors // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=10240 FailureMessage string `json:"failureMessage,omitempty"` - - // observedGeneration is the latest generation observed by the controller. - // +optional - ObservedGeneration int64 `json:"observedGeneration,omitempty"` - - // conditions defines current service state of the KubeadmConfig. - // +optional - Conditions clusterv1.Conditions `json:"conditions,omitempty"` - - // v1beta2 groups all the fields that will be added or modified in KubeadmConfig's status with the V1Beta2 version. - // +optional - V1Beta2 *KubeadmConfigV1Beta2Status `json:"v1beta2,omitempty"` -} - -// KubeadmConfigV1Beta2Status groups all the fields that will be added or modified in KubeadmConfig with the V1Beta2 version. -// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. -type KubeadmConfigV1Beta2Status struct { - // conditions represents the observations of a KubeadmConfig's current state. - // Known condition types are Ready, DataSecretAvailable, CertificatesAvailable. - // +optional - // +listType=map - // +listMapKey=type - // +kubebuilder:validation:MaxItems=32 - Conditions []metav1.Condition `json:"conditions,omitempty"` } // +kubebuilder:object:root=true @@ -530,28 +541,31 @@ type KubeadmConfig struct { // GetConditions returns the set of conditions for this object. func (c *KubeadmConfig) GetConditions() clusterv1.Conditions { - return c.Status.Conditions + if c.Status.Deprecated == nil || c.Status.Deprecated.V1Beta1 == nil { + return nil + } + return c.Status.Deprecated.V1Beta1.Conditions } // SetConditions sets the conditions on this object. func (c *KubeadmConfig) SetConditions(conditions clusterv1.Conditions) { - c.Status.Conditions = conditions + if c.Status.Deprecated == nil { + c.Status.Deprecated = &KubeadmConfigDeprecatedStatus{} + } + if c.Status.Deprecated.V1Beta1 == nil { + c.Status.Deprecated.V1Beta1 = &KubeadmConfigV1Beta1DeprecatedStatus{} + } + c.Status.Deprecated.V1Beta1.Conditions = conditions } // GetV1Beta2Conditions returns the set of conditions for this object. func (c *KubeadmConfig) GetV1Beta2Conditions() []metav1.Condition { - if c.Status.V1Beta2 == nil { - return nil - } - return c.Status.V1Beta2.Conditions + return c.Status.Conditions } // SetV1Beta2Conditions sets conditions for an API object. func (c *KubeadmConfig) SetV1Beta2Conditions(conditions []metav1.Condition) { - if c.Status.V1Beta2 == nil { - c.Status.V1Beta2 = &KubeadmConfigV1Beta2Status{} - } - c.Status.V1Beta2.Conditions = conditions + c.Status.Conditions = conditions } // +kubebuilder:object:root=true diff --git a/bootstrap/kubeadm/api/v1beta2/zz_generated.deepcopy.go b/bootstrap/kubeadm/api/v1beta2/zz_generated.deepcopy.go index 1adfd3c229a2..046f58206e01 100644 --- a/bootstrap/kubeadm/api/v1beta2/zz_generated.deepcopy.go +++ b/bootstrap/kubeadm/api/v1beta2/zz_generated.deepcopy.go @@ -791,6 +791,26 @@ func (in *KubeadmConfig) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeadmConfigDeprecatedStatus) DeepCopyInto(out *KubeadmConfigDeprecatedStatus) { + *out = *in + if in.V1Beta1 != nil { + in, out := &in.V1Beta1, &out.V1Beta1 + *out = new(KubeadmConfigV1Beta1DeprecatedStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeadmConfigDeprecatedStatus. +func (in *KubeadmConfigDeprecatedStatus) DeepCopy() *KubeadmConfigDeprecatedStatus { + if in == nil { + return nil + } + out := new(KubeadmConfigDeprecatedStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KubeadmConfigList) DeepCopyInto(out *KubeadmConfigList) { *out = *in @@ -916,21 +936,21 @@ func (in *KubeadmConfigSpec) DeepCopy() *KubeadmConfigSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KubeadmConfigStatus) DeepCopyInto(out *KubeadmConfigStatus) { *out = *in - if in.DataSecretName != nil { - in, out := &in.DataSecretName, &out.DataSecretName - *out = new(string) - **out = **in - } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make(apiv1beta2.Conditions, len(*in)) + *out = make([]v1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.V1Beta2 != nil { - in, out := &in.V1Beta2, &out.V1Beta2 - *out = new(KubeadmConfigV1Beta2Status) + if in.DataSecretName != nil { + in, out := &in.DataSecretName, &out.DataSecretName + *out = new(string) + **out = **in + } + if in.Deprecated != nil { + in, out := &in.Deprecated, &out.Deprecated + *out = new(KubeadmConfigDeprecatedStatus) (*in).DeepCopyInto(*out) } } @@ -1037,23 +1057,23 @@ func (in *KubeadmConfigTemplateSpec) DeepCopy() *KubeadmConfigTemplateSpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KubeadmConfigV1Beta2Status) DeepCopyInto(out *KubeadmConfigV1Beta2Status) { +func (in *KubeadmConfigV1Beta1DeprecatedStatus) DeepCopyInto(out *KubeadmConfigV1Beta1DeprecatedStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make(apiv1beta2.Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeadmConfigV1Beta2Status. -func (in *KubeadmConfigV1Beta2Status) DeepCopy() *KubeadmConfigV1Beta2Status { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeadmConfigV1Beta1DeprecatedStatus. +func (in *KubeadmConfigV1Beta1DeprecatedStatus) DeepCopy() *KubeadmConfigV1Beta1DeprecatedStatus { if in == nil { return nil } - out := new(KubeadmConfigV1Beta2Status) + out := new(KubeadmConfigV1Beta1DeprecatedStatus) in.DeepCopyInto(out) return out } diff --git a/controlplane/kubeadm/api/v1beta2/kubeadm_control_plane_types.go b/controlplane/kubeadm/api/v1beta2/kubeadm_control_plane_types.go index 10e54a663e54..afd5a3846484 100644 --- a/controlplane/kubeadm/api/v1beta2/kubeadm_control_plane_types.go +++ b/controlplane/kubeadm/api/v1beta2/kubeadm_control_plane_types.go @@ -282,6 +282,15 @@ type MachineNamingStrategy struct { // KubeadmControlPlaneStatus defines the observed state of KubeadmControlPlane. type KubeadmControlPlaneStatus struct { + // conditions represents the observations of a KubeadmControlPlane's current state. + // Known condition types are Available, CertificatesAvailable, EtcdClusterAvailable, MachinesReady, MachinesUpToDate, + // ScalingUp, ScalingDown, Remediating, Deleting, Paused. + // +optional + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=32 + Conditions []metav1.Condition `json:"conditions,omitempty"` + // selector is the label selector in string format to avoid introspection // by clients, and is used to provide the CRD-based integration for the // scale subresource and additional integrations for things like kubectl @@ -297,32 +306,24 @@ type KubeadmControlPlaneStatus struct { // +optional Replicas int32 `json:"replicas"` - // version represents the minimum Kubernetes version for the control plane machines - // in the cluster. + // readyReplicas is the number of ready replicas for this KubeadmControlPlane. A machine is considered ready when Machine's Ready condition is true. // +optional - // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:MaxLength=256 - Version *string `json:"version,omitempty"` + ReadyReplicas *int32 `json:"readyReplicas,omitempty"` - // updatedReplicas is the total number of non-terminated machines targeted by this control plane - // that have the desired template spec. + // availableReplicas is the number of available replicas targeted by this KubeadmControlPlane. A machine is considered available when Machine's Available condition is true. // +optional - UpdatedReplicas int32 `json:"updatedReplicas"` + AvailableReplicas *int32 `json:"availableReplicas,omitempty"` - // readyReplicas is the total number of fully running and ready control plane machines. + // upToDateReplicas is the number of up-to-date replicas targeted by this KubeadmControlPlane. A machine is considered up-to-date when Machine's UpToDate condition is true. // +optional - ReadyReplicas int32 `json:"readyReplicas"` + UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"` - // unavailableReplicas is the total number of unavailable machines targeted by this control plane. - // This is the total number of machines that are still required for - // the deployment to have 100% available capacity. They may either - // be machines that are running but not yet ready or machines - // that still have not been created. - // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - // + // version represents the minimum Kubernetes version for the control plane machines + // in the cluster. // +optional - UnavailableReplicas int32 `json:"unavailableReplicas"` + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=256 + Version *string `json:"version,omitempty"` // initialized denotes that the KubeadmControlPlane API Server is initialized and thus // it can accept requests. @@ -340,11 +341,42 @@ type KubeadmControlPlaneStatus struct { // +optional Ready bool `json:"ready"` + // observedGeneration is the latest generation observed by the controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + + // lastRemediation stores info about last remediation performed. + // +optional + LastRemediation *LastRemediationStatus `json:"lastRemediation,omitempty"` + + // deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed. + // +optional + Deprecated *KubeadmControlPlaneDeprecatedStatus `json:"deprecated,omitempty"` +} + +// KubeadmControlPlaneDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type KubeadmControlPlaneDeprecatedStatus struct { + // v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. + // +optional + V1Beta1 *KubeadmControlPlaneV1Beta1DeprecatedStatus `json:"v1beta1,omitempty"` +} + +// KubeadmControlPlaneV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type KubeadmControlPlaneV1Beta1DeprecatedStatus struct { + // conditions defines current service state of the KubeadmControlPlane. + // + // Deprecated: This field 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. + // + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` + // failureReason indicates that there is a terminal problem reconciling the // state, and will be set to a token value suitable for // programmatic interpretation. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional FailureReason errors.KubeadmControlPlaneStatusError `json:"failureReason,omitempty"` @@ -352,53 +384,38 @@ type KubeadmControlPlaneStatus struct { // failureMessage indicates that there is a terminal problem reconciling the // state, and will be set to a descriptive error message. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=10240 FailureMessage *string `json:"failureMessage,omitempty"` - // observedGeneration is the latest generation observed by the controller. - // +optional - ObservedGeneration int64 `json:"observedGeneration,omitempty"` - - // conditions defines current service state of the KubeadmControlPlane. - // +optional - Conditions clusterv1.Conditions `json:"conditions,omitempty"` - - // lastRemediation stores info about last remediation performed. - // +optional - LastRemediation *LastRemediationStatus `json:"lastRemediation,omitempty"` - - // v1beta2 groups all the fields that will be added or modified in KubeadmControlPlane's status with the V1Beta2 version. - // +optional - V1Beta2 *KubeadmControlPlaneV1Beta2Status `json:"v1beta2,omitempty"` -} - -// KubeadmControlPlaneV1Beta2Status Groups all the fields that will be added or modified in KubeadmControlPlane with the V1Beta2 version. -// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. -type KubeadmControlPlaneV1Beta2Status struct { - // conditions represents the observations of a KubeadmControlPlane's current state. - // Known condition types are Available, CertificatesAvailable, EtcdClusterAvailable, MachinesReady, MachinesUpToDate, - // ScalingUp, ScalingDown, Remediating, Deleting, Paused. - // +optional - // +listType=map - // +listMapKey=type - // +kubebuilder:validation:MaxItems=32 - Conditions []metav1.Condition `json:"conditions,omitempty"` - - // readyReplicas is the number of ready replicas for this KubeadmControlPlane. A machine is considered ready when Machine's Ready condition is true. + // updatedReplicas is the total number of non-terminated machines targeted by this control plane + // that have the desired template spec. + // + // Deprecated: This field 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. + // // +optional - ReadyReplicas *int32 `json:"readyReplicas,omitempty"` + UpdatedReplicas int32 `json:"updatedReplicas"` - // availableReplicas is the number of available replicas targeted by this KubeadmControlPlane. A machine is considered available when Machine's Available condition is true. + // readyReplicas is the total number of fully running and ready control plane machines. + // + // Deprecated: This field 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. + // // +optional - AvailableReplicas *int32 `json:"availableReplicas,omitempty"` + ReadyReplicas int32 `json:"readyReplicas"` - // upToDateReplicas is the number of up-to-date replicas targeted by this KubeadmControlPlane. A machine is considered up-to-date when Machine's UpToDate condition is true. + // unavailableReplicas is the total number of unavailable machines targeted by this control plane. + // This is the total number of machines that are still required for + // the deployment to have 100% available capacity. They may either + // be machines that are running but not yet ready or machines + // that still have not been created. + // + // Deprecated: This field 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. + // // +optional - UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"` + UnavailableReplicas int32 `json:"unavailableReplicas"` } // LastRemediationStatus stores info about last remediation performed. @@ -455,28 +472,31 @@ type KubeadmControlPlane struct { // GetConditions returns the set of conditions for this object. func (in *KubeadmControlPlane) GetConditions() clusterv1.Conditions { - return in.Status.Conditions + if in.Status.Deprecated == nil || in.Status.Deprecated.V1Beta1 == nil { + return nil + } + return in.Status.Deprecated.V1Beta1.Conditions } // SetConditions sets the conditions on this object. func (in *KubeadmControlPlane) SetConditions(conditions clusterv1.Conditions) { - in.Status.Conditions = conditions + if in.Status.Deprecated == nil { + in.Status.Deprecated = &KubeadmControlPlaneDeprecatedStatus{} + } + if in.Status.Deprecated.V1Beta1 == nil { + in.Status.Deprecated.V1Beta1 = &KubeadmControlPlaneV1Beta1DeprecatedStatus{} + } + in.Status.Deprecated.V1Beta1.Conditions = conditions } // GetV1Beta2Conditions returns the set of conditions for this object. func (in *KubeadmControlPlane) GetV1Beta2Conditions() []metav1.Condition { - if in.Status.V1Beta2 == nil { - return nil - } - return in.Status.V1Beta2.Conditions + return in.Status.Conditions } // SetV1Beta2Conditions sets conditions for an API object. func (in *KubeadmControlPlane) SetV1Beta2Conditions(conditions []metav1.Condition) { - if in.Status.V1Beta2 == nil { - in.Status.V1Beta2 = &KubeadmControlPlaneV1Beta2Status{} - } - in.Status.V1Beta2.Conditions = conditions + in.Status.Conditions = conditions } // +kubebuilder:object:root=true diff --git a/controlplane/kubeadm/api/v1beta2/zz_generated.deepcopy.go b/controlplane/kubeadm/api/v1beta2/zz_generated.deepcopy.go index cfad6626a34c..d9836887a409 100644 --- a/controlplane/kubeadm/api/v1beta2/zz_generated.deepcopy.go +++ b/controlplane/kubeadm/api/v1beta2/zz_generated.deepcopy.go @@ -54,6 +54,26 @@ func (in *KubeadmControlPlane) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeadmControlPlaneDeprecatedStatus) DeepCopyInto(out *KubeadmControlPlaneDeprecatedStatus) { + *out = *in + if in.V1Beta1 != nil { + in, out := &in.V1Beta1, &out.V1Beta1 + *out = new(KubeadmControlPlaneV1Beta1DeprecatedStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeadmControlPlaneDeprecatedStatus. +func (in *KubeadmControlPlaneDeprecatedStatus) DeepCopy() *KubeadmControlPlaneDeprecatedStatus { + if in == nil { + return nil + } + out := new(KubeadmControlPlaneDeprecatedStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KubeadmControlPlaneList) DeepCopyInto(out *KubeadmControlPlaneList) { *out = *in @@ -172,31 +192,41 @@ func (in *KubeadmControlPlaneSpec) DeepCopy() *KubeadmControlPlaneSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KubeadmControlPlaneStatus) DeepCopyInto(out *KubeadmControlPlaneStatus) { *out = *in - if in.Version != nil { - in, out := &in.Version, &out.Version - *out = new(string) - **out = **in - } - if in.FailureMessage != nil { - in, out := &in.FailureMessage, &out.FailureMessage - *out = new(string) - **out = **in - } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make(apiv1beta2.Conditions, len(*in)) + *out = make([]v1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.ReadyReplicas != nil { + in, out := &in.ReadyReplicas, &out.ReadyReplicas + *out = new(int32) + **out = **in + } + if in.AvailableReplicas != nil { + in, out := &in.AvailableReplicas, &out.AvailableReplicas + *out = new(int32) + **out = **in + } + if in.UpToDateReplicas != nil { + in, out := &in.UpToDateReplicas, &out.UpToDateReplicas + *out = new(int32) + **out = **in + } + if in.Version != nil { + in, out := &in.Version, &out.Version + *out = new(string) + **out = **in + } if in.LastRemediation != nil { in, out := &in.LastRemediation, &out.LastRemediation *out = new(LastRemediationStatus) (*in).DeepCopyInto(*out) } - if in.V1Beta2 != nil { - in, out := &in.V1Beta2, &out.V1Beta2 - *out = new(KubeadmControlPlaneV1Beta2Status) + if in.Deprecated != nil { + in, out := &in.Deprecated, &out.Deprecated + *out = new(KubeadmControlPlaneDeprecatedStatus) (*in).DeepCopyInto(*out) } } @@ -379,38 +409,28 @@ func (in *KubeadmControlPlaneTemplateSpec) DeepCopy() *KubeadmControlPlaneTempla } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KubeadmControlPlaneV1Beta2Status) DeepCopyInto(out *KubeadmControlPlaneV1Beta2Status) { +func (in *KubeadmControlPlaneV1Beta1DeprecatedStatus) DeepCopyInto(out *KubeadmControlPlaneV1Beta1DeprecatedStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make(apiv1beta2.Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.ReadyReplicas != nil { - in, out := &in.ReadyReplicas, &out.ReadyReplicas - *out = new(int32) - **out = **in - } - if in.AvailableReplicas != nil { - in, out := &in.AvailableReplicas, &out.AvailableReplicas - *out = new(int32) - **out = **in - } - if in.UpToDateReplicas != nil { - in, out := &in.UpToDateReplicas, &out.UpToDateReplicas - *out = new(int32) + if in.FailureMessage != nil { + in, out := &in.FailureMessage, &out.FailureMessage + *out = new(string) **out = **in } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeadmControlPlaneV1Beta2Status. -func (in *KubeadmControlPlaneV1Beta2Status) DeepCopy() *KubeadmControlPlaneV1Beta2Status { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeadmControlPlaneV1Beta1DeprecatedStatus. +func (in *KubeadmControlPlaneV1Beta1DeprecatedStatus) DeepCopy() *KubeadmControlPlaneV1Beta1DeprecatedStatus { if in == nil { return nil } - out := new(KubeadmControlPlaneV1Beta2Status) + out := new(KubeadmControlPlaneV1Beta1DeprecatedStatus) in.DeepCopyInto(out) return out } diff --git a/exp/api/v1beta2/machinepool_types.go b/exp/api/v1beta2/machinepool_types.go index 9cce93ec541d..29e558debadf 100644 --- a/exp/api/v1beta2/machinepool_types.go +++ b/exp/api/v1beta2/machinepool_types.go @@ -77,6 +77,15 @@ type MachinePoolSpec struct { // MachinePoolStatus defines the observed state of MachinePool. type MachinePoolStatus struct { + // conditions represents the observations of a MachinePool's current state. + // Known condition types are Available, BootstrapConfigReady, InfrastructureReady, MachinesReady, MachinesUpToDate, + // ScalingUp, ScalingDown, Remediating, Deleting, Paused. + // +optional + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=32 + Conditions []metav1.Condition `json:"conditions,omitempty"` + // nodeRefs will point to the corresponding Nodes if it they exist. // +optional // +kubebuilder:validation:MaxItems=10000 @@ -86,42 +95,17 @@ type MachinePoolStatus struct { // +optional Replicas int32 `json:"replicas"` - // readyReplicas is the number of ready replicas for this MachinePool. A machine is considered ready when the node has been created and is "Ready". - // +optional - ReadyReplicas int32 `json:"readyReplicas,omitempty"` - - // availableReplicas is the number of available replicas (ready for at least minReadySeconds) for this MachinePool. - // +optional - AvailableReplicas int32 `json:"availableReplicas,omitempty"` - - // unavailableReplicas is the total number of unavailable machine instances targeted by this machine pool. - // This is the total number of machine instances that are still required for - // the machine pool to have 100% available capacity. They may either - // be machine instances that are running but not yet available or machine instances - // that still have not been created. - // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - // + // readyReplicas is the number of ready replicas for this MachinePool. A machine is considered ready when Machine's Ready condition is true. // +optional - UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"` + ReadyReplicas *int32 `json:"readyReplicas,omitempty"` - // failureReason indicates that there is a problem reconciling the state, and - // will be set to a token value suitable for programmatic interpretation. - // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - // + // availableReplicas is the number of available replicas for this MachinePool. A machine is considered available when Machine's Available condition is true. // +optional - FailureReason *capierrors.MachinePoolStatusFailure `json:"failureReason,omitempty"` + AvailableReplicas *int32 `json:"availableReplicas,omitempty"` - // failureMessage indicates that there is a problem reconciling the state, - // and will be set to a descriptive error message. - // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - // + // upToDateReplicas is the number of up-to-date replicas targeted by this MachinePool. A machine is considered up-to-date when Machine's UpToDate condition is true. // +optional - // +kubebuilder:validation:MinLength=1 - // +kubebuilder:validation:MaxLength=10240 - FailureMessage *string `json:"failureMessage,omitempty"` + UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"` // phase represents the current phase of cluster actuation. // +optional @@ -140,38 +124,65 @@ type MachinePoolStatus struct { // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty"` - // conditions define the current service state of the MachinePool. + // deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed. // +optional - Conditions clusterv1.Conditions `json:"conditions,omitempty"` + Deprecated *MachinePoolDeprecatedStatus `json:"deprecated,omitempty"` +} - // v1beta2 groups all the fields that will be added or modified in MachinePool's status with the V1Beta2 version. +// MachinePoolDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type MachinePoolDeprecatedStatus struct { + // v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. // +optional - V1Beta2 *MachinePoolV1Beta2Status `json:"v1beta2,omitempty"` + V1Beta1 *MachinePoolV1Beta1DeprecatedStatus `json:"v1beta1,omitempty"` } -// MachinePoolV1Beta2Status groups all the fields that will be added or modified in MachinePoolStatus with the V1Beta2 version. +// MachinePoolV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. // See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. -type MachinePoolV1Beta2Status struct { - // conditions represents the observations of a MachinePool's current state. - // Known condition types are Available, BootstrapConfigReady, InfrastructureReady, MachinesReady, MachinesUpToDate, - // ScalingUp, ScalingDown, Remediating, Deleting, Paused. +type MachinePoolV1Beta1DeprecatedStatus struct { + // conditions define the current service state of the MachinePool. + // + // Deprecated: This field 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. + // // +optional - // +listType=map - // +listMapKey=type - // +kubebuilder:validation:MaxItems=32 - Conditions []metav1.Condition `json:"conditions,omitempty"` + Conditions clusterv1.Conditions `json:"conditions,omitempty"` - // readyReplicas is the number of ready replicas for this MachinePool. A machine is considered ready when Machine's Ready condition is true. + // failureReason indicates that there is a problem reconciling the state, and + // will be set to a token value suitable for programmatic interpretation. + // + // Deprecated: This field 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. + // // +optional - ReadyReplicas *int32 `json:"readyReplicas,omitempty"` + FailureReason *capierrors.MachinePoolStatusFailure `json:"failureReason,omitempty"` - // availableReplicas is the number of available replicas for this MachinePool. A machine is considered available when Machine's Available condition is true. + // failureMessage indicates that there is a problem reconciling the state, + // and will be set to a descriptive error message. + // + // Deprecated: This field 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. + // // +optional - AvailableReplicas *int32 `json:"availableReplicas,omitempty"` + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=10240 + FailureMessage *string `json:"failureMessage,omitempty"` - // upToDateReplicas is the number of up-to-date replicas targeted by this MachinePool. A machine is considered up-to-date when Machine's UpToDate condition is true. + // readyReplicas is the number of ready replicas for this MachinePool. A machine is considered ready when the node has been created and is "Ready". // +optional - UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"` + ReadyReplicas int32 `json:"readyReplicas,omitempty"` + + // availableReplicas is the number of available replicas (ready for at least minReadySeconds) for this MachinePool. + // +optional + AvailableReplicas int32 `json:"availableReplicas,omitempty"` + + // unavailableReplicas is the total number of unavailable machine instances targeted by this machine pool. + // This is the total number of machine instances that are still required for + // the machine pool to have 100% available capacity. They may either + // be machine instances that are running but not yet available or machine instances + // that still have not been created. + // + // Deprecated: This field 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. + // + // +optional + UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"` } // ANCHOR_END: MachinePoolStatus @@ -287,28 +298,31 @@ type MachinePool struct { // GetConditions returns the set of conditions for this object. func (m *MachinePool) GetConditions() clusterv1.Conditions { - return m.Status.Conditions + if m.Status.Deprecated == nil || m.Status.Deprecated.V1Beta1 == nil { + return nil + } + return m.Status.Deprecated.V1Beta1.Conditions } // SetConditions sets the conditions on this object. func (m *MachinePool) SetConditions(conditions clusterv1.Conditions) { - m.Status.Conditions = conditions + if m.Status.Deprecated == nil { + m.Status.Deprecated = &MachinePoolDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &MachinePoolV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.Conditions = conditions } // GetV1Beta2Conditions returns the set of conditions for this object. func (m *MachinePool) GetV1Beta2Conditions() []metav1.Condition { - if m.Status.V1Beta2 == nil { - return nil - } - return m.Status.V1Beta2.Conditions + return m.Status.Conditions } // SetV1Beta2Conditions sets conditions for an API object. func (m *MachinePool) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil { - m.Status.V1Beta2 = &MachinePoolV1Beta2Status{} - } - m.Status.V1Beta2.Conditions = conditions + m.Status.Conditions = conditions } // +kubebuilder:object:root=true diff --git a/exp/api/v1beta2/zz_generated.deepcopy.go b/exp/api/v1beta2/zz_generated.deepcopy.go index 210b53fc3940..96a588d0275b 100644 --- a/exp/api/v1beta2/zz_generated.deepcopy.go +++ b/exp/api/v1beta2/zz_generated.deepcopy.go @@ -21,8 +21,8 @@ limitations under the License. package v1beta2 import ( - "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" apiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" "sigs.k8s.io/cluster-api/errors" @@ -55,6 +55,26 @@ func (in *MachinePool) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachinePoolDeprecatedStatus) DeepCopyInto(out *MachinePoolDeprecatedStatus) { + *out = *in + if in.V1Beta1 != nil { + in, out := &in.V1Beta1, &out.V1Beta1 + *out = new(MachinePoolV1Beta1DeprecatedStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachinePoolDeprecatedStatus. +func (in *MachinePoolDeprecatedStatus) DeepCopy() *MachinePoolDeprecatedStatus { + if in == nil { + return nil + } + out := new(MachinePoolDeprecatedStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachinePoolList) DeepCopyInto(out *MachinePoolList) { *out = *in @@ -126,31 +146,36 @@ func (in *MachinePoolSpec) DeepCopy() *MachinePoolSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MachinePoolStatus) DeepCopyInto(out *MachinePoolStatus) { *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } if in.NodeRefs != nil { in, out := &in.NodeRefs, &out.NodeRefs - *out = make([]v1.ObjectReference, len(*in)) + *out = make([]corev1.ObjectReference, len(*in)) copy(*out, *in) } - if in.FailureReason != nil { - in, out := &in.FailureReason, &out.FailureReason - *out = new(errors.MachinePoolStatusFailure) + if in.ReadyReplicas != nil { + in, out := &in.ReadyReplicas, &out.ReadyReplicas + *out = new(int32) **out = **in } - if in.FailureMessage != nil { - in, out := &in.FailureMessage, &out.FailureMessage - *out = new(string) + if in.AvailableReplicas != nil { + in, out := &in.AvailableReplicas, &out.AvailableReplicas + *out = new(int32) **out = **in } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make(apiv1beta2.Conditions, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + if in.UpToDateReplicas != nil { + in, out := &in.UpToDateReplicas, &out.UpToDateReplicas + *out = new(int32) + **out = **in } - if in.V1Beta2 != nil { - in, out := &in.V1Beta2, &out.V1Beta2 - *out = new(MachinePoolV1Beta2Status) + if in.Deprecated != nil { + in, out := &in.Deprecated, &out.Deprecated + *out = new(MachinePoolDeprecatedStatus) (*in).DeepCopyInto(*out) } } @@ -166,38 +191,33 @@ func (in *MachinePoolStatus) DeepCopy() *MachinePoolStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MachinePoolV1Beta2Status) DeepCopyInto(out *MachinePoolV1Beta2Status) { +func (in *MachinePoolV1Beta1DeprecatedStatus) DeepCopyInto(out *MachinePoolV1Beta1DeprecatedStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) + *out = make(apiv1beta2.Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.ReadyReplicas != nil { - in, out := &in.ReadyReplicas, &out.ReadyReplicas - *out = new(int32) - **out = **in - } - if in.AvailableReplicas != nil { - in, out := &in.AvailableReplicas, &out.AvailableReplicas - *out = new(int32) + if in.FailureReason != nil { + in, out := &in.FailureReason, &out.FailureReason + *out = new(errors.MachinePoolStatusFailure) **out = **in } - if in.UpToDateReplicas != nil { - in, out := &in.UpToDateReplicas, &out.UpToDateReplicas - *out = new(int32) + if in.FailureMessage != nil { + in, out := &in.FailureMessage, &out.FailureMessage + *out = new(string) **out = **in } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachinePoolV1Beta2Status. -func (in *MachinePoolV1Beta2Status) DeepCopy() *MachinePoolV1Beta2Status { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachinePoolV1Beta1DeprecatedStatus. +func (in *MachinePoolV1Beta1DeprecatedStatus) DeepCopy() *MachinePoolV1Beta1DeprecatedStatus { if in == nil { return nil } - out := new(MachinePoolV1Beta2Status) + out := new(MachinePoolV1Beta1DeprecatedStatus) in.DeepCopyInto(out) return out } diff --git a/exp/ipam/api/v1beta2/ipaddressclaim_types.go b/exp/ipam/api/v1beta2/ipaddressclaim_types.go index e7a6941c6a7d..4ce3c49ca3c2 100644 --- a/exp/ipam/api/v1beta2/ipaddressclaim_types.go +++ b/exp/ipam/api/v1beta2/ipaddressclaim_types.go @@ -38,28 +38,39 @@ type IPAddressClaimSpec struct { // IPAddressClaimStatus is the observed status of a IPAddressClaim. type IPAddressClaimStatus struct { + // conditions represents the observations of a IPAddressClaim's current state. + // +optional + // +listType=map + // +listMapKey=type + // +kubebuilder:validation:MaxItems=32 + Conditions []metav1.Condition `json:"conditions,omitempty"` + // addressRef is a reference to the address that was created for this claim. // +optional AddressRef corev1.LocalObjectReference `json:"addressRef,omitempty"` - // conditions summarises the current state of the IPAddressClaim + // deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed. // +optional - Conditions clusterv1.Conditions `json:"conditions,omitempty"` + Deprecated *IPAddressClaimDeprecatedStatus `json:"deprecated,omitempty"` +} - // v1beta2 groups all the fields that will be added or modified in IPAddressClaim's status with the V1Beta2 version. +// IPAddressClaimDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. +// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. +type IPAddressClaimDeprecatedStatus struct { + // v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. // +optional - V1Beta2 *IPAddressClaimV1Beta2Status `json:"v1beta2,omitempty"` + V1Beta1 *IPAddressClaimV1Beta1DeprecatedStatus `json:"v1beta1,omitempty"` } -// IPAddressClaimV1Beta2Status groups all the fields that will be added or modified in IPAddressClaimStatus with the V1Beta2 version. +// IPAddressClaimV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. // See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context. -type IPAddressClaimV1Beta2Status struct { - // conditions represents the observations of a IPAddressClaim's current state. +type IPAddressClaimV1Beta1DeprecatedStatus struct { + // conditions summarises the current state of the IPAddressClaim + // + // Deprecated: This field 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. + // // +optional - // +listType=map - // +listMapKey=type - // +kubebuilder:validation:MaxItems=32 - Conditions []metav1.Condition `json:"conditions,omitempty"` + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } // +kubebuilder:object:root=true @@ -88,28 +99,31 @@ type IPAddressClaim struct { // GetConditions returns the set of conditions for this object. func (m *IPAddressClaim) GetConditions() clusterv1.Conditions { - return m.Status.Conditions + if m.Status.Deprecated == nil || m.Status.Deprecated.V1Beta1 == nil { + return nil + } + return m.Status.Deprecated.V1Beta1.Conditions } // SetConditions sets the conditions on this object. func (m *IPAddressClaim) SetConditions(conditions clusterv1.Conditions) { - m.Status.Conditions = conditions + if m.Status.Deprecated == nil { + m.Status.Deprecated = &IPAddressClaimDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &IPAddressClaimV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.Conditions = conditions } // GetV1Beta2Conditions returns the set of conditions for this object. func (m *IPAddressClaim) GetV1Beta2Conditions() []metav1.Condition { - if m.Status.V1Beta2 == nil { - return nil - } - return m.Status.V1Beta2.Conditions + return m.Status.Conditions } // SetV1Beta2Conditions sets conditions for an API object. func (m *IPAddressClaim) SetV1Beta2Conditions(conditions []metav1.Condition) { - if m.Status.V1Beta2 == nil { - m.Status.V1Beta2 = &IPAddressClaimV1Beta2Status{} - } - m.Status.V1Beta2.Conditions = conditions + m.Status.Conditions = conditions } // +kubebuilder:object:root=true diff --git a/exp/ipam/api/v1beta2/zz_generated.deepcopy.go b/exp/ipam/api/v1beta2/zz_generated.deepcopy.go index ca9d0a7d57ab..155367c9bd0f 100644 --- a/exp/ipam/api/v1beta2/zz_generated.deepcopy.go +++ b/exp/ipam/api/v1beta2/zz_generated.deepcopy.go @@ -79,6 +79,26 @@ func (in *IPAddressClaim) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressClaimDeprecatedStatus) DeepCopyInto(out *IPAddressClaimDeprecatedStatus) { + *out = *in + if in.V1Beta1 != nil { + in, out := &in.V1Beta1, &out.V1Beta1 + *out = new(IPAddressClaimV1Beta1DeprecatedStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressClaimDeprecatedStatus. +func (in *IPAddressClaimDeprecatedStatus) DeepCopy() *IPAddressClaimDeprecatedStatus { + if in == nil { + return nil + } + out := new(IPAddressClaimDeprecatedStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IPAddressClaimList) DeepCopyInto(out *IPAddressClaimList) { *out = *in @@ -130,17 +150,17 @@ func (in *IPAddressClaimSpec) DeepCopy() *IPAddressClaimSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IPAddressClaimStatus) DeepCopyInto(out *IPAddressClaimStatus) { *out = *in - out.AddressRef = in.AddressRef if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make(apiv1beta2.Conditions, len(*in)) + *out = make([]v1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.V1Beta2 != nil { - in, out := &in.V1Beta2, &out.V1Beta2 - *out = new(IPAddressClaimV1Beta2Status) + out.AddressRef = in.AddressRef + if in.Deprecated != nil { + in, out := &in.Deprecated, &out.Deprecated + *out = new(IPAddressClaimDeprecatedStatus) (*in).DeepCopyInto(*out) } } @@ -156,23 +176,23 @@ func (in *IPAddressClaimStatus) DeepCopy() *IPAddressClaimStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *IPAddressClaimV1Beta2Status) DeepCopyInto(out *IPAddressClaimV1Beta2Status) { +func (in *IPAddressClaimV1Beta1DeprecatedStatus) DeepCopyInto(out *IPAddressClaimV1Beta1DeprecatedStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + *out = make(apiv1beta2.Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressClaimV1Beta2Status. -func (in *IPAddressClaimV1Beta2Status) DeepCopy() *IPAddressClaimV1Beta2Status { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressClaimV1Beta1DeprecatedStatus. +func (in *IPAddressClaimV1Beta1DeprecatedStatus) DeepCopy() *IPAddressClaimV1Beta1DeprecatedStatus { if in == nil { return nil } - out := new(IPAddressClaimV1Beta2Status) + out := new(IPAddressClaimV1Beta1DeprecatedStatus) in.DeepCopyInto(out) return out } From dd6094cc85f1930f97b727a9eb2264c4f94916ee Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Mon, 7 Apr 2025 08:29:59 +0200 Subject: [PATCH 02/11] Fix conversions --- api/addons/v1beta1/conversion.go | 69 ++ api/addons/v1beta1/conversion_test.go | 36 +- api/addons/v1beta1/zz_generated.conversion.go | 123 +-- api/v1beta1/cluster_types.go | 4 +- api/v1beta1/conversion.go | 446 +++++++++ api/v1beta1/conversion_test.go | 329 +++++- api/v1beta1/machine_types.go | 4 +- api/v1beta1/machinedeployment_types.go | 2 +- api/v1beta1/machineset_types.go | 6 +- api/v1beta1/zz_generated.conversion.go | 942 +++++++++--------- bootstrap/kubeadm/api/v1beta1/conversion.go | 71 +- .../kubeadm/api/v1beta1/conversion_test.go | 37 +- .../api/v1beta1/kubeadmconfig_types.go | 4 +- .../api/v1beta1/zz_generated.conversion.go | 128 +-- .../kubeadm/api/v1beta1/conversion.go | 95 +- .../kubeadm/api/v1beta1/conversion_test.go | 38 +- .../v1beta1/kubeadm_control_plane_types.go | 6 +- .../api/v1beta1/zz_generated.conversion.go | 149 ++- exp/api/v1beta1/conversion.go | 93 +- exp/api/v1beta1/conversion_test.go | 37 +- exp/api/v1beta1/machinepool_types.go | 6 +- exp/api/v1beta1/zz_generated.conversion.go | 119 +-- exp/ipam/api/v1alpha1/conversion.go | 25 +- exp/ipam/api/v1alpha1/conversion_test.go | 25 +- .../api/v1alpha1/zz_generated.conversion.go | 31 +- exp/ipam/api/v1beta1/conversion.go | 65 ++ exp/ipam/api/v1beta1/conversion_test.go | 37 +- .../api/v1beta1/zz_generated.conversion.go | 115 ++- internal/apis/addons/v1alpha3/conversion.go | 43 +- .../apis/addons/v1alpha3/conversion_test.go | 25 +- .../v1alpha3/zz_generated.conversion.go | 37 +- internal/apis/addons/v1alpha4/conversion.go | 42 +- .../apis/addons/v1alpha4/conversion_test.go | 25 +- .../v1alpha4/zz_generated.conversion.go | 37 +- .../bootstrap/kubeadm/v1alpha3/conversion.go | 66 +- .../kubeadm/v1alpha3/conversion_test.go | 58 +- .../v1alpha3/zz_generated.conversion.go | 44 +- .../bootstrap/kubeadm/v1alpha4/conversion.go | 67 +- .../kubeadm/v1alpha4/conversion_test.go | 19 +- .../v1alpha4/zz_generated.conversion.go | 58 +- .../kubeadm/v1alpha3/conversion.go | 69 +- .../kubeadm/v1alpha3/conversion_test.go | 53 +- .../v1alpha3/zz_generated.conversion.go | 76 +- .../kubeadm/v1alpha4/conversion.go | 76 +- .../kubeadm/v1alpha4/conversion_test.go | 68 +- .../v1alpha4/zz_generated.conversion.go | 74 +- internal/apis/core/exp/v1alpha3/conversion.go | 116 ++- .../apis/core/exp/v1alpha3/conversion_test.go | 28 +- .../exp/v1alpha3/zz_generated.conversion.go | 79 +- internal/apis/core/exp/v1alpha4/conversion.go | 57 +- .../apis/core/exp/v1alpha4/conversion_test.go | 26 +- .../exp/v1alpha4/zz_generated.conversion.go | 77 +- internal/apis/core/v1alpha3/conversion.go | 208 +++- .../apis/core/v1alpha3/conversion_test.go | 110 +- .../core/v1alpha3/zz_generated.conversion.go | 238 +++-- internal/apis/core/v1alpha4/conversion.go | 258 ++++- .../apis/core/v1alpha4/conversion_test.go | 113 ++- .../core/v1alpha4/zz_generated.conversion.go | 309 ++++-- 58 files changed, 4207 insertions(+), 1391 deletions(-) diff --git a/api/addons/v1beta1/conversion.go b/api/addons/v1beta1/conversion.go index d88a0ef26631..c22e69c4a4b4 100644 --- a/api/addons/v1beta1/conversion.go +++ b/api/addons/v1beta1/conversion.go @@ -17,9 +17,12 @@ limitations under the License. package v1beta1 import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" addonsv1 "sigs.k8s.io/cluster-api/api/addons/v1beta2" + clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" ) func (src *ClusterResourceSet) ConvertTo(dstRaw conversion.Hub) error { @@ -45,3 +48,69 @@ func (dst *ClusterResourceSetBinding) ConvertFrom(srcRaw conversion.Hub) error { return Convert_v1beta2_ClusterResourceSetBinding_To_v1beta1_ClusterResourceSetBinding(src, dst, nil) } + +func Convert_v1beta2_ClusterResourceSetStatus_To_v1beta1_ClusterResourceSetStatus(in *addonsv1.ClusterResourceSetStatus, out *ClusterResourceSetStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta2_ClusterResourceSetStatus_To_v1beta1_ClusterResourceSetStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). + out.Conditions = nil + + // Retrieve legacy conditions (v1beta1) from the deprecated field. + if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { + if in.Deprecated.V1Beta1.Conditions != nil { + clusterv1beta1.Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + } + } + + // Move new conditions (v1beta2) to the v1beta2 field. + if in.Conditions == nil { + return nil + } + out.V1Beta2 = &ClusterResourceSetV1Beta2Status{} + out.V1Beta2.Conditions = in.Conditions + return nil +} + +func Convert_v1beta1_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStatus(in *ClusterResourceSetStatus, out *addonsv1.ClusterResourceSetStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta1_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. + out.Conditions = nil + + // Retrieve new conditions (v1beta2) from the v1beta2 field. + if in.V1Beta2 != nil { + out.Conditions = in.V1Beta2.Conditions + } + + // Move legacy conditions (v1beta1) to the deprecated field. + if in.Conditions == nil { + return nil + } + + if out.Deprecated == nil { + out.Deprecated = &addonsv1.ClusterResourceSetDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &addonsv1.ClusterResourceSetV1Beta1DeprecatedStatus{} + } + if in.Conditions != nil { + clusterv1beta1.Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + } + return nil +} + +// Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) + +func Convert_v1_Condition_To_v1beta1_Condition(in *metav1.Condition, out *clusterv1beta1.Condition, s apimachineryconversion.Scope) error { + return clusterv1beta1.Convert_v1_Condition_To_v1beta1_Condition(in, out, s) +} + +func Convert_v1beta1_Condition_To_v1_Condition(in *clusterv1beta1.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1beta1.Convert_v1beta1_Condition_To_v1_Condition(in, out, s) +} diff --git a/api/addons/v1beta1/conversion_test.go b/api/addons/v1beta1/conversion_test.go index 849004214987..04314c0c5013 100644 --- a/api/addons/v1beta1/conversion_test.go +++ b/api/addons/v1beta1/conversion_test.go @@ -21,6 +21,10 @@ package v1beta1 import ( "testing" + fuzz "github.com/google/gofuzz" + "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" + addonsv1 "sigs.k8s.io/cluster-api/api/addons/v1beta2" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -29,11 +33,39 @@ import ( func TestFuzzyConversion(t *testing.T) { t.Run("for ClusterResourceSet", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Hub: &addonsv1.ClusterResourceSet{}, - Spoke: &ClusterResourceSet{}, + Hub: &addonsv1.ClusterResourceSet{}, + Spoke: &ClusterResourceSet{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{ClusterResourceSetFuzzFuncs}, })) t.Run("for ClusterResourceSetBinding", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &addonsv1.ClusterResourceSetBinding{}, Spoke: &ClusterResourceSetBinding{}, })) } + +func ClusterResourceSetFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubClusterResourceSetStatus, + spokeClusterResourceSetStatus, + } +} + +func hubClusterResourceSetStatus(in *addonsv1.ClusterResourceSetStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + in.Deprecated = nil + } + } +} + +func spokeClusterResourceSetStatus(in *ClusterResourceSetStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.V1Beta2 != nil { + if in.V1Beta2.Conditions == nil { + in.V1Beta2 = nil + } + } +} diff --git a/api/addons/v1beta1/zz_generated.conversion.go b/api/addons/v1beta1/zz_generated.conversion.go index 1eaafe90ad5d..eeb1cb34720c 100644 --- a/api/addons/v1beta1/zz_generated.conversion.go +++ b/api/addons/v1beta1/zz_generated.conversion.go @@ -29,7 +29,6 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" v1beta2 "sigs.k8s.io/cluster-api/api/addons/v1beta2" apiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" - apiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" ) func init() { @@ -99,26 +98,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*ClusterResourceSetStatus)(nil), (*v1beta2.ClusterResourceSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStatus(a.(*ClusterResourceSetStatus), b.(*v1beta2.ClusterResourceSetStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.ClusterResourceSetStatus)(nil), (*ClusterResourceSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ClusterResourceSetStatus_To_v1beta1_ClusterResourceSetStatus(a.(*v1beta2.ClusterResourceSetStatus), b.(*ClusterResourceSetStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*ClusterResourceSetV1Beta2Status)(nil), (*v1beta2.ClusterResourceSetV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_ClusterResourceSetV1Beta2Status_To_v1beta2_ClusterResourceSetV1Beta2Status(a.(*ClusterResourceSetV1Beta2Status), b.(*v1beta2.ClusterResourceSetV1Beta2Status), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.ClusterResourceSetV1Beta2Status)(nil), (*ClusterResourceSetV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ClusterResourceSetV1Beta2Status_To_v1beta1_ClusterResourceSetV1Beta2Status(a.(*v1beta2.ClusterResourceSetV1Beta2Status), b.(*ClusterResourceSetV1Beta2Status), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*ResourceBinding)(nil), (*v1beta2.ResourceBinding)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_ResourceBinding_To_v1beta2_ResourceBinding(a.(*ResourceBinding), b.(*v1beta2.ResourceBinding), scope) }); err != nil { @@ -149,6 +128,26 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1.Condition)(nil), (*apiv1beta1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1beta1_Condition(a.(*v1.Condition), b.(*apiv1beta1.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*ClusterResourceSetStatus)(nil), (*v1beta2.ClusterResourceSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStatus(a.(*ClusterResourceSetStatus), b.(*v1beta2.ClusterResourceSetStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*apiv1beta1.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_Condition_To_v1_Condition(a.(*apiv1beta1.Condition), b.(*v1.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta2.ClusterResourceSetStatus)(nil), (*ClusterResourceSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_ClusterResourceSetStatus_To_v1beta1_ClusterResourceSetStatus(a.(*v1beta2.ClusterResourceSetStatus), b.(*ClusterResourceSetStatus), scope) + }); err != nil { + return err + } return nil } @@ -256,7 +255,17 @@ func Convert_v1beta2_ClusterResourceSetBindingSpec_To_v1beta1_ClusterResourceSet func autoConvert_v1beta1_ClusterResourceSetList_To_v1beta2_ClusterResourceSetList(in *ClusterResourceSetList, out *v1beta2.ClusterResourceSetList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1beta2.ClusterResourceSet)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.ClusterResourceSet, len(*in)) + for i := range *in { + if err := Convert_v1beta1_ClusterResourceSet_To_v1beta2_ClusterResourceSet(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -267,7 +276,17 @@ func Convert_v1beta1_ClusterResourceSetList_To_v1beta2_ClusterResourceSetList(in func autoConvert_v1beta2_ClusterResourceSetList_To_v1beta1_ClusterResourceSetList(in *v1beta2.ClusterResourceSetList, out *ClusterResourceSetList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]ClusterResourceSet)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterResourceSet, len(*in)) + for i := range *in { + if err := Convert_v1beta2_ClusterResourceSet_To_v1beta1_ClusterResourceSet(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -302,48 +321,38 @@ func Convert_v1beta2_ClusterResourceSetSpec_To_v1beta1_ClusterResourceSetSpec(in func autoConvert_v1beta1_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStatus(in *ClusterResourceSetStatus, out *v1beta2.ClusterResourceSetStatus, s conversion.Scope) error { out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*apiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*v1beta2.ClusterResourceSetV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStatus is an autogenerated conversion function. -func Convert_v1beta1_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStatus(in *ClusterResourceSetStatus, out *v1beta2.ClusterResourceSetStatus, s conversion.Scope) error { - return autoConvert_v1beta1_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStatus(in, out, s) -} - func autoConvert_v1beta2_ClusterResourceSetStatus_To_v1beta1_ClusterResourceSetStatus(in *v1beta2.ClusterResourceSetStatus, out *ClusterResourceSetStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(apiv1beta1.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1beta1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*ClusterResourceSetV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta2_ClusterResourceSetStatus_To_v1beta1_ClusterResourceSetStatus is an autogenerated conversion function. -func Convert_v1beta2_ClusterResourceSetStatus_To_v1beta1_ClusterResourceSetStatus(in *v1beta2.ClusterResourceSetStatus, out *ClusterResourceSetStatus, s conversion.Scope) error { - return autoConvert_v1beta2_ClusterResourceSetStatus_To_v1beta1_ClusterResourceSetStatus(in, out, s) -} - -func autoConvert_v1beta1_ClusterResourceSetV1Beta2Status_To_v1beta2_ClusterResourceSetV1Beta2Status(in *ClusterResourceSetV1Beta2Status, out *v1beta2.ClusterResourceSetV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]v1.Condition)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta1_ClusterResourceSetV1Beta2Status_To_v1beta2_ClusterResourceSetV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta1_ClusterResourceSetV1Beta2Status_To_v1beta2_ClusterResourceSetV1Beta2Status(in *ClusterResourceSetV1Beta2Status, out *v1beta2.ClusterResourceSetV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta1_ClusterResourceSetV1Beta2Status_To_v1beta2_ClusterResourceSetV1Beta2Status(in, out, s) -} - -func autoConvert_v1beta2_ClusterResourceSetV1Beta2Status_To_v1beta1_ClusterResourceSetV1Beta2Status(in *v1beta2.ClusterResourceSetV1Beta2Status, out *ClusterResourceSetV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]v1.Condition)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta2_ClusterResourceSetV1Beta2Status_To_v1beta1_ClusterResourceSetV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta2_ClusterResourceSetV1Beta2Status_To_v1beta1_ClusterResourceSetV1Beta2Status(in *v1beta2.ClusterResourceSetV1Beta2Status, out *ClusterResourceSetV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta2_ClusterResourceSetV1Beta2Status_To_v1beta1_ClusterResourceSetV1Beta2Status(in, out, s) -} - func autoConvert_v1beta1_ResourceBinding_To_v1beta2_ResourceBinding(in *ResourceBinding, out *v1beta2.ResourceBinding, s conversion.Scope) error { if err := Convert_v1beta1_ResourceRef_To_v1beta2_ResourceRef(&in.ResourceRef, &out.ResourceRef, s); err != nil { return err diff --git a/api/v1beta1/cluster_types.go b/api/v1beta1/cluster_types.go index 9168868b63c8..4841e7339369 100644 --- a/api/v1beta1/cluster_types.go +++ b/api/v1beta1/cluster_types.go @@ -964,7 +964,7 @@ type ClusterStatus struct { // state, and will be set to a token value suitable for // programmatic interpretation. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional FailureReason *capierrors.ClusterStatusError `json:"failureReason,omitempty"` @@ -972,7 +972,7 @@ type ClusterStatus struct { // failureMessage indicates that there is a fatal problem reconciling the // state, and will be set to a descriptive error message. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional // +kubebuilder:validation:MinLength=1 diff --git a/api/v1beta1/conversion.go b/api/v1beta1/conversion.go index 9744a8cc08ee..da3d60f0c82f 100644 --- a/api/v1beta1/conversion.go +++ b/api/v1beta1/conversion.go @@ -17,6 +17,10 @@ limitations under the License. package v1beta1 import ( + "unsafe" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2" @@ -93,3 +97,445 @@ func (dst *MachineHealthCheck) ConvertFrom(srcRaw conversion.Hub) error { return Convert_v1beta2_MachineHealthCheck_To_v1beta1_MachineHealthCheck(src, dst, nil) } + +func Convert_v1beta2_ClusterClassStatus_To_v1beta1_ClusterClassStatus(in *clusterv1.ClusterClassStatus, out *ClusterClassStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta2_ClusterClassStatus_To_v1beta1_ClusterClassStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). + out.Conditions = nil + + // Retrieve legacy conditions (v1beta1) from the deprecated field. + if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { + if in.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + } + } + + // Move new conditions (v1beta2) to the v1beta2 field. + if in.Conditions == nil { + return nil + } + out.V1Beta2 = &ClusterClassV1Beta2Status{} + out.V1Beta2.Conditions = in.Conditions + return nil +} + +func Convert_v1beta1_ClusterClassStatus_To_v1beta2_ClusterClassStatus(in *ClusterClassStatus, out *clusterv1.ClusterClassStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta1_ClusterClassStatus_To_v1beta2_ClusterClassStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. + out.Conditions = nil + + // Retrieve new conditions (v1beta2) from the v1beta2 field. + if in.V1Beta2 != nil { + out.Conditions = in.V1Beta2.Conditions + } + + // Move legacy conditions (v1beta1) to the deprecated field. + if in.Conditions == nil { + return nil + } + + if out.Deprecated == nil { + out.Deprecated = &clusterv1.ClusterClassDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &clusterv1.ClusterClassV1Beta1DeprecatedStatus{} + } + if in.Conditions != nil { + Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + } + return nil +} + +func Convert_v1beta2_ClusterStatus_To_v1beta1_ClusterStatus(in *clusterv1.ClusterStatus, out *ClusterStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta2_ClusterStatus_To_v1beta1_ClusterStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). + out.Conditions = nil + + // Retrieve legacy conditions (v1beta1) from the deprecated field. + if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { + if in.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + } + out.FailureReason = in.Deprecated.V1Beta1.FailureReason + out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage + } + + // Move new conditions (v1beta2), controlPlane and workers counters to the v1beta2 field. + if in.Conditions == nil && in.ControlPlane == nil && in.Workers == nil { + return nil + } + out.V1Beta2 = &ClusterV1Beta2Status{} + out.V1Beta2.Conditions = in.Conditions + if in.ControlPlane != nil { + out.V1Beta2.ControlPlane = &ClusterControlPlaneStatus{ + DesiredReplicas: in.ControlPlane.DesiredReplicas, + Replicas: in.ControlPlane.Replicas, + UpToDateReplicas: in.ControlPlane.UpToDateReplicas, + ReadyReplicas: in.ControlPlane.ReadyReplicas, + AvailableReplicas: in.ControlPlane.AvailableReplicas, + } + } + if in.Workers != nil { + out.V1Beta2.Workers = &WorkersStatus{ + DesiredReplicas: in.Workers.DesiredReplicas, + Replicas: in.Workers.Replicas, + UpToDateReplicas: in.Workers.UpToDateReplicas, + ReadyReplicas: in.Workers.ReadyReplicas, + AvailableReplicas: in.Workers.AvailableReplicas, + } + } + return nil +} + +func Convert_v1beta1_ClusterStatus_To_v1beta2_ClusterStatus(in *ClusterStatus, out *clusterv1.ClusterStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta1_ClusterStatus_To_v1beta2_ClusterStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. + out.Conditions = nil + + // Retrieve new conditions (v1beta2), controlPlane and workers counters from the v1beta2 field. + if in.V1Beta2 != nil { + out.Conditions = in.V1Beta2.Conditions + if in.V1Beta2.ControlPlane != nil { + out.ControlPlane = &clusterv1.ClusterControlPlaneStatus{ + DesiredReplicas: in.V1Beta2.ControlPlane.DesiredReplicas, + Replicas: in.V1Beta2.ControlPlane.Replicas, + UpToDateReplicas: in.V1Beta2.ControlPlane.UpToDateReplicas, + ReadyReplicas: in.V1Beta2.ControlPlane.ReadyReplicas, + AvailableReplicas: in.V1Beta2.ControlPlane.AvailableReplicas, + } + } + if in.V1Beta2.Workers != nil { + out.Workers = &clusterv1.WorkersStatus{ + DesiredReplicas: in.V1Beta2.Workers.DesiredReplicas, + Replicas: in.V1Beta2.Workers.Replicas, + UpToDateReplicas: in.V1Beta2.Workers.UpToDateReplicas, + ReadyReplicas: in.V1Beta2.Workers.ReadyReplicas, + AvailableReplicas: in.V1Beta2.Workers.AvailableReplicas, + } + } + } + + // Move legacy conditions (v1beta1), FailureReason and FailureMessage to the deprecated field. + if in.Conditions == nil && in.FailureReason == nil && in.FailureMessage == nil { + return nil + } + + if out.Deprecated == nil { + out.Deprecated = &clusterv1.ClusterDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &clusterv1.ClusterV1Beta1DeprecatedStatus{} + } + if in.Conditions != nil { + Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + } + out.Deprecated.V1Beta1.FailureReason = in.FailureReason + out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage + return nil +} + +func Convert_v1beta2_MachineDeploymentStatus_To_v1beta1_MachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, out *MachineDeploymentStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta2_MachineDeploymentStatus_To_v1beta1_MachineDeploymentStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). + out.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. + out.AvailableReplicas = 0 + out.ReadyReplicas = 0 + + // Retrieve legacy conditions (v1beta1) and replica counters from the deprecated field. + if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { + if in.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + } + out.AvailableReplicas = in.Deprecated.V1Beta1.AvailableReplicas + out.UnavailableReplicas = in.Deprecated.V1Beta1.UnavailableReplicas + out.UpdatedReplicas = in.Deprecated.V1Beta1.UpdatedReplicas + out.ReadyReplicas = in.Deprecated.V1Beta1.ReadyReplicas + } + + // Move new conditions (v1beta2) and replica counters to the v1beta2 field. + if in.Conditions == nil && in.ReadyReplicas == nil && in.AvailableReplicas == nil && in.UpToDateReplicas == nil { + return nil + } + out.V1Beta2 = &MachineDeploymentV1Beta2Status{} + out.V1Beta2.Conditions = in.Conditions + out.V1Beta2.ReadyReplicas = in.ReadyReplicas + out.V1Beta2.AvailableReplicas = in.AvailableReplicas + out.V1Beta2.UpToDateReplicas = in.UpToDateReplicas + return nil +} + +func Convert_v1beta1_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(in *MachineDeploymentStatus, out *clusterv1.MachineDeploymentStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta1_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. + out.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: old replica counters should not be automatically be converted into replica counters with a new semantic. + out.AvailableReplicas = nil + out.ReadyReplicas = nil + + // Retrieve new conditions (v1beta2) and replica counters from the v1beta2 field. + if in.V1Beta2 != nil { + out.Conditions = in.V1Beta2.Conditions + out.ReadyReplicas = in.V1Beta2.ReadyReplicas + out.AvailableReplicas = in.V1Beta2.AvailableReplicas + out.UpToDateReplicas = in.V1Beta2.UpToDateReplicas + } + + // Move legacy conditions (v1beta1) and replica counters to the deprecated field. + if out.Deprecated == nil { + out.Deprecated = &clusterv1.MachineDeploymentDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{} + } + if in.Conditions != nil { + Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + } + out.Deprecated.V1Beta1.AvailableReplicas = in.AvailableReplicas + out.Deprecated.V1Beta1.UnavailableReplicas = in.UnavailableReplicas + out.Deprecated.V1Beta1.UpdatedReplicas = in.UpdatedReplicas + out.Deprecated.V1Beta1.ReadyReplicas = in.ReadyReplicas + return nil +} + +func Convert_v1beta2_MachineHealthCheckStatus_To_v1beta1_MachineHealthCheckStatus(in *clusterv1.MachineHealthCheckStatus, out *MachineHealthCheckStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta2_MachineHealthCheckStatus_To_v1beta1_MachineHealthCheckStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). + out.Conditions = nil + + // Retrieve legacy conditions (v1beta1) from the deprecated field. + if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { + if in.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + } + } + + // Move new conditions (v1beta2) to the v1beta2 field. + if in.Conditions == nil { + return nil + } + out.V1Beta2 = &MachineHealthCheckV1Beta2Status{} + out.V1Beta2.Conditions = in.Conditions + return nil +} + +func Convert_v1beta1_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheckStatus(in *MachineHealthCheckStatus, out *clusterv1.MachineHealthCheckStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta1_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheckStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. + out.Conditions = nil + + // Retrieve new conditions (v1beta2) from the v1beta2 field. + if in.V1Beta2 != nil { + out.Conditions = in.V1Beta2.Conditions + } + + // Move legacy conditions (v1beta1) to the deprecated field. + if in.Conditions == nil { + return nil + } + + if out.Deprecated == nil { + out.Deprecated = &clusterv1.MachineHealthCheckDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{} + } + if in.Conditions != nil { + Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + } + return nil +} + +func Convert_v1beta2_MachineSetStatus_To_v1beta1_MachineSetStatus(in *clusterv1.MachineSetStatus, out *MachineSetStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta2_MachineSetStatus_To_v1beta1_MachineSetStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). + out.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. + out.AvailableReplicas = 0 + out.ReadyReplicas = 0 + + // Retrieve legacy conditions (v1beta1) and replica counters from the deprecated field. + if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { + if in.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + } + out.AvailableReplicas = in.Deprecated.V1Beta1.AvailableReplicas + out.FullyLabeledReplicas = in.Deprecated.V1Beta1.FullyLabeledReplicas + out.ReadyReplicas = in.Deprecated.V1Beta1.ReadyReplicas + out.FailureReason = in.Deprecated.V1Beta1.FailureReason + out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage + } + + // Move new conditions (v1beta2) and replica counters to the v1beta2 field. + if in.Conditions == nil && in.ReadyReplicas == nil && in.AvailableReplicas == nil && in.UpToDateReplicas == nil { + return nil + } + out.V1Beta2 = &MachineSetV1Beta2Status{} + out.V1Beta2.Conditions = in.Conditions + out.V1Beta2.ReadyReplicas = in.ReadyReplicas + out.V1Beta2.AvailableReplicas = in.AvailableReplicas + out.V1Beta2.UpToDateReplicas = in.UpToDateReplicas + return nil +} + +func Convert_v1beta1_MachineSetStatus_To_v1beta2_MachineSetStatus(in *MachineSetStatus, out *clusterv1.MachineSetStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta1_MachineSetStatus_To_v1beta2_MachineSetStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. + out.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: old replica counters should not be automatically be converted into replica counters with a new semantic. + out.AvailableReplicas = nil + out.ReadyReplicas = nil + + // Retrieve new conditions (v1beta2) from the v1beta2 field. + if in.V1Beta2 != nil { + out.Conditions = in.V1Beta2.Conditions + out.ReadyReplicas = in.V1Beta2.ReadyReplicas + out.AvailableReplicas = in.V1Beta2.AvailableReplicas + out.UpToDateReplicas = in.V1Beta2.UpToDateReplicas + } + + // Move legacy conditions (v1beta1) to the deprecated field. + if out.Deprecated == nil { + out.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} + } + if in.Conditions != nil { + Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + } + out.Deprecated.V1Beta1.AvailableReplicas = in.AvailableReplicas + out.Deprecated.V1Beta1.FullyLabeledReplicas = in.FullyLabeledReplicas + out.Deprecated.V1Beta1.ReadyReplicas = in.ReadyReplicas + out.Deprecated.V1Beta1.FailureReason = in.FailureReason + out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage + return nil +} + +func Convert_v1beta2_MachineStatus_To_v1beta1_MachineStatus(in *clusterv1.MachineStatus, out *MachineStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta2_MachineStatus_To_v1beta1_MachineStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). + out.Conditions = nil + + // Retrieve legacy conditions (v1beta1) from the deprecated field. + if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { + if in.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + } + } + + // Move new conditions (v1beta2) to the v1beta2 field. + if in.Conditions == nil { + return nil + } + out.V1Beta2 = &MachineV1Beta2Status{} + out.V1Beta2.Conditions = in.Conditions + return nil +} + +func Convert_v1beta1_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, out *clusterv1.MachineStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta1_MachineStatus_To_v1beta2_MachineStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. + out.Conditions = nil + + // Retrieve new conditions (v1beta2) from the v1beta2 field. + if in.V1Beta2 != nil { + out.Conditions = in.V1Beta2.Conditions + } + + // Move legacy conditions (v1beta1) to the deprecated field. + if in.Conditions == nil { + return nil + } + + if out.Deprecated == nil { + out.Deprecated = &clusterv1.MachineDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + } + if in.Conditions != nil { + Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + } + return nil +} + +func Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(in *clusterv1.Conditions, out *Conditions) { + *out = make(Conditions, len(*in)) + for i := range *in { + (*out)[i] = *(*Condition)(unsafe.Pointer(&(*in)[i])) + } +} + +func Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(in *Conditions, out *clusterv1.Conditions) { + *out = make(clusterv1.Conditions, len(*in)) + for i := range *in { + (*out)[i] = *(*clusterv1.Condition)(unsafe.Pointer(&(*in)[i])) + } +} + +func Convert_v1_Condition_To_v1beta1_Condition(_ *metav1.Condition, _ *Condition, _ apimachineryconversion.Scope) error { + // NOTE: v1beta2 conditions should not be automatically converted into legacy (v1beta1) conditions. + return nil +} + +func Convert_v1beta1_Condition_To_v1_Condition(_ *Condition, _ *metav1.Condition, _ apimachineryconversion.Scope) error { + // NOTE: legacy (v1beta1) conditions should not be automatically converted into v1beta2 conditions. + return nil +} diff --git a/api/v1beta1/conversion_test.go b/api/v1beta1/conversion_test.go index 2a72e65ebfe6..6693656ed1c6 100644 --- a/api/v1beta1/conversion_test.go +++ b/api/v1beta1/conversion_test.go @@ -22,9 +22,11 @@ import ( "strconv" "testing" + "github.com/google/go-cmp/cmp" fuzz "github.com/google/gofuzz" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/utils/ptr" @@ -38,45 +40,82 @@ func TestFuzzyConversion(t *testing.T) { t.Run("for Cluster", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.Cluster{}, Spoke: &Cluster{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{ClusterFuzzFuncs}, })) t.Run("for ClusterClass", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.ClusterClass{}, Spoke: &ClusterClass{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{ClusterClassJSONFuzzFuncs}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{ClusterClassFuncs}, })) t.Run("for Machine", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.Machine{}, Spoke: &Machine{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineFuzzFuncs}, })) - t.Run("for MachineSet", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.MachineSet{}, Spoke: &MachineSet{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineSetFuzzFuncs}, })) - t.Run("for MachineDeployment", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.MachineDeployment{}, Spoke: &MachineDeployment{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineDeploymentFuzzFuncs}, })) - t.Run("for MachineHealthCheck", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Hub: &clusterv1.MachineHealthCheck{}, - Spoke: &MachineHealthCheck{}, + Hub: &clusterv1.MachineHealthCheck{}, + Spoke: &MachineHealthCheck{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineHealthCheckFuzzFuncs}, })) } -func ClusterClassJSONFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { +func ClusterFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - JSONSchemaPropsFuzzer, - JSONSchemaPropsFuzzerV1beta1, + hubClusterStatus, + spokeClusterStatus, + } +} + +func hubClusterStatus(in *clusterv1.ClusterStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || (in.Deprecated.V1Beta1.Conditions == nil && in.Deprecated.V1Beta1.FailureReason == nil && in.Deprecated.V1Beta1.FailureMessage == nil) { + in.Deprecated = nil + } } } -func JSONSchemaPropsFuzzer(in *clusterv1.JSONSchemaProps, c fuzz.Continue) { +func spokeClusterStatus(in *ClusterStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.V1Beta2 != nil { + if in.V1Beta2.Conditions == nil && in.V1Beta2.ControlPlane == nil && in.V1Beta2.Workers == nil { + in.V1Beta2 = nil + } + } +} + +func ClusterClassFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubClusterClassStatus, + hubJSONSchemaProps, + spokeClusterClassStatus, + spokeJSONSchemaProps, + } +} + +func hubClusterClassStatus(in *clusterv1.ClusterClassStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + in.Deprecated = nil + } + } +} + +func hubJSONSchemaProps(in *clusterv1.JSONSchemaProps, c fuzz.Continue) { // NOTE: We have to fuzz the individual fields manually, // because we cannot call `FuzzNoCustom` as it would lead // to an infinite recursion. @@ -119,7 +158,17 @@ func JSONSchemaPropsFuzzer(in *clusterv1.JSONSchemaProps, c fuzz.Continue) { in.Items = in2 } -func JSONSchemaPropsFuzzerV1beta1(in *JSONSchemaProps, c fuzz.Continue) { +func spokeClusterClassStatus(in *ClusterClassStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.V1Beta2 != nil { + if in.V1Beta2.Conditions == nil { + in.V1Beta2 = nil + } + } +} + +func spokeJSONSchemaProps(in *JSONSchemaProps, c fuzz.Continue) { // NOTE: We have to fuzz the individual fields manually, // because we cannot call `FuzzNoCustom` as it would lead // to an infinite recursion. @@ -161,3 +210,253 @@ func JSONSchemaPropsFuzzerV1beta1(in *JSONSchemaProps, c fuzz.Continue) { } in.Items = in2 } + +func MachineFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubMachineStatus, + spokeMachineStatus, + } +} + +func hubMachineStatus(in *clusterv1.MachineStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || (in.Deprecated.V1Beta1.Conditions == nil && in.Deprecated.V1Beta1.FailureReason == nil && in.Deprecated.V1Beta1.FailureMessage == nil) { + in.Deprecated = nil + } + } +} + +func spokeMachineStatus(in *MachineStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.V1Beta2 != nil { + if in.V1Beta2.Conditions == nil { + in.V1Beta2 = nil + } + } +} + +func MachineSetFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubMachineSetStatus, + spokeMachineSetStatus, + } +} + +func hubMachineSetStatus(in *clusterv1.MachineSetStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} + } +} + +func spokeMachineSetStatus(in *MachineSetStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.V1Beta2 != nil { + if in.V1Beta2.Conditions == nil && in.V1Beta2.ReadyReplicas == nil && in.V1Beta2.AvailableReplicas == nil && in.V1Beta2.UpToDateReplicas == nil { + in.V1Beta2 = nil + } + } +} + +func MachineDeploymentFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubMachineDeploymentStatus, + spokeMachineDeploymentStatus, + } +} + +func hubMachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &clusterv1.MachineDeploymentDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{} + } +} + +func spokeMachineDeploymentStatus(in *MachineDeploymentStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.V1Beta2 != nil { + if in.V1Beta2.Conditions == nil && in.V1Beta2.ReadyReplicas == nil && in.V1Beta2.AvailableReplicas == nil && in.V1Beta2.UpToDateReplicas == nil { + in.V1Beta2 = nil + } + } +} + +func MachineHealthCheckFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubMachineHealthCheckStatus, + spokeMachineHealthCheckStatus, + } +} + +func hubMachineHealthCheckStatus(in *clusterv1.MachineHealthCheckStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + in.Deprecated = nil + } + } +} + +func spokeMachineHealthCheckStatus(in *MachineHealthCheckStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.V1Beta2 != nil { + if in.V1Beta2.Conditions == nil { + in.V1Beta2 = nil + } + } +} + +// FIXME: remove test below + +func TestHubSpokeHubCluster(t *testing.T) { + hubBefore := &clusterv1.Cluster{ + Status: clusterv1.ClusterStatus{ + Conditions: []metav1.Condition{ + { + Type: "v1beta2 Condition", + }, + }, + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + { + Type: "v1beta1 Condition", + }, + }, + }, + }, + }, + } + + spoke := &Cluster{} + spoke.ConvertFrom(hubBefore) + hubAfter := &clusterv1.Cluster{} + spoke.ConvertTo(hubAfter) + + hubAfter.Annotations = nil + + if d := cmp.Diff(hubBefore, hubAfter); d != "" { + t.Errorf("-want, +got:\n%s", d) + } +} + +func TestSpokeHubSpokeCluster(t *testing.T) { + spokeBefore := &Cluster{ + Status: ClusterStatus{ + Conditions: []Condition{ + { + Type: "v1beta1 Condition", + }, + }, + V1Beta2: &ClusterV1Beta2Status{ + Conditions: []metav1.Condition{ + { + Type: "v1beta2 Condition", + }, + }, + }, + }, + } + + hub := &clusterv1.Cluster{} + spokeBefore.ConvertTo(hub) + spokeAfter := &Cluster{} + spokeAfter.ConvertFrom(hub) + + spokeAfter.Annotations = nil + + if d := cmp.Diff(spokeBefore, spokeAfter); d != "" { + t.Errorf("-want, +got:\n%s", d) + } +} + +func TestHubSpokeHubMachineDeployment(t *testing.T) { + hubBefore := &clusterv1.MachineDeployment{ + Status: clusterv1.MachineDeploymentStatus{ + Conditions: []metav1.Condition{ + { + Type: "v1beta2 Condition", + }, + }, + ReadyReplicas: ptr.To[int32](11), + AvailableReplicas: ptr.To[int32](12), + UpToDateReplicas: ptr.To[int32](13), + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + { + Type: "v1beta1 Condition", + }, + }, + UpdatedReplicas: 1, + ReadyReplicas: 2, + AvailableReplicas: 3, + UnavailableReplicas: 4, + }, + }, + }, + } + + spoke := &MachineDeployment{} + spoke.ConvertFrom(hubBefore) + hubAfter := &clusterv1.MachineDeployment{} + spoke.ConvertTo(hubAfter) + + hubAfter.Annotations = nil + + if d := cmp.Diff(hubBefore, hubAfter); d != "" { + t.Errorf("-want, +got:\n%s", d) + } +} + +func TestSpokeHubSpokeMachineDeployment(t *testing.T) { + spokeBefore := &MachineDeployment{ + Status: MachineDeploymentStatus{ + Conditions: []Condition{ + { + Type: "v1beta1 Condition", + }, + }, + UpdatedReplicas: 1, + ReadyReplicas: 2, + AvailableReplicas: 3, + UnavailableReplicas: 4, + V1Beta2: &MachineDeploymentV1Beta2Status{ + Conditions: []metav1.Condition{ + { + Type: "v1beta2 Condition", + }, + }, + ReadyReplicas: ptr.To[int32](11), + AvailableReplicas: ptr.To[int32](12), + UpToDateReplicas: ptr.To[int32](13), + }, + }, + } + + hub := &clusterv1.MachineDeployment{} + spokeBefore.ConvertTo(hub) + spokeAfter := &MachineDeployment{} + spokeAfter.ConvertFrom(hub) + + spokeAfter.Annotations = nil + + if d := cmp.Diff(spokeBefore, spokeAfter); d != "" { + t.Errorf("-want, +got:\n%s", d) + } +} diff --git a/api/v1beta1/machine_types.go b/api/v1beta1/machine_types.go index 6c0f471decca..1e352d9a8dd0 100644 --- a/api/v1beta1/machine_types.go +++ b/api/v1beta1/machine_types.go @@ -527,7 +527,7 @@ type MachineStatus struct { // can be added as events to the Machine object and/or logged in the // controller's output. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional FailureReason *capierrors.MachineStatusError `json:"failureReason,omitempty"` @@ -549,7 +549,7 @@ type MachineStatus struct { // can be added as events to the Machine object and/or logged in the // controller's output. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional // +kubebuilder:validation:MinLength=1 diff --git a/api/v1beta1/machinedeployment_types.go b/api/v1beta1/machinedeployment_types.go index cf567d37ade5..6becfba6263a 100644 --- a/api/v1beta1/machinedeployment_types.go +++ b/api/v1beta1/machinedeployment_types.go @@ -488,7 +488,7 @@ type MachineDeploymentStatus struct { // be machines that are running but not yet available or machines // that still have not been created. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional UnavailableReplicas int32 `json:"unavailableReplicas"` diff --git a/api/v1beta1/machineset_types.go b/api/v1beta1/machineset_types.go index 8d19ed8677df..df5e2746ffab 100644 --- a/api/v1beta1/machineset_types.go +++ b/api/v1beta1/machineset_types.go @@ -297,7 +297,7 @@ type MachineSetStatus struct { // fullyLabeledReplicas is the number of replicas that have labels matching the labels of the machine template of the MachineSet. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional FullyLabeledReplicas int32 `json:"fullyLabeledReplicas"` @@ -337,7 +337,7 @@ type MachineSetStatus struct { // can be added as events to the MachineSet object and/or logged in the // controller's output. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional FailureReason *capierrors.MachineSetStatusError `json:"failureReason,omitempty"` @@ -346,7 +346,7 @@ type MachineSetStatus struct { // reconciling the Machine and will contain a more verbose string suitable // for logging and human consumption. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional // +kubebuilder:validation:MinLength=1 diff --git a/api/v1beta1/zz_generated.conversion.go b/api/v1beta1/zz_generated.conversion.go index 1d54363918a8..8d7457a4d3b2 100644 --- a/api/v1beta1/zz_generated.conversion.go +++ b/api/v1beta1/zz_generated.conversion.go @@ -24,14 +24,13 @@ package v1beta1 import ( unsafe "unsafe" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" intstr "k8s.io/apimachinery/pkg/util/intstr" v1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" - errors "sigs.k8s.io/cluster-api/errors" ) func init() { @@ -121,16 +120,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*ClusterClassStatus)(nil), (*v1beta2.ClusterClassStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_ClusterClassStatus_To_v1beta2_ClusterClassStatus(a.(*ClusterClassStatus), b.(*v1beta2.ClusterClassStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.ClusterClassStatus)(nil), (*ClusterClassStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ClusterClassStatus_To_v1beta1_ClusterClassStatus(a.(*v1beta2.ClusterClassStatus), b.(*ClusterClassStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*ClusterClassStatusVariable)(nil), (*v1beta2.ClusterClassStatusVariable)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_ClusterClassStatusVariable_To_v1beta2_ClusterClassStatusVariable(a.(*ClusterClassStatusVariable), b.(*v1beta2.ClusterClassStatusVariable), scope) }); err != nil { @@ -151,16 +140,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*ClusterClassV1Beta2Status)(nil), (*v1beta2.ClusterClassV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_ClusterClassV1Beta2Status_To_v1beta2_ClusterClassV1Beta2Status(a.(*ClusterClassV1Beta2Status), b.(*v1beta2.ClusterClassV1Beta2Status), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.ClusterClassV1Beta2Status)(nil), (*ClusterClassV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ClusterClassV1Beta2Status_To_v1beta1_ClusterClassV1Beta2Status(a.(*v1beta2.ClusterClassV1Beta2Status), b.(*ClusterClassV1Beta2Status), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*ClusterClassVariable)(nil), (*v1beta2.ClusterClassVariable)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_ClusterClassVariable_To_v1beta2_ClusterClassVariable(a.(*ClusterClassVariable), b.(*v1beta2.ClusterClassVariable), scope) }); err != nil { @@ -221,26 +200,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*ClusterStatus)(nil), (*v1beta2.ClusterStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_ClusterStatus_To_v1beta2_ClusterStatus(a.(*ClusterStatus), b.(*v1beta2.ClusterStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.ClusterStatus)(nil), (*ClusterStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ClusterStatus_To_v1beta1_ClusterStatus(a.(*v1beta2.ClusterStatus), b.(*ClusterStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*ClusterV1Beta2Status)(nil), (*v1beta2.ClusterV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_ClusterV1Beta2Status_To_v1beta2_ClusterV1Beta2Status(a.(*ClusterV1Beta2Status), b.(*v1beta2.ClusterV1Beta2Status), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.ClusterV1Beta2Status)(nil), (*ClusterV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ClusterV1Beta2Status_To_v1beta1_ClusterV1Beta2Status(a.(*v1beta2.ClusterV1Beta2Status), b.(*ClusterV1Beta2Status), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*ClusterVariable)(nil), (*v1beta2.ClusterVariable)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_ClusterVariable_To_v1beta2_ClusterVariable(a.(*ClusterVariable), b.(*v1beta2.ClusterVariable), scope) }); err != nil { @@ -461,16 +420,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachineDeploymentStatus)(nil), (*v1beta2.MachineDeploymentStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(a.(*MachineDeploymentStatus), b.(*v1beta2.MachineDeploymentStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.MachineDeploymentStatus)(nil), (*MachineDeploymentStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_MachineDeploymentStatus_To_v1beta1_MachineDeploymentStatus(a.(*v1beta2.MachineDeploymentStatus), b.(*MachineDeploymentStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*MachineDeploymentStrategy)(nil), (*v1beta2.MachineDeploymentStrategy)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_MachineDeploymentStrategy_To_v1beta2_MachineDeploymentStrategy(a.(*MachineDeploymentStrategy), b.(*v1beta2.MachineDeploymentStrategy), scope) }); err != nil { @@ -491,16 +440,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachineDeploymentV1Beta2Status)(nil), (*v1beta2.MachineDeploymentV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_MachineDeploymentV1Beta2Status_To_v1beta2_MachineDeploymentV1Beta2Status(a.(*MachineDeploymentV1Beta2Status), b.(*v1beta2.MachineDeploymentV1Beta2Status), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.MachineDeploymentV1Beta2Status)(nil), (*MachineDeploymentV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_MachineDeploymentV1Beta2Status_To_v1beta1_MachineDeploymentV1Beta2Status(a.(*v1beta2.MachineDeploymentV1Beta2Status), b.(*MachineDeploymentV1Beta2Status), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*MachineDeploymentVariables)(nil), (*v1beta2.MachineDeploymentVariables)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_MachineDeploymentVariables_To_v1beta2_MachineDeploymentVariables(a.(*MachineDeploymentVariables), b.(*v1beta2.MachineDeploymentVariables), scope) }); err != nil { @@ -611,16 +550,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachineHealthCheckStatus)(nil), (*v1beta2.MachineHealthCheckStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheckStatus(a.(*MachineHealthCheckStatus), b.(*v1beta2.MachineHealthCheckStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.MachineHealthCheckStatus)(nil), (*MachineHealthCheckStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_MachineHealthCheckStatus_To_v1beta1_MachineHealthCheckStatus(a.(*v1beta2.MachineHealthCheckStatus), b.(*MachineHealthCheckStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*MachineHealthCheckTopology)(nil), (*v1beta2.MachineHealthCheckTopology)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_MachineHealthCheckTopology_To_v1beta2_MachineHealthCheckTopology(a.(*MachineHealthCheckTopology), b.(*v1beta2.MachineHealthCheckTopology), scope) }); err != nil { @@ -631,16 +560,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachineHealthCheckV1Beta2Status)(nil), (*v1beta2.MachineHealthCheckV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_MachineHealthCheckV1Beta2Status_To_v1beta2_MachineHealthCheckV1Beta2Status(a.(*MachineHealthCheckV1Beta2Status), b.(*v1beta2.MachineHealthCheckV1Beta2Status), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.MachineHealthCheckV1Beta2Status)(nil), (*MachineHealthCheckV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_MachineHealthCheckV1Beta2Status_To_v1beta1_MachineHealthCheckV1Beta2Status(a.(*v1beta2.MachineHealthCheckV1Beta2Status), b.(*MachineHealthCheckV1Beta2Status), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*MachineList)(nil), (*v1beta2.MachineList)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_MachineList_To_v1beta2_MachineList(a.(*MachineList), b.(*v1beta2.MachineList), scope) }); err != nil { @@ -761,26 +680,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachineSetStatus)(nil), (*v1beta2.MachineSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_MachineSetStatus_To_v1beta2_MachineSetStatus(a.(*MachineSetStatus), b.(*v1beta2.MachineSetStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.MachineSetStatus)(nil), (*MachineSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_MachineSetStatus_To_v1beta1_MachineSetStatus(a.(*v1beta2.MachineSetStatus), b.(*MachineSetStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*MachineSetV1Beta2Status)(nil), (*v1beta2.MachineSetV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_MachineSetV1Beta2Status_To_v1beta2_MachineSetV1Beta2Status(a.(*MachineSetV1Beta2Status), b.(*v1beta2.MachineSetV1Beta2Status), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.MachineSetV1Beta2Status)(nil), (*MachineSetV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_MachineSetV1Beta2Status_To_v1beta1_MachineSetV1Beta2Status(a.(*v1beta2.MachineSetV1Beta2Status), b.(*MachineSetV1Beta2Status), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*MachineSpec)(nil), (*v1beta2.MachineSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_MachineSpec_To_v1beta2_MachineSpec(a.(*MachineSpec), b.(*v1beta2.MachineSpec), scope) }); err != nil { @@ -791,16 +690,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachineStatus)(nil), (*v1beta2.MachineStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_MachineStatus_To_v1beta2_MachineStatus(a.(*MachineStatus), b.(*v1beta2.MachineStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.MachineStatus)(nil), (*MachineStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_MachineStatus_To_v1beta1_MachineStatus(a.(*v1beta2.MachineStatus), b.(*MachineStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*MachineTemplateSpec)(nil), (*v1beta2.MachineTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_MachineTemplateSpec_To_v1beta2_MachineTemplateSpec(a.(*MachineTemplateSpec), b.(*v1beta2.MachineTemplateSpec), scope) }); err != nil { @@ -811,16 +700,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachineV1Beta2Status)(nil), (*v1beta2.MachineV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_MachineV1Beta2Status_To_v1beta2_MachineV1Beta2Status(a.(*MachineV1Beta2Status), b.(*v1beta2.MachineV1Beta2Status), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.MachineV1Beta2Status)(nil), (*MachineV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_MachineV1Beta2Status_To_v1beta1_MachineV1Beta2Status(a.(*v1beta2.MachineV1Beta2Status), b.(*MachineV1Beta2Status), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*NetworkRanges)(nil), (*v1beta2.NetworkRanges)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_NetworkRanges_To_v1beta2_NetworkRanges(a.(*NetworkRanges), b.(*v1beta2.NetworkRanges), scope) }); err != nil { @@ -981,6 +860,76 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1.Condition)(nil), (*Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1beta1_Condition(a.(*v1.Condition), b.(*Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*ClusterClassStatus)(nil), (*v1beta2.ClusterClassStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_ClusterClassStatus_To_v1beta2_ClusterClassStatus(a.(*ClusterClassStatus), b.(*v1beta2.ClusterClassStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*ClusterStatus)(nil), (*v1beta2.ClusterStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_ClusterStatus_To_v1beta2_ClusterStatus(a.(*ClusterStatus), b.(*v1beta2.ClusterStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_Condition_To_v1_Condition(a.(*Condition), b.(*v1.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*MachineDeploymentStatus)(nil), (*v1beta2.MachineDeploymentStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(a.(*MachineDeploymentStatus), b.(*v1beta2.MachineDeploymentStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*MachineHealthCheckStatus)(nil), (*v1beta2.MachineHealthCheckStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheckStatus(a.(*MachineHealthCheckStatus), b.(*v1beta2.MachineHealthCheckStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*MachineSetStatus)(nil), (*v1beta2.MachineSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_MachineSetStatus_To_v1beta2_MachineSetStatus(a.(*MachineSetStatus), b.(*v1beta2.MachineSetStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*MachineStatus)(nil), (*v1beta2.MachineStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_MachineStatus_To_v1beta2_MachineStatus(a.(*MachineStatus), b.(*v1beta2.MachineStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta2.ClusterClassStatus)(nil), (*ClusterClassStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_ClusterClassStatus_To_v1beta1_ClusterClassStatus(a.(*v1beta2.ClusterClassStatus), b.(*ClusterClassStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta2.ClusterStatus)(nil), (*ClusterStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_ClusterStatus_To_v1beta1_ClusterStatus(a.(*v1beta2.ClusterStatus), b.(*ClusterStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta2.MachineDeploymentStatus)(nil), (*MachineDeploymentStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_MachineDeploymentStatus_To_v1beta1_MachineDeploymentStatus(a.(*v1beta2.MachineDeploymentStatus), b.(*MachineDeploymentStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta2.MachineHealthCheckStatus)(nil), (*MachineHealthCheckStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_MachineHealthCheckStatus_To_v1beta1_MachineHealthCheckStatus(a.(*v1beta2.MachineHealthCheckStatus), b.(*MachineHealthCheckStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta2.MachineSetStatus)(nil), (*MachineSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_MachineSetStatus_To_v1beta1_MachineSetStatus(a.(*v1beta2.MachineSetStatus), b.(*MachineSetStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta2.MachineStatus)(nil), (*MachineStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_MachineStatus_To_v1beta1_MachineStatus(a.(*v1beta2.MachineStatus), b.(*MachineStatus), scope) + }); err != nil { + return err + } return nil } @@ -1007,7 +956,7 @@ func Convert_v1beta2_APIEndpoint_To_v1beta1_APIEndpoint(in *v1beta2.APIEndpoint, } func autoConvert_v1beta1_Bootstrap_To_v1beta2_Bootstrap(in *Bootstrap, out *v1beta2.Bootstrap, s conversion.Scope) error { - out.ConfigRef = (*v1.ObjectReference)(unsafe.Pointer(in.ConfigRef)) + out.ConfigRef = (*corev1.ObjectReference)(unsafe.Pointer(in.ConfigRef)) out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) return nil } @@ -1018,7 +967,7 @@ func Convert_v1beta1_Bootstrap_To_v1beta2_Bootstrap(in *Bootstrap, out *v1beta2. } func autoConvert_v1beta2_Bootstrap_To_v1beta1_Bootstrap(in *v1beta2.Bootstrap, out *Bootstrap, s conversion.Scope) error { - out.ConfigRef = (*v1.ObjectReference)(unsafe.Pointer(in.ConfigRef)) + out.ConfigRef = (*corev1.ObjectReference)(unsafe.Pointer(in.ConfigRef)) out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) return nil } @@ -1116,7 +1065,17 @@ func Convert_v1beta2_ClusterClass_To_v1beta1_ClusterClass(in *v1beta2.ClusterCla func autoConvert_v1beta1_ClusterClassList_To_v1beta2_ClusterClassList(in *ClusterClassList, out *v1beta2.ClusterClassList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1beta2.ClusterClass)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.ClusterClass, len(*in)) + for i := range *in { + if err := Convert_v1beta1_ClusterClass_To_v1beta2_ClusterClass(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -1127,7 +1086,17 @@ func Convert_v1beta1_ClusterClassList_To_v1beta2_ClusterClassList(in *ClusterCla func autoConvert_v1beta2_ClusterClassList_To_v1beta1_ClusterClassList(in *v1beta2.ClusterClassList, out *ClusterClassList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]ClusterClass)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterClass, len(*in)) + for i := range *in { + if err := Convert_v1beta2_ClusterClass_To_v1beta1_ClusterClass(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -1210,30 +1179,40 @@ func Convert_v1beta2_ClusterClassSpec_To_v1beta1_ClusterClassSpec(in *v1beta2.Cl func autoConvert_v1beta1_ClusterClassStatus_To_v1beta2_ClusterClassStatus(in *ClusterClassStatus, out *v1beta2.ClusterClassStatus, s conversion.Scope) error { out.Variables = *(*[]v1beta2.ClusterClassStatusVariable)(unsafe.Pointer(&in.Variables)) - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.ObservedGeneration = in.ObservedGeneration - out.V1Beta2 = (*v1beta2.ClusterClassV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_ClusterClassStatus_To_v1beta2_ClusterClassStatus is an autogenerated conversion function. -func Convert_v1beta1_ClusterClassStatus_To_v1beta2_ClusterClassStatus(in *ClusterClassStatus, out *v1beta2.ClusterClassStatus, s conversion.Scope) error { - return autoConvert_v1beta1_ClusterClassStatus_To_v1beta2_ClusterClassStatus(in, out, s) -} - func autoConvert_v1beta2_ClusterClassStatus_To_v1beta1_ClusterClassStatus(in *v1beta2.ClusterClassStatus, out *ClusterClassStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1beta1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.Variables = *(*[]ClusterClassStatusVariable)(unsafe.Pointer(&in.Variables)) - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) out.ObservedGeneration = in.ObservedGeneration - out.V1Beta2 = (*ClusterClassV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta2_ClusterClassStatus_To_v1beta1_ClusterClassStatus is an autogenerated conversion function. -func Convert_v1beta2_ClusterClassStatus_To_v1beta1_ClusterClassStatus(in *v1beta2.ClusterClassStatus, out *ClusterClassStatus, s conversion.Scope) error { - return autoConvert_v1beta2_ClusterClassStatus_To_v1beta1_ClusterClassStatus(in, out, s) -} - func autoConvert_v1beta1_ClusterClassStatusVariable_To_v1beta2_ClusterClassStatusVariable(in *ClusterClassStatusVariable, out *v1beta2.ClusterClassStatusVariable, s conversion.Scope) error { out.Name = in.Name out.DefinitionsConflict = in.DefinitionsConflict @@ -1292,26 +1271,6 @@ func Convert_v1beta2_ClusterClassStatusVariableDefinition_To_v1beta1_ClusterClas return autoConvert_v1beta2_ClusterClassStatusVariableDefinition_To_v1beta1_ClusterClassStatusVariableDefinition(in, out, s) } -func autoConvert_v1beta1_ClusterClassV1Beta2Status_To_v1beta2_ClusterClassV1Beta2Status(in *ClusterClassV1Beta2Status, out *v1beta2.ClusterClassV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta1_ClusterClassV1Beta2Status_To_v1beta2_ClusterClassV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta1_ClusterClassV1Beta2Status_To_v1beta2_ClusterClassV1Beta2Status(in *ClusterClassV1Beta2Status, out *v1beta2.ClusterClassV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta1_ClusterClassV1Beta2Status_To_v1beta2_ClusterClassV1Beta2Status(in, out, s) -} - -func autoConvert_v1beta2_ClusterClassV1Beta2Status_To_v1beta1_ClusterClassV1Beta2Status(in *v1beta2.ClusterClassV1Beta2Status, out *ClusterClassV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta2_ClusterClassV1Beta2Status_To_v1beta1_ClusterClassV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta2_ClusterClassV1Beta2Status_To_v1beta1_ClusterClassV1Beta2Status(in *v1beta2.ClusterClassV1Beta2Status, out *ClusterClassV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta2_ClusterClassV1Beta2Status_To_v1beta1_ClusterClassV1Beta2Status(in, out, s) -} - func autoConvert_v1beta1_ClusterClassVariable_To_v1beta2_ClusterClassVariable(in *ClusterClassVariable, out *v1beta2.ClusterClassVariable, s conversion.Scope) error { out.Name = in.Name out.Required = in.Required @@ -1398,7 +1357,17 @@ func Convert_v1beta2_ClusterControlPlaneStatus_To_v1beta1_ClusterControlPlaneSta func autoConvert_v1beta1_ClusterList_To_v1beta2_ClusterList(in *ClusterList, out *v1beta2.ClusterList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1beta2.Cluster)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.Cluster, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Cluster_To_v1beta2_Cluster(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -1409,7 +1378,17 @@ func Convert_v1beta1_ClusterList_To_v1beta2_ClusterList(in *ClusterList, out *v1 func autoConvert_v1beta2_ClusterList_To_v1beta1_ClusterList(in *v1beta2.ClusterList, out *ClusterList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]Cluster)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Cluster, len(*in)) + for i := range *in { + if err := Convert_v1beta2_Cluster_To_v1beta1_Cluster(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -1450,8 +1429,8 @@ func autoConvert_v1beta1_ClusterSpec_To_v1beta2_ClusterSpec(in *ClusterSpec, out if err := Convert_v1beta1_APIEndpoint_To_v1beta2_APIEndpoint(&in.ControlPlaneEndpoint, &out.ControlPlaneEndpoint, s); err != nil { return err } - out.ControlPlaneRef = (*v1.ObjectReference)(unsafe.Pointer(in.ControlPlaneRef)) - out.InfrastructureRef = (*v1.ObjectReference)(unsafe.Pointer(in.InfrastructureRef)) + out.ControlPlaneRef = (*corev1.ObjectReference)(unsafe.Pointer(in.ControlPlaneRef)) + out.InfrastructureRef = (*corev1.ObjectReference)(unsafe.Pointer(in.InfrastructureRef)) out.Topology = (*v1beta2.Topology)(unsafe.Pointer(in.Topology)) out.AvailabilityGates = *(*[]v1beta2.ClusterAvailabilityGate)(unsafe.Pointer(&in.AvailabilityGates)) return nil @@ -1468,8 +1447,8 @@ func autoConvert_v1beta2_ClusterSpec_To_v1beta1_ClusterSpec(in *v1beta2.ClusterS if err := Convert_v1beta2_APIEndpoint_To_v1beta1_APIEndpoint(&in.ControlPlaneEndpoint, &out.ControlPlaneEndpoint, s); err != nil { return err } - out.ControlPlaneRef = (*v1.ObjectReference)(unsafe.Pointer(in.ControlPlaneRef)) - out.InfrastructureRef = (*v1.ObjectReference)(unsafe.Pointer(in.InfrastructureRef)) + out.ControlPlaneRef = (*corev1.ObjectReference)(unsafe.Pointer(in.ControlPlaneRef)) + out.InfrastructureRef = (*corev1.ObjectReference)(unsafe.Pointer(in.InfrastructureRef)) out.Topology = (*Topology)(unsafe.Pointer(in.Topology)) out.AvailabilityGates = *(*[]ClusterAvailabilityGate)(unsafe.Pointer(&in.AvailabilityGates)) return nil @@ -1482,64 +1461,50 @@ func Convert_v1beta2_ClusterSpec_To_v1beta1_ClusterSpec(in *v1beta2.ClusterSpec, func autoConvert_v1beta1_ClusterStatus_To_v1beta2_ClusterStatus(in *ClusterStatus, out *v1beta2.ClusterStatus, s conversion.Scope) error { out.FailureDomains = *(*v1beta2.FailureDomains)(unsafe.Pointer(&in.FailureDomains)) - out.FailureReason = (*errors.ClusterStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.Phase = in.Phase out.InfrastructureReady = in.InfrastructureReady out.ControlPlaneReady = in.ControlPlaneReady - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.ObservedGeneration = in.ObservedGeneration - out.V1Beta2 = (*v1beta2.ClusterV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_ClusterStatus_To_v1beta2_ClusterStatus is an autogenerated conversion function. -func Convert_v1beta1_ClusterStatus_To_v1beta2_ClusterStatus(in *ClusterStatus, out *v1beta2.ClusterStatus, s conversion.Scope) error { - return autoConvert_v1beta1_ClusterStatus_To_v1beta2_ClusterStatus(in, out, s) -} - func autoConvert_v1beta2_ClusterStatus_To_v1beta1_ClusterStatus(in *v1beta2.ClusterStatus, out *ClusterStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1beta1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + // WARNING: in.ControlPlane requires manual conversion: does not exist in peer-type + // WARNING: in.Workers requires manual conversion: does not exist in peer-type out.FailureDomains = *(*FailureDomains)(unsafe.Pointer(&in.FailureDomains)) - out.FailureReason = (*errors.ClusterStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) out.Phase = in.Phase out.InfrastructureReady = in.InfrastructureReady out.ControlPlaneReady = in.ControlPlaneReady - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) out.ObservedGeneration = in.ObservedGeneration - out.V1Beta2 = (*ClusterV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) - return nil -} - -// Convert_v1beta2_ClusterStatus_To_v1beta1_ClusterStatus is an autogenerated conversion function. -func Convert_v1beta2_ClusterStatus_To_v1beta1_ClusterStatus(in *v1beta2.ClusterStatus, out *ClusterStatus, s conversion.Scope) error { - return autoConvert_v1beta2_ClusterStatus_To_v1beta1_ClusterStatus(in, out, s) -} - -func autoConvert_v1beta1_ClusterV1Beta2Status_To_v1beta2_ClusterV1Beta2Status(in *ClusterV1Beta2Status, out *v1beta2.ClusterV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - out.ControlPlane = (*v1beta2.ClusterControlPlaneStatus)(unsafe.Pointer(in.ControlPlane)) - out.Workers = (*v1beta2.WorkersStatus)(unsafe.Pointer(in.Workers)) - return nil -} - -// Convert_v1beta1_ClusterV1Beta2Status_To_v1beta2_ClusterV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta1_ClusterV1Beta2Status_To_v1beta2_ClusterV1Beta2Status(in *ClusterV1Beta2Status, out *v1beta2.ClusterV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta1_ClusterV1Beta2Status_To_v1beta2_ClusterV1Beta2Status(in, out, s) -} - -func autoConvert_v1beta2_ClusterV1Beta2Status_To_v1beta1_ClusterV1Beta2Status(in *v1beta2.ClusterV1Beta2Status, out *ClusterV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - out.ControlPlane = (*ClusterControlPlaneStatus)(unsafe.Pointer(in.ControlPlane)) - out.Workers = (*WorkersStatus)(unsafe.Pointer(in.Workers)) + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta2_ClusterV1Beta2Status_To_v1beta1_ClusterV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta2_ClusterV1Beta2Status_To_v1beta1_ClusterV1Beta2Status(in *v1beta2.ClusterV1Beta2Status, out *ClusterV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta2_ClusterV1Beta2Status_To_v1beta1_ClusterV1Beta2Status(in, out, s) -} - func autoConvert_v1beta1_ClusterVariable_To_v1beta2_ClusterVariable(in *ClusterVariable, out *v1beta2.ClusterVariable, s conversion.Scope) error { out.Name = in.Name out.DefinitionFrom = in.DefinitionFrom @@ -1566,7 +1531,7 @@ func Convert_v1beta2_ClusterVariable_To_v1beta1_ClusterVariable(in *v1beta2.Clus func autoConvert_v1beta1_Condition_To_v1beta2_Condition(in *Condition, out *v1beta2.Condition, s conversion.Scope) error { out.Type = v1beta2.ConditionType(in.Type) - out.Status = v1.ConditionStatus(in.Status) + out.Status = corev1.ConditionStatus(in.Status) out.Severity = v1beta2.ConditionSeverity(in.Severity) out.LastTransitionTime = in.LastTransitionTime out.Reason = in.Reason @@ -1581,7 +1546,7 @@ func Convert_v1beta1_Condition_To_v1beta2_Condition(in *Condition, out *v1beta2. func autoConvert_v1beta2_Condition_To_v1beta1_Condition(in *v1beta2.Condition, out *Condition, s conversion.Scope) error { out.Type = ConditionType(in.Type) - out.Status = v1.ConditionStatus(in.Status) + out.Status = corev1.ConditionStatus(in.Status) out.Severity = ConditionSeverity(in.Severity) out.LastTransitionTime = in.LastTransitionTime out.Reason = in.Reason @@ -1604,9 +1569,9 @@ func autoConvert_v1beta1_ControlPlaneClass_To_v1beta2_ControlPlaneClass(in *Cont out.MachineInfrastructure = (*v1beta2.LocalObjectTemplate)(unsafe.Pointer(in.MachineInfrastructure)) out.MachineHealthCheck = (*v1beta2.MachineHealthCheckClass)(unsafe.Pointer(in.MachineHealthCheck)) out.NamingStrategy = (*v1beta2.ControlPlaneClassNamingStrategy)(unsafe.Pointer(in.NamingStrategy)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) out.ReadinessGates = *(*[]v1beta2.MachineReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) return nil } @@ -1626,9 +1591,9 @@ func autoConvert_v1beta2_ControlPlaneClass_To_v1beta1_ControlPlaneClass(in *v1be out.MachineInfrastructure = (*LocalObjectTemplate)(unsafe.Pointer(in.MachineInfrastructure)) out.MachineHealthCheck = (*MachineHealthCheckClass)(unsafe.Pointer(in.MachineHealthCheck)) out.NamingStrategy = (*ControlPlaneClassNamingStrategy)(unsafe.Pointer(in.NamingStrategy)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) out.ReadinessGates = *(*[]MachineReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) return nil } @@ -1664,9 +1629,9 @@ func autoConvert_v1beta1_ControlPlaneTopology_To_v1beta2_ControlPlaneTopology(in } out.Replicas = (*int32)(unsafe.Pointer(in.Replicas)) out.MachineHealthCheck = (*v1beta2.MachineHealthCheckTopology)(unsafe.Pointer(in.MachineHealthCheck)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) out.ReadinessGates = *(*[]v1beta2.MachineReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) out.Variables = (*v1beta2.ControlPlaneVariables)(unsafe.Pointer(in.Variables)) return nil @@ -1683,9 +1648,9 @@ func autoConvert_v1beta2_ControlPlaneTopology_To_v1beta1_ControlPlaneTopology(in } out.Replicas = (*int32)(unsafe.Pointer(in.Replicas)) out.MachineHealthCheck = (*MachineHealthCheckTopology)(unsafe.Pointer(in.MachineHealthCheck)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) out.ReadinessGates = *(*[]MachineReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) out.Variables = (*ControlPlaneVariables)(unsafe.Pointer(in.Variables)) return nil @@ -1911,7 +1876,7 @@ func Convert_v1beta2_JSONSchemaProps_To_v1beta1_JSONSchemaProps(in *v1beta2.JSON } func autoConvert_v1beta1_LocalObjectTemplate_To_v1beta2_LocalObjectTemplate(in *LocalObjectTemplate, out *v1beta2.LocalObjectTemplate, s conversion.Scope) error { - out.Ref = (*v1.ObjectReference)(unsafe.Pointer(in.Ref)) + out.Ref = (*corev1.ObjectReference)(unsafe.Pointer(in.Ref)) return nil } @@ -1921,7 +1886,7 @@ func Convert_v1beta1_LocalObjectTemplate_To_v1beta2_LocalObjectTemplate(in *Loca } func autoConvert_v1beta2_LocalObjectTemplate_To_v1beta1_LocalObjectTemplate(in *v1beta2.LocalObjectTemplate, out *LocalObjectTemplate, s conversion.Scope) error { - out.Ref = (*v1.ObjectReference)(unsafe.Pointer(in.Ref)) + out.Ref = (*corev1.ObjectReference)(unsafe.Pointer(in.Ref)) return nil } @@ -1985,8 +1950,8 @@ func Convert_v1beta2_MachineAddress_To_v1beta1_MachineAddress(in *v1beta2.Machin } func autoConvert_v1beta1_MachineDeletionStatus_To_v1beta2_MachineDeletionStatus(in *MachineDeletionStatus, out *v1beta2.MachineDeletionStatus, s conversion.Scope) error { - out.NodeDrainStartTime = (*metav1.Time)(unsafe.Pointer(in.NodeDrainStartTime)) - out.WaitForNodeVolumeDetachStartTime = (*metav1.Time)(unsafe.Pointer(in.WaitForNodeVolumeDetachStartTime)) + out.NodeDrainStartTime = (*v1.Time)(unsafe.Pointer(in.NodeDrainStartTime)) + out.WaitForNodeVolumeDetachStartTime = (*v1.Time)(unsafe.Pointer(in.WaitForNodeVolumeDetachStartTime)) return nil } @@ -1996,8 +1961,8 @@ func Convert_v1beta1_MachineDeletionStatus_To_v1beta2_MachineDeletionStatus(in * } func autoConvert_v1beta2_MachineDeletionStatus_To_v1beta1_MachineDeletionStatus(in *v1beta2.MachineDeletionStatus, out *MachineDeletionStatus, s conversion.Scope) error { - out.NodeDrainStartTime = (*metav1.Time)(unsafe.Pointer(in.NodeDrainStartTime)) - out.WaitForNodeVolumeDetachStartTime = (*metav1.Time)(unsafe.Pointer(in.WaitForNodeVolumeDetachStartTime)) + out.NodeDrainStartTime = (*v1.Time)(unsafe.Pointer(in.NodeDrainStartTime)) + out.WaitForNodeVolumeDetachStartTime = (*v1.Time)(unsafe.Pointer(in.WaitForNodeVolumeDetachStartTime)) return nil } @@ -2046,9 +2011,9 @@ func autoConvert_v1beta1_MachineDeploymentClass_To_v1beta2_MachineDeploymentClas out.MachineHealthCheck = (*v1beta2.MachineHealthCheckClass)(unsafe.Pointer(in.MachineHealthCheck)) out.FailureDomain = (*string)(unsafe.Pointer(in.FailureDomain)) out.NamingStrategy = (*v1beta2.MachineDeploymentClassNamingStrategy)(unsafe.Pointer(in.NamingStrategy)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) out.MinReadySeconds = (*int32)(unsafe.Pointer(in.MinReadySeconds)) out.ReadinessGates = *(*[]v1beta2.MachineReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) out.Strategy = (*v1beta2.MachineDeploymentStrategy)(unsafe.Pointer(in.Strategy)) @@ -2068,9 +2033,9 @@ func autoConvert_v1beta2_MachineDeploymentClass_To_v1beta1_MachineDeploymentClas out.MachineHealthCheck = (*MachineHealthCheckClass)(unsafe.Pointer(in.MachineHealthCheck)) out.FailureDomain = (*string)(unsafe.Pointer(in.FailureDomain)) out.NamingStrategy = (*MachineDeploymentClassNamingStrategy)(unsafe.Pointer(in.NamingStrategy)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) out.MinReadySeconds = (*int32)(unsafe.Pointer(in.MinReadySeconds)) out.ReadinessGates = *(*[]MachineReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) out.Strategy = (*MachineDeploymentStrategy)(unsafe.Pointer(in.Strategy)) @@ -2140,7 +2105,17 @@ func Convert_v1beta2_MachineDeploymentClassTemplate_To_v1beta1_MachineDeployment func autoConvert_v1beta1_MachineDeploymentList_To_v1beta2_MachineDeploymentList(in *MachineDeploymentList, out *v1beta2.MachineDeploymentList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1beta2.MachineDeployment)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.MachineDeployment, len(*in)) + for i := range *in { + if err := Convert_v1beta1_MachineDeployment_To_v1beta2_MachineDeployment(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -2151,7 +2126,17 @@ func Convert_v1beta1_MachineDeploymentList_To_v1beta2_MachineDeploymentList(in * func autoConvert_v1beta2_MachineDeploymentList_To_v1beta1_MachineDeploymentList(in *v1beta2.MachineDeploymentList, out *MachineDeploymentList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]MachineDeployment)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]MachineDeployment, len(*in)) + for i := range *in { + if err := Convert_v1beta2_MachineDeployment_To_v1beta1_MachineDeployment(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -2163,7 +2148,7 @@ func Convert_v1beta2_MachineDeploymentList_To_v1beta1_MachineDeploymentList(in * func autoConvert_v1beta1_MachineDeploymentSpec_To_v1beta2_MachineDeploymentSpec(in *MachineDeploymentSpec, out *v1beta2.MachineDeploymentSpec, s conversion.Scope) error { out.ClusterName = in.ClusterName out.Replicas = (*int32)(unsafe.Pointer(in.Replicas)) - out.RolloutAfter = (*metav1.Time)(unsafe.Pointer(in.RolloutAfter)) + out.RolloutAfter = (*v1.Time)(unsafe.Pointer(in.RolloutAfter)) out.Selector = in.Selector if err := Convert_v1beta1_MachineTemplateSpec_To_v1beta2_MachineTemplateSpec(&in.Template, &out.Template, s); err != nil { return err @@ -2185,7 +2170,7 @@ func Convert_v1beta1_MachineDeploymentSpec_To_v1beta2_MachineDeploymentSpec(in * func autoConvert_v1beta2_MachineDeploymentSpec_To_v1beta1_MachineDeploymentSpec(in *v1beta2.MachineDeploymentSpec, out *MachineDeploymentSpec, s conversion.Scope) error { out.ClusterName = in.ClusterName out.Replicas = (*int32)(unsafe.Pointer(in.Replicas)) - out.RolloutAfter = (*metav1.Time)(unsafe.Pointer(in.RolloutAfter)) + out.RolloutAfter = (*v1.Time)(unsafe.Pointer(in.RolloutAfter)) out.Selector = in.Selector if err := Convert_v1beta2_MachineTemplateSpec_To_v1beta1_MachineTemplateSpec(&in.Template, &out.Template, s); err != nil { return err @@ -2208,40 +2193,57 @@ func autoConvert_v1beta1_MachineDeploymentStatus_To_v1beta2_MachineDeploymentSta out.ObservedGeneration = in.ObservedGeneration out.Selector = in.Selector out.Replicas = in.Replicas - out.UpdatedReplicas = in.UpdatedReplicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas - out.UnavailableReplicas = in.UnavailableReplicas + // WARNING: in.UpdatedReplicas requires manual conversion: does not exist in peer-type + if err := v1.Convert_int32_To_Pointer_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_int32_To_Pointer_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UnavailableReplicas requires manual conversion: does not exist in peer-type out.Phase = in.Phase - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*v1beta2.MachineDeploymentV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus is an autogenerated conversion function. -func Convert_v1beta1_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(in *MachineDeploymentStatus, out *v1beta2.MachineDeploymentStatus, s conversion.Scope) error { - return autoConvert_v1beta1_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(in, out, s) -} - func autoConvert_v1beta2_MachineDeploymentStatus_To_v1beta1_MachineDeploymentStatus(in *v1beta2.MachineDeploymentStatus, out *MachineDeploymentStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1beta1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.ObservedGeneration = in.ObservedGeneration out.Selector = in.Selector out.Replicas = in.Replicas - out.UpdatedReplicas = in.UpdatedReplicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas - out.UnavailableReplicas = in.UnavailableReplicas + if err := v1.Convert_Pointer_int32_To_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int32_To_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UpToDateReplicas requires manual conversion: does not exist in peer-type out.Phase = in.Phase - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*MachineDeploymentV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta2_MachineDeploymentStatus_To_v1beta1_MachineDeploymentStatus is an autogenerated conversion function. -func Convert_v1beta2_MachineDeploymentStatus_To_v1beta1_MachineDeploymentStatus(in *v1beta2.MachineDeploymentStatus, out *MachineDeploymentStatus, s conversion.Scope) error { - return autoConvert_v1beta2_MachineDeploymentStatus_To_v1beta1_MachineDeploymentStatus(in, out, s) -} - func autoConvert_v1beta1_MachineDeploymentStrategy_To_v1beta2_MachineDeploymentStrategy(in *MachineDeploymentStrategy, out *v1beta2.MachineDeploymentStrategy, s conversion.Scope) error { out.Type = v1beta2.MachineDeploymentStrategyType(in.Type) out.RollingUpdate = (*v1beta2.MachineRollingUpdateDeployment)(unsafe.Pointer(in.RollingUpdate)) @@ -2275,9 +2277,9 @@ func autoConvert_v1beta1_MachineDeploymentTopology_To_v1beta2_MachineDeploymentT out.FailureDomain = (*string)(unsafe.Pointer(in.FailureDomain)) out.Replicas = (*int32)(unsafe.Pointer(in.Replicas)) out.MachineHealthCheck = (*v1beta2.MachineHealthCheckTopology)(unsafe.Pointer(in.MachineHealthCheck)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) out.MinReadySeconds = (*int32)(unsafe.Pointer(in.MinReadySeconds)) out.ReadinessGates = *(*[]v1beta2.MachineReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) out.Strategy = (*v1beta2.MachineDeploymentStrategy)(unsafe.Pointer(in.Strategy)) @@ -2299,9 +2301,9 @@ func autoConvert_v1beta2_MachineDeploymentTopology_To_v1beta1_MachineDeploymentT out.FailureDomain = (*string)(unsafe.Pointer(in.FailureDomain)) out.Replicas = (*int32)(unsafe.Pointer(in.Replicas)) out.MachineHealthCheck = (*MachineHealthCheckTopology)(unsafe.Pointer(in.MachineHealthCheck)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) out.MinReadySeconds = (*int32)(unsafe.Pointer(in.MinReadySeconds)) out.ReadinessGates = *(*[]MachineReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) out.Strategy = (*MachineDeploymentStrategy)(unsafe.Pointer(in.Strategy)) @@ -2314,32 +2316,6 @@ func Convert_v1beta2_MachineDeploymentTopology_To_v1beta1_MachineDeploymentTopol return autoConvert_v1beta2_MachineDeploymentTopology_To_v1beta1_MachineDeploymentTopology(in, out, s) } -func autoConvert_v1beta1_MachineDeploymentV1Beta2Status_To_v1beta2_MachineDeploymentV1Beta2Status(in *MachineDeploymentV1Beta2Status, out *v1beta2.MachineDeploymentV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - out.ReadyReplicas = (*int32)(unsafe.Pointer(in.ReadyReplicas)) - out.AvailableReplicas = (*int32)(unsafe.Pointer(in.AvailableReplicas)) - out.UpToDateReplicas = (*int32)(unsafe.Pointer(in.UpToDateReplicas)) - return nil -} - -// Convert_v1beta1_MachineDeploymentV1Beta2Status_To_v1beta2_MachineDeploymentV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta1_MachineDeploymentV1Beta2Status_To_v1beta2_MachineDeploymentV1Beta2Status(in *MachineDeploymentV1Beta2Status, out *v1beta2.MachineDeploymentV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta1_MachineDeploymentV1Beta2Status_To_v1beta2_MachineDeploymentV1Beta2Status(in, out, s) -} - -func autoConvert_v1beta2_MachineDeploymentV1Beta2Status_To_v1beta1_MachineDeploymentV1Beta2Status(in *v1beta2.MachineDeploymentV1Beta2Status, out *MachineDeploymentV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - out.ReadyReplicas = (*int32)(unsafe.Pointer(in.ReadyReplicas)) - out.AvailableReplicas = (*int32)(unsafe.Pointer(in.AvailableReplicas)) - out.UpToDateReplicas = (*int32)(unsafe.Pointer(in.UpToDateReplicas)) - return nil -} - -// Convert_v1beta2_MachineDeploymentV1Beta2Status_To_v1beta1_MachineDeploymentV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta2_MachineDeploymentV1Beta2Status_To_v1beta1_MachineDeploymentV1Beta2Status(in *v1beta2.MachineDeploymentV1Beta2Status, out *MachineDeploymentV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta2_MachineDeploymentV1Beta2Status_To_v1beta1_MachineDeploymentV1Beta2Status(in, out, s) -} - func autoConvert_v1beta1_MachineDeploymentVariables_To_v1beta2_MachineDeploymentVariables(in *MachineDeploymentVariables, out *v1beta2.MachineDeploymentVariables, s conversion.Scope) error { out.Overrides = *(*[]v1beta2.ClusterVariable)(unsafe.Pointer(&in.Overrides)) return nil @@ -2431,8 +2407,8 @@ func Convert_v1beta2_MachineDrainRuleList_To_v1beta1_MachineDrainRuleList(in *v1 } func autoConvert_v1beta1_MachineDrainRuleMachineSelector_To_v1beta2_MachineDrainRuleMachineSelector(in *MachineDrainRuleMachineSelector, out *v1beta2.MachineDrainRuleMachineSelector, s conversion.Scope) error { - out.Selector = (*metav1.LabelSelector)(unsafe.Pointer(in.Selector)) - out.ClusterSelector = (*metav1.LabelSelector)(unsafe.Pointer(in.ClusterSelector)) + out.Selector = (*v1.LabelSelector)(unsafe.Pointer(in.Selector)) + out.ClusterSelector = (*v1.LabelSelector)(unsafe.Pointer(in.ClusterSelector)) return nil } @@ -2442,8 +2418,8 @@ func Convert_v1beta1_MachineDrainRuleMachineSelector_To_v1beta2_MachineDrainRule } func autoConvert_v1beta2_MachineDrainRuleMachineSelector_To_v1beta1_MachineDrainRuleMachineSelector(in *v1beta2.MachineDrainRuleMachineSelector, out *MachineDrainRuleMachineSelector, s conversion.Scope) error { - out.Selector = (*metav1.LabelSelector)(unsafe.Pointer(in.Selector)) - out.ClusterSelector = (*metav1.LabelSelector)(unsafe.Pointer(in.ClusterSelector)) + out.Selector = (*v1.LabelSelector)(unsafe.Pointer(in.Selector)) + out.ClusterSelector = (*v1.LabelSelector)(unsafe.Pointer(in.ClusterSelector)) return nil } @@ -2453,8 +2429,8 @@ func Convert_v1beta2_MachineDrainRuleMachineSelector_To_v1beta1_MachineDrainRule } func autoConvert_v1beta1_MachineDrainRulePodSelector_To_v1beta2_MachineDrainRulePodSelector(in *MachineDrainRulePodSelector, out *v1beta2.MachineDrainRulePodSelector, s conversion.Scope) error { - out.Selector = (*metav1.LabelSelector)(unsafe.Pointer(in.Selector)) - out.NamespaceSelector = (*metav1.LabelSelector)(unsafe.Pointer(in.NamespaceSelector)) + out.Selector = (*v1.LabelSelector)(unsafe.Pointer(in.Selector)) + out.NamespaceSelector = (*v1.LabelSelector)(unsafe.Pointer(in.NamespaceSelector)) return nil } @@ -2464,8 +2440,8 @@ func Convert_v1beta1_MachineDrainRulePodSelector_To_v1beta2_MachineDrainRulePodS } func autoConvert_v1beta2_MachineDrainRulePodSelector_To_v1beta1_MachineDrainRulePodSelector(in *v1beta2.MachineDrainRulePodSelector, out *MachineDrainRulePodSelector, s conversion.Scope) error { - out.Selector = (*metav1.LabelSelector)(unsafe.Pointer(in.Selector)) - out.NamespaceSelector = (*metav1.LabelSelector)(unsafe.Pointer(in.NamespaceSelector)) + out.Selector = (*v1.LabelSelector)(unsafe.Pointer(in.Selector)) + out.NamespaceSelector = (*v1.LabelSelector)(unsafe.Pointer(in.NamespaceSelector)) return nil } @@ -2538,8 +2514,8 @@ func autoConvert_v1beta1_MachineHealthCheckClass_To_v1beta2_MachineHealthCheckCl out.UnhealthyConditions = *(*[]v1beta2.UnhealthyCondition)(unsafe.Pointer(&in.UnhealthyConditions)) out.MaxUnhealthy = (*intstr.IntOrString)(unsafe.Pointer(in.MaxUnhealthy)) out.UnhealthyRange = (*string)(unsafe.Pointer(in.UnhealthyRange)) - out.NodeStartupTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) - out.RemediationTemplate = (*v1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) + out.NodeStartupTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) + out.RemediationTemplate = (*corev1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) return nil } @@ -2552,8 +2528,8 @@ func autoConvert_v1beta2_MachineHealthCheckClass_To_v1beta1_MachineHealthCheckCl out.UnhealthyConditions = *(*[]UnhealthyCondition)(unsafe.Pointer(&in.UnhealthyConditions)) out.MaxUnhealthy = (*intstr.IntOrString)(unsafe.Pointer(in.MaxUnhealthy)) out.UnhealthyRange = (*string)(unsafe.Pointer(in.UnhealthyRange)) - out.NodeStartupTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) - out.RemediationTemplate = (*v1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) + out.NodeStartupTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) + out.RemediationTemplate = (*corev1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) return nil } @@ -2564,7 +2540,17 @@ func Convert_v1beta2_MachineHealthCheckClass_To_v1beta1_MachineHealthCheckClass( func autoConvert_v1beta1_MachineHealthCheckList_To_v1beta2_MachineHealthCheckList(in *MachineHealthCheckList, out *v1beta2.MachineHealthCheckList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1beta2.MachineHealthCheck)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.MachineHealthCheck, len(*in)) + for i := range *in { + if err := Convert_v1beta1_MachineHealthCheck_To_v1beta2_MachineHealthCheck(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -2575,7 +2561,17 @@ func Convert_v1beta1_MachineHealthCheckList_To_v1beta2_MachineHealthCheckList(in func autoConvert_v1beta2_MachineHealthCheckList_To_v1beta1_MachineHealthCheckList(in *v1beta2.MachineHealthCheckList, out *MachineHealthCheckList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]MachineHealthCheck)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]MachineHealthCheck, len(*in)) + for i := range *in { + if err := Convert_v1beta2_MachineHealthCheck_To_v1beta1_MachineHealthCheck(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -2590,8 +2586,8 @@ func autoConvert_v1beta1_MachineHealthCheckSpec_To_v1beta2_MachineHealthCheckSpe out.UnhealthyConditions = *(*[]v1beta2.UnhealthyCondition)(unsafe.Pointer(&in.UnhealthyConditions)) out.MaxUnhealthy = (*intstr.IntOrString)(unsafe.Pointer(in.MaxUnhealthy)) out.UnhealthyRange = (*string)(unsafe.Pointer(in.UnhealthyRange)) - out.NodeStartupTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) - out.RemediationTemplate = (*v1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) + out.NodeStartupTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) + out.RemediationTemplate = (*corev1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) return nil } @@ -2606,8 +2602,8 @@ func autoConvert_v1beta2_MachineHealthCheckSpec_To_v1beta1_MachineHealthCheckSpe out.UnhealthyConditions = *(*[]UnhealthyCondition)(unsafe.Pointer(&in.UnhealthyConditions)) out.MaxUnhealthy = (*intstr.IntOrString)(unsafe.Pointer(in.MaxUnhealthy)) out.UnhealthyRange = (*string)(unsafe.Pointer(in.UnhealthyRange)) - out.NodeStartupTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) - out.RemediationTemplate = (*v1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) + out.NodeStartupTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) + out.RemediationTemplate = (*corev1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) return nil } @@ -2622,32 +2618,42 @@ func autoConvert_v1beta1_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheckS out.RemediationsAllowed = in.RemediationsAllowed out.ObservedGeneration = in.ObservedGeneration out.Targets = *(*[]string)(unsafe.Pointer(&in.Targets)) - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*v1beta2.MachineHealthCheckV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheckStatus is an autogenerated conversion function. -func Convert_v1beta1_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheckStatus(in *MachineHealthCheckStatus, out *v1beta2.MachineHealthCheckStatus, s conversion.Scope) error { - return autoConvert_v1beta1_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheckStatus(in, out, s) -} - func autoConvert_v1beta2_MachineHealthCheckStatus_To_v1beta1_MachineHealthCheckStatus(in *v1beta2.MachineHealthCheckStatus, out *MachineHealthCheckStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1beta1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.ExpectedMachines = in.ExpectedMachines out.CurrentHealthy = in.CurrentHealthy out.RemediationsAllowed = in.RemediationsAllowed out.ObservedGeneration = in.ObservedGeneration out.Targets = *(*[]string)(unsafe.Pointer(&in.Targets)) - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*MachineHealthCheckV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta2_MachineHealthCheckStatus_To_v1beta1_MachineHealthCheckStatus is an autogenerated conversion function. -func Convert_v1beta2_MachineHealthCheckStatus_To_v1beta1_MachineHealthCheckStatus(in *v1beta2.MachineHealthCheckStatus, out *MachineHealthCheckStatus, s conversion.Scope) error { - return autoConvert_v1beta2_MachineHealthCheckStatus_To_v1beta1_MachineHealthCheckStatus(in, out, s) -} - func autoConvert_v1beta1_MachineHealthCheckTopology_To_v1beta2_MachineHealthCheckTopology(in *MachineHealthCheckTopology, out *v1beta2.MachineHealthCheckTopology, s conversion.Scope) error { out.Enable = (*bool)(unsafe.Pointer(in.Enable)) if err := Convert_v1beta1_MachineHealthCheckClass_To_v1beta2_MachineHealthCheckClass(&in.MachineHealthCheckClass, &out.MachineHealthCheckClass, s); err != nil { @@ -2674,29 +2680,19 @@ func Convert_v1beta2_MachineHealthCheckTopology_To_v1beta1_MachineHealthCheckTop return autoConvert_v1beta2_MachineHealthCheckTopology_To_v1beta1_MachineHealthCheckTopology(in, out, s) } -func autoConvert_v1beta1_MachineHealthCheckV1Beta2Status_To_v1beta2_MachineHealthCheckV1Beta2Status(in *MachineHealthCheckV1Beta2Status, out *v1beta2.MachineHealthCheckV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta1_MachineHealthCheckV1Beta2Status_To_v1beta2_MachineHealthCheckV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta1_MachineHealthCheckV1Beta2Status_To_v1beta2_MachineHealthCheckV1Beta2Status(in *MachineHealthCheckV1Beta2Status, out *v1beta2.MachineHealthCheckV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta1_MachineHealthCheckV1Beta2Status_To_v1beta2_MachineHealthCheckV1Beta2Status(in, out, s) -} - -func autoConvert_v1beta2_MachineHealthCheckV1Beta2Status_To_v1beta1_MachineHealthCheckV1Beta2Status(in *v1beta2.MachineHealthCheckV1Beta2Status, out *MachineHealthCheckV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta2_MachineHealthCheckV1Beta2Status_To_v1beta1_MachineHealthCheckV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta2_MachineHealthCheckV1Beta2Status_To_v1beta1_MachineHealthCheckV1Beta2Status(in *v1beta2.MachineHealthCheckV1Beta2Status, out *MachineHealthCheckV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta2_MachineHealthCheckV1Beta2Status_To_v1beta1_MachineHealthCheckV1Beta2Status(in, out, s) -} - func autoConvert_v1beta1_MachineList_To_v1beta2_MachineList(in *MachineList, out *v1beta2.MachineList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1beta2.Machine)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.Machine, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Machine_To_v1beta2_Machine(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -2707,7 +2703,17 @@ func Convert_v1beta1_MachineList_To_v1beta2_MachineList(in *MachineList, out *v1 func autoConvert_v1beta2_MachineList_To_v1beta1_MachineList(in *v1beta2.MachineList, out *MachineList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]Machine)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Machine, len(*in)) + for i := range *in { + if err := Convert_v1beta2_Machine_To_v1beta1_Machine(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -2743,9 +2749,9 @@ func autoConvert_v1beta1_MachinePoolClass_To_v1beta2_MachinePoolClass(in *Machin } out.FailureDomains = *(*[]string)(unsafe.Pointer(&in.FailureDomains)) out.NamingStrategy = (*v1beta2.MachinePoolClassNamingStrategy)(unsafe.Pointer(in.NamingStrategy)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) out.MinReadySeconds = (*int32)(unsafe.Pointer(in.MinReadySeconds)) return nil } @@ -2762,9 +2768,9 @@ func autoConvert_v1beta2_MachinePoolClass_To_v1beta1_MachinePoolClass(in *v1beta } out.FailureDomains = *(*[]string)(unsafe.Pointer(&in.FailureDomains)) out.NamingStrategy = (*MachinePoolClassNamingStrategy)(unsafe.Pointer(in.NamingStrategy)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) out.MinReadySeconds = (*int32)(unsafe.Pointer(in.MinReadySeconds)) return nil } @@ -2837,9 +2843,9 @@ func autoConvert_v1beta1_MachinePoolTopology_To_v1beta2_MachinePoolTopology(in * out.Class = in.Class out.Name = in.Name out.FailureDomains = *(*[]string)(unsafe.Pointer(&in.FailureDomains)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) out.MinReadySeconds = (*int32)(unsafe.Pointer(in.MinReadySeconds)) out.Replicas = (*int32)(unsafe.Pointer(in.Replicas)) out.Variables = (*v1beta2.MachinePoolVariables)(unsafe.Pointer(in.Variables)) @@ -2858,9 +2864,9 @@ func autoConvert_v1beta2_MachinePoolTopology_To_v1beta1_MachinePoolTopology(in * out.Class = in.Class out.Name = in.Name out.FailureDomains = *(*[]string)(unsafe.Pointer(&in.FailureDomains)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) out.MinReadySeconds = (*int32)(unsafe.Pointer(in.MinReadySeconds)) out.Replicas = (*int32)(unsafe.Pointer(in.Replicas)) out.Variables = (*MachinePoolVariables)(unsafe.Pointer(in.Variables)) @@ -2972,7 +2978,17 @@ func Convert_v1beta2_MachineSet_To_v1beta1_MachineSet(in *v1beta2.MachineSet, ou func autoConvert_v1beta1_MachineSetList_To_v1beta2_MachineSetList(in *MachineSetList, out *v1beta2.MachineSetList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1beta2.MachineSet)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.MachineSet, len(*in)) + for i := range *in { + if err := Convert_v1beta1_MachineSet_To_v1beta2_MachineSet(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -2983,7 +2999,17 @@ func Convert_v1beta1_MachineSetList_To_v1beta2_MachineSetList(in *MachineSetList func autoConvert_v1beta2_MachineSetList_To_v1beta1_MachineSetList(in *v1beta2.MachineSetList, out *MachineSetList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]MachineSet)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]MachineSet, len(*in)) + for i := range *in { + if err := Convert_v1beta2_MachineSet_To_v1beta1_MachineSet(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -3031,67 +3057,57 @@ func Convert_v1beta2_MachineSetSpec_To_v1beta1_MachineSetSpec(in *v1beta2.Machin func autoConvert_v1beta1_MachineSetStatus_To_v1beta2_MachineSetStatus(in *MachineSetStatus, out *v1beta2.MachineSetStatus, s conversion.Scope) error { out.Selector = in.Selector out.Replicas = in.Replicas - out.FullyLabeledReplicas = in.FullyLabeledReplicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas + // WARNING: in.FullyLabeledReplicas requires manual conversion: does not exist in peer-type + if err := v1.Convert_int32_To_Pointer_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_int32_To_Pointer_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } out.ObservedGeneration = in.ObservedGeneration - out.FailureReason = (*errors.MachineSetStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*v1beta2.MachineSetV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_MachineSetStatus_To_v1beta2_MachineSetStatus is an autogenerated conversion function. -func Convert_v1beta1_MachineSetStatus_To_v1beta2_MachineSetStatus(in *MachineSetStatus, out *v1beta2.MachineSetStatus, s conversion.Scope) error { - return autoConvert_v1beta1_MachineSetStatus_To_v1beta2_MachineSetStatus(in, out, s) -} - func autoConvert_v1beta2_MachineSetStatus_To_v1beta1_MachineSetStatus(in *v1beta2.MachineSetStatus, out *MachineSetStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1beta1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.Selector = in.Selector out.Replicas = in.Replicas - out.FullyLabeledReplicas = in.FullyLabeledReplicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas + if err := v1.Convert_Pointer_int32_To_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int32_To_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UpToDateReplicas requires manual conversion: does not exist in peer-type out.ObservedGeneration = in.ObservedGeneration - out.FailureReason = (*errors.MachineSetStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*MachineSetV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) - return nil -} - -// Convert_v1beta2_MachineSetStatus_To_v1beta1_MachineSetStatus is an autogenerated conversion function. -func Convert_v1beta2_MachineSetStatus_To_v1beta1_MachineSetStatus(in *v1beta2.MachineSetStatus, out *MachineSetStatus, s conversion.Scope) error { - return autoConvert_v1beta2_MachineSetStatus_To_v1beta1_MachineSetStatus(in, out, s) -} - -func autoConvert_v1beta1_MachineSetV1Beta2Status_To_v1beta2_MachineSetV1Beta2Status(in *MachineSetV1Beta2Status, out *v1beta2.MachineSetV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - out.ReadyReplicas = (*int32)(unsafe.Pointer(in.ReadyReplicas)) - out.AvailableReplicas = (*int32)(unsafe.Pointer(in.AvailableReplicas)) - out.UpToDateReplicas = (*int32)(unsafe.Pointer(in.UpToDateReplicas)) - return nil -} - -// Convert_v1beta1_MachineSetV1Beta2Status_To_v1beta2_MachineSetV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta1_MachineSetV1Beta2Status_To_v1beta2_MachineSetV1Beta2Status(in *MachineSetV1Beta2Status, out *v1beta2.MachineSetV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta1_MachineSetV1Beta2Status_To_v1beta2_MachineSetV1Beta2Status(in, out, s) -} - -func autoConvert_v1beta2_MachineSetV1Beta2Status_To_v1beta1_MachineSetV1Beta2Status(in *v1beta2.MachineSetV1Beta2Status, out *MachineSetV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - out.ReadyReplicas = (*int32)(unsafe.Pointer(in.ReadyReplicas)) - out.AvailableReplicas = (*int32)(unsafe.Pointer(in.AvailableReplicas)) - out.UpToDateReplicas = (*int32)(unsafe.Pointer(in.UpToDateReplicas)) + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta2_MachineSetV1Beta2Status_To_v1beta1_MachineSetV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta2_MachineSetV1Beta2Status_To_v1beta1_MachineSetV1Beta2Status(in *v1beta2.MachineSetV1Beta2Status, out *MachineSetV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta2_MachineSetV1Beta2Status_To_v1beta1_MachineSetV1Beta2Status(in, out, s) -} - func autoConvert_v1beta1_MachineSpec_To_v1beta2_MachineSpec(in *MachineSpec, out *v1beta2.MachineSpec, s conversion.Scope) error { out.ClusterName = in.ClusterName if err := Convert_v1beta1_Bootstrap_To_v1beta2_Bootstrap(&in.Bootstrap, &out.Bootstrap, s); err != nil { @@ -3102,9 +3118,9 @@ func autoConvert_v1beta1_MachineSpec_To_v1beta2_MachineSpec(in *MachineSpec, out out.ProviderID = (*string)(unsafe.Pointer(in.ProviderID)) out.FailureDomain = (*string)(unsafe.Pointer(in.FailureDomain)) out.ReadinessGates = *(*[]v1beta2.MachineReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) return nil } @@ -3123,9 +3139,9 @@ func autoConvert_v1beta2_MachineSpec_To_v1beta1_MachineSpec(in *v1beta2.MachineS out.ProviderID = (*string)(unsafe.Pointer(in.ProviderID)) out.FailureDomain = (*string)(unsafe.Pointer(in.FailureDomain)) out.ReadinessGates = *(*[]MachineReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) - out.NodeVolumeDetachTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) - out.NodeDeletionTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) + out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) return nil } @@ -3135,51 +3151,59 @@ func Convert_v1beta2_MachineSpec_To_v1beta1_MachineSpec(in *v1beta2.MachineSpec, } func autoConvert_v1beta1_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, out *v1beta2.MachineStatus, s conversion.Scope) error { - out.NodeRef = (*v1.ObjectReference)(unsafe.Pointer(in.NodeRef)) - out.NodeInfo = (*v1.NodeSystemInfo)(unsafe.Pointer(in.NodeInfo)) - out.LastUpdated = (*metav1.Time)(unsafe.Pointer(in.LastUpdated)) - out.FailureReason = (*errors.MachineStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + out.NodeRef = (*corev1.ObjectReference)(unsafe.Pointer(in.NodeRef)) + out.NodeInfo = (*corev1.NodeSystemInfo)(unsafe.Pointer(in.NodeInfo)) + out.LastUpdated = (*v1.Time)(unsafe.Pointer(in.LastUpdated)) + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.Addresses = *(*v1beta2.MachineAddresses)(unsafe.Pointer(&in.Addresses)) out.Phase = in.Phase - out.CertificatesExpiryDate = (*metav1.Time)(unsafe.Pointer(in.CertificatesExpiryDate)) + out.CertificatesExpiryDate = (*v1.Time)(unsafe.Pointer(in.CertificatesExpiryDate)) out.BootstrapReady = in.BootstrapReady out.InfrastructureReady = in.InfrastructureReady out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.Deletion = (*v1beta2.MachineDeletionStatus)(unsafe.Pointer(in.Deletion)) - out.V1Beta2 = (*v1beta2.MachineV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_MachineStatus_To_v1beta2_MachineStatus is an autogenerated conversion function. -func Convert_v1beta1_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, out *v1beta2.MachineStatus, s conversion.Scope) error { - return autoConvert_v1beta1_MachineStatus_To_v1beta2_MachineStatus(in, out, s) -} - func autoConvert_v1beta2_MachineStatus_To_v1beta1_MachineStatus(in *v1beta2.MachineStatus, out *MachineStatus, s conversion.Scope) error { - out.NodeRef = (*v1.ObjectReference)(unsafe.Pointer(in.NodeRef)) - out.NodeInfo = (*v1.NodeSystemInfo)(unsafe.Pointer(in.NodeInfo)) - out.LastUpdated = (*metav1.Time)(unsafe.Pointer(in.LastUpdated)) - out.FailureReason = (*errors.MachineStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1beta1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + out.NodeRef = (*corev1.ObjectReference)(unsafe.Pointer(in.NodeRef)) + out.NodeInfo = (*corev1.NodeSystemInfo)(unsafe.Pointer(in.NodeInfo)) + out.LastUpdated = (*v1.Time)(unsafe.Pointer(in.LastUpdated)) out.Addresses = *(*MachineAddresses)(unsafe.Pointer(&in.Addresses)) out.Phase = in.Phase - out.CertificatesExpiryDate = (*metav1.Time)(unsafe.Pointer(in.CertificatesExpiryDate)) + out.CertificatesExpiryDate = (*v1.Time)(unsafe.Pointer(in.CertificatesExpiryDate)) out.BootstrapReady = in.BootstrapReady out.InfrastructureReady = in.InfrastructureReady out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) out.Deletion = (*MachineDeletionStatus)(unsafe.Pointer(in.Deletion)) - out.V1Beta2 = (*MachineV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta2_MachineStatus_To_v1beta1_MachineStatus is an autogenerated conversion function. -func Convert_v1beta2_MachineStatus_To_v1beta1_MachineStatus(in *v1beta2.MachineStatus, out *MachineStatus, s conversion.Scope) error { - return autoConvert_v1beta2_MachineStatus_To_v1beta1_MachineStatus(in, out, s) -} - func autoConvert_v1beta1_MachineTemplateSpec_To_v1beta2_MachineTemplateSpec(in *MachineTemplateSpec, out *v1beta2.MachineTemplateSpec, s conversion.Scope) error { if err := Convert_v1beta1_ObjectMeta_To_v1beta2_ObjectMeta(&in.ObjectMeta, &out.ObjectMeta, s); err != nil { return err @@ -3210,26 +3234,6 @@ func Convert_v1beta2_MachineTemplateSpec_To_v1beta1_MachineTemplateSpec(in *v1be return autoConvert_v1beta2_MachineTemplateSpec_To_v1beta1_MachineTemplateSpec(in, out, s) } -func autoConvert_v1beta1_MachineV1Beta2Status_To_v1beta2_MachineV1Beta2Status(in *MachineV1Beta2Status, out *v1beta2.MachineV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta1_MachineV1Beta2Status_To_v1beta2_MachineV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta1_MachineV1Beta2Status_To_v1beta2_MachineV1Beta2Status(in *MachineV1Beta2Status, out *v1beta2.MachineV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta1_MachineV1Beta2Status_To_v1beta2_MachineV1Beta2Status(in, out, s) -} - -func autoConvert_v1beta2_MachineV1Beta2Status_To_v1beta1_MachineV1Beta2Status(in *v1beta2.MachineV1Beta2Status, out *MachineV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta2_MachineV1Beta2Status_To_v1beta1_MachineV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta2_MachineV1Beta2Status_To_v1beta1_MachineV1Beta2Status(in *v1beta2.MachineV1Beta2Status, out *MachineV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta2_MachineV1Beta2Status_To_v1beta1_MachineV1Beta2Status(in, out, s) -} - func autoConvert_v1beta1_NetworkRanges_To_v1beta2_NetworkRanges(in *NetworkRanges, out *v1beta2.NetworkRanges, s conversion.Scope) error { out.CIDRBlocks = *(*[]string)(unsafe.Pointer(&in.CIDRBlocks)) return nil @@ -3416,7 +3420,7 @@ func autoConvert_v1beta1_Topology_To_v1beta2_Topology(in *Topology, out *v1beta2 out.Class = in.Class out.ClassNamespace = in.ClassNamespace out.Version = in.Version - out.RolloutAfter = (*metav1.Time)(unsafe.Pointer(in.RolloutAfter)) + out.RolloutAfter = (*v1.Time)(unsafe.Pointer(in.RolloutAfter)) if err := Convert_v1beta1_ControlPlaneTopology_To_v1beta2_ControlPlaneTopology(&in.ControlPlane, &out.ControlPlane, s); err != nil { return err } @@ -3434,7 +3438,7 @@ func autoConvert_v1beta2_Topology_To_v1beta1_Topology(in *v1beta2.Topology, out out.Class = in.Class out.ClassNamespace = in.ClassNamespace out.Version = in.Version - out.RolloutAfter = (*metav1.Time)(unsafe.Pointer(in.RolloutAfter)) + out.RolloutAfter = (*v1.Time)(unsafe.Pointer(in.RolloutAfter)) if err := Convert_v1beta2_ControlPlaneTopology_To_v1beta1_ControlPlaneTopology(&in.ControlPlane, &out.ControlPlane, s); err != nil { return err } @@ -3449,8 +3453,8 @@ func Convert_v1beta2_Topology_To_v1beta1_Topology(in *v1beta2.Topology, out *Top } func autoConvert_v1beta1_UnhealthyCondition_To_v1beta2_UnhealthyCondition(in *UnhealthyCondition, out *v1beta2.UnhealthyCondition, s conversion.Scope) error { - out.Type = v1.NodeConditionType(in.Type) - out.Status = v1.ConditionStatus(in.Status) + out.Type = corev1.NodeConditionType(in.Type) + out.Status = corev1.ConditionStatus(in.Status) out.Timeout = in.Timeout return nil } @@ -3461,8 +3465,8 @@ func Convert_v1beta1_UnhealthyCondition_To_v1beta2_UnhealthyCondition(in *Unheal } func autoConvert_v1beta2_UnhealthyCondition_To_v1beta1_UnhealthyCondition(in *v1beta2.UnhealthyCondition, out *UnhealthyCondition, s conversion.Scope) error { - out.Type = v1.NodeConditionType(in.Type) - out.Status = v1.ConditionStatus(in.Status) + out.Type = corev1.NodeConditionType(in.Type) + out.Status = corev1.ConditionStatus(in.Status) out.Timeout = in.Timeout return nil } diff --git a/bootstrap/kubeadm/api/v1beta1/conversion.go b/bootstrap/kubeadm/api/v1beta1/conversion.go index 493dfd157e89..3c70b90d7ae5 100644 --- a/bootstrap/kubeadm/api/v1beta1/conversion.go +++ b/bootstrap/kubeadm/api/v1beta1/conversion.go @@ -17,7 +17,8 @@ limitations under the License. package v1beta1 import ( - apiconversion "k8s.io/apimachinery/pkg/conversion" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -49,12 +50,76 @@ func (dst *KubeadmConfigTemplate) ConvertFrom(srcRaw conversion.Hub) error { return Convert_v1beta2_KubeadmConfigTemplate_To_v1beta1_KubeadmConfigTemplate(src, dst, nil) } +func Convert_v1beta2_KubeadmConfigStatus_To_v1beta1_KubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, out *KubeadmConfigStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta2_KubeadmConfigStatus_To_v1beta1_KubeadmConfigStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). + out.Conditions = nil + + // Retrieve legacy conditions (v1beta1), failureReason and failureMessage from the deprecated field. + if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { + if in.Deprecated.V1Beta1.Conditions != nil { + clusterv1beta1.Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + } + out.FailureReason = in.Deprecated.V1Beta1.FailureReason + out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage + } + + // Move new conditions (v1beta2) to the v1beta2 field. + if in.Conditions == nil { + return nil + } + out.V1Beta2 = &KubeadmConfigV1Beta2Status{} + out.V1Beta2.Conditions = in.Conditions + return nil +} + +func Convert_v1beta1_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in *KubeadmConfigStatus, out *bootstrapv1.KubeadmConfigStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta1_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. + out.Conditions = nil + + // Retrieve new conditions (v1beta2) from the v1beta2 field. + if in.V1Beta2 != nil { + out.Conditions = in.V1Beta2.Conditions + } + + // Move legacy conditions (v1beta1), failureReason and failureMessage to the deprecated field. + if out.Deprecated == nil { + out.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &bootstrapv1.KubeadmConfigV1Beta1DeprecatedStatus{} + } + if in.Conditions != nil { + clusterv1beta1.Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + } + out.Deprecated.V1Beta1.FailureReason = in.FailureReason + out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage + return nil +} + // Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) -func Convert_v1beta1_ObjectMeta_To_v1beta2_ObjectMeta(in *clusterv1beta1.ObjectMeta, out *clusterv1.ObjectMeta, s apiconversion.Scope) error { +func Convert_v1beta1_ObjectMeta_To_v1beta2_ObjectMeta(in *clusterv1beta1.ObjectMeta, out *clusterv1.ObjectMeta, s apimachineryconversion.Scope) error { return clusterv1beta1.Convert_v1beta1_ObjectMeta_To_v1beta2_ObjectMeta(in, out, s) } -func Convert_v1beta2_ObjectMeta_To_v1beta1_ObjectMeta(in *clusterv1.ObjectMeta, out *clusterv1beta1.ObjectMeta, s apiconversion.Scope) error { +func Convert_v1beta2_ObjectMeta_To_v1beta1_ObjectMeta(in *clusterv1.ObjectMeta, out *clusterv1beta1.ObjectMeta, s apimachineryconversion.Scope) error { return clusterv1beta1.Convert_v1beta2_ObjectMeta_To_v1beta1_ObjectMeta(in, out, s) } + +func Convert_v1_Condition_To_v1beta1_Condition(in *metav1.Condition, out *clusterv1beta1.Condition, s apimachineryconversion.Scope) error { + return clusterv1beta1.Convert_v1_Condition_To_v1beta1_Condition(in, out, s) +} + +func Convert_v1beta1_Condition_To_v1_Condition(in *clusterv1beta1.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1beta1.Convert_v1beta1_Condition_To_v1_Condition(in, out, s) +} diff --git a/bootstrap/kubeadm/api/v1beta1/conversion_test.go b/bootstrap/kubeadm/api/v1beta1/conversion_test.go index e4013b62671c..4671132eeffa 100644 --- a/bootstrap/kubeadm/api/v1beta1/conversion_test.go +++ b/bootstrap/kubeadm/api/v1beta1/conversion_test.go @@ -21,7 +21,9 @@ package v1beta1 import ( "testing" + fuzz "github.com/google/gofuzz" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2" utilconversion "sigs.k8s.io/cluster-api/util/conversion" @@ -33,11 +35,38 @@ func TestFuzzyConversion(t *testing.T) { t.Run("for KubeadmConfig", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &bootstrapv1.KubeadmConfig{}, Spoke: &KubeadmConfig{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{KubeadmConfigFuzzFuncs}, })) t.Run("for KubeadmConfigTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Hub: &bootstrapv1.KubeadmConfigTemplate{}, - Spoke: &KubeadmConfigTemplate{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + Hub: &bootstrapv1.KubeadmConfigTemplate{}, + Spoke: &KubeadmConfigTemplate{}, })) } + +func KubeadmConfigFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubKubeadmConfigStatus, + spokeKubeadmConfigStatus, + } +} + +func hubKubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &bootstrapv1.KubeadmConfigV1Beta1DeprecatedStatus{} + } +} + +func spokeKubeadmConfigStatus(in *KubeadmConfigStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.V1Beta2 != nil { + if in.V1Beta2.Conditions == nil { + in.V1Beta2 = nil + } + } +} diff --git a/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go b/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go index 4575c474dfa4..c3b99e085369 100644 --- a/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go +++ b/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go @@ -464,7 +464,7 @@ type KubeadmConfigStatus struct { // failureReason will be set on non-retryable errors // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional // +kubebuilder:validation:MinLength=1 @@ -473,7 +473,7 @@ type KubeadmConfigStatus struct { // failureMessage will be set on non-retryable errors // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional // +kubebuilder:validation:MinLength=1 diff --git a/bootstrap/kubeadm/api/v1beta1/zz_generated.conversion.go b/bootstrap/kubeadm/api/v1beta1/zz_generated.conversion.go index aca087dbe5e6..ee7375d86284 100644 --- a/bootstrap/kubeadm/api/v1beta1/zz_generated.conversion.go +++ b/bootstrap/kubeadm/api/v1beta1/zz_generated.conversion.go @@ -380,16 +380,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*KubeadmConfigStatus)(nil), (*v1beta2.KubeadmConfigStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(a.(*KubeadmConfigStatus), b.(*v1beta2.KubeadmConfigStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.KubeadmConfigStatus)(nil), (*KubeadmConfigStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_KubeadmConfigStatus_To_v1beta1_KubeadmConfigStatus(a.(*v1beta2.KubeadmConfigStatus), b.(*KubeadmConfigStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*KubeadmConfigTemplate)(nil), (*v1beta2.KubeadmConfigTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_KubeadmConfigTemplate_To_v1beta2_KubeadmConfigTemplate(a.(*KubeadmConfigTemplate), b.(*v1beta2.KubeadmConfigTemplate), scope) }); err != nil { @@ -430,16 +420,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*KubeadmConfigV1Beta2Status)(nil), (*v1beta2.KubeadmConfigV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_KubeadmConfigV1Beta2Status_To_v1beta2_KubeadmConfigV1Beta2Status(a.(*KubeadmConfigV1Beta2Status), b.(*v1beta2.KubeadmConfigV1Beta2Status), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.KubeadmConfigV1Beta2Status)(nil), (*KubeadmConfigV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_KubeadmConfigV1Beta2Status_To_v1beta1_KubeadmConfigV1Beta2Status(a.(*v1beta2.KubeadmConfigV1Beta2Status), b.(*KubeadmConfigV1Beta2Status), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*LocalEtcd)(nil), (*v1beta2.LocalEtcd)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_LocalEtcd_To_v1beta2_LocalEtcd(a.(*LocalEtcd), b.(*v1beta2.LocalEtcd), scope) }); err != nil { @@ -540,11 +520,31 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1.Condition)(nil), (*apiv1beta1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1beta1_Condition(a.(*v1.Condition), b.(*apiv1beta1.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*apiv1beta1.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_Condition_To_v1_Condition(a.(*apiv1beta1.Condition), b.(*v1.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*KubeadmConfigStatus)(nil), (*v1beta2.KubeadmConfigStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(a.(*KubeadmConfigStatus), b.(*v1beta2.KubeadmConfigStatus), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*apiv1beta1.ObjectMeta)(nil), (*apiv1beta2.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_ObjectMeta_To_v1beta2_ObjectMeta(a.(*apiv1beta1.ObjectMeta), b.(*apiv1beta2.ObjectMeta), scope) }); err != nil { return err } + if err := s.AddConversionFunc((*v1beta2.KubeadmConfigStatus)(nil), (*KubeadmConfigStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KubeadmConfigStatus_To_v1beta1_KubeadmConfigStatus(a.(*v1beta2.KubeadmConfigStatus), b.(*KubeadmConfigStatus), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*apiv1beta2.ObjectMeta)(nil), (*apiv1beta1.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta2_ObjectMeta_To_v1beta1_ObjectMeta(a.(*apiv1beta2.ObjectMeta), b.(*apiv1beta1.ObjectMeta), scope) }); err != nil { @@ -1413,7 +1413,17 @@ func Convert_v1beta2_KubeadmConfig_To_v1beta1_KubeadmConfig(in *v1beta2.KubeadmC func autoConvert_v1beta1_KubeadmConfigList_To_v1beta2_KubeadmConfigList(in *KubeadmConfigList, out *v1beta2.KubeadmConfigList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1beta2.KubeadmConfig)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.KubeadmConfig, len(*in)) + for i := range *in { + if err := Convert_v1beta1_KubeadmConfig_To_v1beta2_KubeadmConfig(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -1424,7 +1434,17 @@ func Convert_v1beta1_KubeadmConfigList_To_v1beta2_KubeadmConfigList(in *KubeadmC func autoConvert_v1beta2_KubeadmConfigList_To_v1beta1_KubeadmConfigList(in *v1beta2.KubeadmConfigList, out *KubeadmConfigList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]KubeadmConfig)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KubeadmConfig, len(*in)) + for i := range *in { + if err := Convert_v1beta2_KubeadmConfig_To_v1beta1_KubeadmConfig(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -1484,35 +1504,43 @@ func Convert_v1beta2_KubeadmConfigSpec_To_v1beta1_KubeadmConfigSpec(in *v1beta2. func autoConvert_v1beta1_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in *KubeadmConfigStatus, out *v1beta2.KubeadmConfigStatus, s conversion.Scope) error { out.Ready = in.Ready out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) - out.FailureReason = in.FailureReason - out.FailureMessage = in.FailureMessage + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*apiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*v1beta2.KubeadmConfigV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus is an autogenerated conversion function. -func Convert_v1beta1_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in *KubeadmConfigStatus, out *v1beta2.KubeadmConfigStatus, s conversion.Scope) error { - return autoConvert_v1beta1_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in, out, s) -} - func autoConvert_v1beta2_KubeadmConfigStatus_To_v1beta1_KubeadmConfigStatus(in *v1beta2.KubeadmConfigStatus, out *KubeadmConfigStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(apiv1beta1.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1beta1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.Ready = in.Ready out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) - out.FailureReason = in.FailureReason - out.FailureMessage = in.FailureMessage out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*KubeadmConfigV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta2_KubeadmConfigStatus_To_v1beta1_KubeadmConfigStatus is an autogenerated conversion function. -func Convert_v1beta2_KubeadmConfigStatus_To_v1beta1_KubeadmConfigStatus(in *v1beta2.KubeadmConfigStatus, out *KubeadmConfigStatus, s conversion.Scope) error { - return autoConvert_v1beta2_KubeadmConfigStatus_To_v1beta1_KubeadmConfigStatus(in, out, s) -} - func autoConvert_v1beta1_KubeadmConfigTemplate_To_v1beta2_KubeadmConfigTemplate(in *KubeadmConfigTemplate, out *v1beta2.KubeadmConfigTemplate, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta if err := Convert_v1beta1_KubeadmConfigTemplateSpec_To_v1beta2_KubeadmConfigTemplateSpec(&in.Spec, &out.Spec, s); err != nil { @@ -1635,26 +1663,6 @@ func Convert_v1beta2_KubeadmConfigTemplateSpec_To_v1beta1_KubeadmConfigTemplateS return autoConvert_v1beta2_KubeadmConfigTemplateSpec_To_v1beta1_KubeadmConfigTemplateSpec(in, out, s) } -func autoConvert_v1beta1_KubeadmConfigV1Beta2Status_To_v1beta2_KubeadmConfigV1Beta2Status(in *KubeadmConfigV1Beta2Status, out *v1beta2.KubeadmConfigV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]v1.Condition)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta1_KubeadmConfigV1Beta2Status_To_v1beta2_KubeadmConfigV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta1_KubeadmConfigV1Beta2Status_To_v1beta2_KubeadmConfigV1Beta2Status(in *KubeadmConfigV1Beta2Status, out *v1beta2.KubeadmConfigV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta1_KubeadmConfigV1Beta2Status_To_v1beta2_KubeadmConfigV1Beta2Status(in, out, s) -} - -func autoConvert_v1beta2_KubeadmConfigV1Beta2Status_To_v1beta1_KubeadmConfigV1Beta2Status(in *v1beta2.KubeadmConfigV1Beta2Status, out *KubeadmConfigV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]v1.Condition)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta2_KubeadmConfigV1Beta2Status_To_v1beta1_KubeadmConfigV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta2_KubeadmConfigV1Beta2Status_To_v1beta1_KubeadmConfigV1Beta2Status(in *v1beta2.KubeadmConfigV1Beta2Status, out *KubeadmConfigV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta2_KubeadmConfigV1Beta2Status_To_v1beta1_KubeadmConfigV1Beta2Status(in, out, s) -} - func autoConvert_v1beta1_LocalEtcd_To_v1beta2_LocalEtcd(in *LocalEtcd, out *v1beta2.LocalEtcd, s conversion.Scope) error { if err := Convert_v1beta1_ImageMeta_To_v1beta2_ImageMeta(&in.ImageMeta, &out.ImageMeta, s); err != nil { return err diff --git a/controlplane/kubeadm/api/v1beta1/conversion.go b/controlplane/kubeadm/api/v1beta1/conversion.go index 115f51832b98..a5a51e4d792f 100644 --- a/controlplane/kubeadm/api/v1beta1/conversion.go +++ b/controlplane/kubeadm/api/v1beta1/conversion.go @@ -17,7 +17,8 @@ limitations under the License. package v1beta1 import ( - apiconversion "k8s.io/apimachinery/pkg/conversion" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -51,20 +52,104 @@ func (dst *KubeadmControlPlaneTemplate) ConvertFrom(srcRaw conversion.Hub) error return Convert_v1beta2_KubeadmControlPlaneTemplate_To_v1beta1_KubeadmControlPlaneTemplate(src, dst, nil) } +func Convert_v1beta2_KubeadmControlPlaneStatus_To_v1beta1_KubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus, out *KubeadmControlPlaneStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta2_KubeadmControlPlaneStatus_To_v1beta1_KubeadmControlPlaneStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). + out.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. + out.ReadyReplicas = 0 + + // Retrieve legacy conditions (v1beta1), failureReason, failureMessage and replica counters from the deprecated field. + if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { + if in.Deprecated.V1Beta1.Conditions != nil { + clusterv1beta1.Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + } + out.FailureReason = in.Deprecated.V1Beta1.FailureReason + out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage + out.UpdatedReplicas = in.Deprecated.V1Beta1.UpdatedReplicas + out.ReadyReplicas = in.Deprecated.V1Beta1.ReadyReplicas + out.UnavailableReplicas = in.Deprecated.V1Beta1.UnavailableReplicas + } + + // Move new conditions (v1beta2) and replica counter to the v1beta2 field. + if in.Conditions == nil && in.ReadyReplicas == nil && in.AvailableReplicas == nil && in.UpToDateReplicas == nil { + return nil + } + out.V1Beta2 = &KubeadmControlPlaneV1Beta2Status{} + out.V1Beta2.Conditions = in.Conditions + out.V1Beta2.ReadyReplicas = in.ReadyReplicas + out.V1Beta2.AvailableReplicas = in.AvailableReplicas + out.V1Beta2.UpToDateReplicas = in.UpToDateReplicas + return nil +} + +func Convert_v1beta1_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in *KubeadmControlPlaneStatus, out *controlplanev1.KubeadmControlPlaneStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta1_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. + out.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: old replica counters should not be automatically be converted into replica counters with a new semantic. + out.ReadyReplicas = nil + + // Retrieve new conditions (v1beta2) and replica counter from the v1beta2 field. + if in.V1Beta2 != nil { + out.Conditions = in.V1Beta2.Conditions + out.ReadyReplicas = in.V1Beta2.ReadyReplicas + out.AvailableReplicas = in.V1Beta2.AvailableReplicas + out.UpToDateReplicas = in.V1Beta2.UpToDateReplicas + } + + // Move legacy conditions (v1beta1), failureReason, failureMessage and replica counters to the deprecated field. + if out.Deprecated == nil { + out.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{} + } + if in.Conditions != nil { + clusterv1beta1.Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + } + out.Deprecated.V1Beta1.FailureReason = in.FailureReason + out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage + out.Deprecated.V1Beta1.UpdatedReplicas = in.UpdatedReplicas + out.Deprecated.V1Beta1.ReadyReplicas = in.ReadyReplicas + out.Deprecated.V1Beta1.UnavailableReplicas = in.UnavailableReplicas + return nil +} + // Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) -func Convert_v1beta1_ObjectMeta_To_v1beta2_ObjectMeta(in *clusterv1beta1.ObjectMeta, out *clusterv1.ObjectMeta, s apiconversion.Scope) error { +func Convert_v1beta1_ObjectMeta_To_v1beta2_ObjectMeta(in *clusterv1beta1.ObjectMeta, out *clusterv1.ObjectMeta, s apimachineryconversion.Scope) error { return clusterv1beta1.Convert_v1beta1_ObjectMeta_To_v1beta2_ObjectMeta(in, out, s) } -func Convert_v1beta2_ObjectMeta_To_v1beta1_ObjectMeta(in *clusterv1.ObjectMeta, out *clusterv1beta1.ObjectMeta, s apiconversion.Scope) error { +func Convert_v1beta2_ObjectMeta_To_v1beta1_ObjectMeta(in *clusterv1.ObjectMeta, out *clusterv1beta1.ObjectMeta, s apimachineryconversion.Scope) error { return clusterv1beta1.Convert_v1beta2_ObjectMeta_To_v1beta1_ObjectMeta(in, out, s) } -func Convert_v1beta1_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in *bootstrapv1beta1.KubeadmConfigSpec, out *bootstrapv1.KubeadmConfigSpec, s apiconversion.Scope) error { +func Convert_v1beta1_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in *bootstrapv1beta1.KubeadmConfigSpec, out *bootstrapv1.KubeadmConfigSpec, s apimachineryconversion.Scope) error { return bootstrapv1beta1.Convert_v1beta1_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in, out, s) } -func Convert_v1beta2_KubeadmConfigSpec_To_v1beta1_KubeadmConfigSpec(in *bootstrapv1.KubeadmConfigSpec, out *bootstrapv1beta1.KubeadmConfigSpec, s apiconversion.Scope) error { +func Convert_v1beta2_KubeadmConfigSpec_To_v1beta1_KubeadmConfigSpec(in *bootstrapv1.KubeadmConfigSpec, out *bootstrapv1beta1.KubeadmConfigSpec, s apimachineryconversion.Scope) error { return bootstrapv1beta1.Convert_v1beta2_KubeadmConfigSpec_To_v1beta1_KubeadmConfigSpec(in, out, s) } + +func Convert_v1_Condition_To_v1beta1_Condition(in *metav1.Condition, out *clusterv1beta1.Condition, s apimachineryconversion.Scope) error { + return clusterv1beta1.Convert_v1_Condition_To_v1beta1_Condition(in, out, s) +} + +func Convert_v1beta1_Condition_To_v1_Condition(in *clusterv1beta1.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1beta1.Convert_v1beta1_Condition_To_v1_Condition(in, out, s) +} diff --git a/controlplane/kubeadm/api/v1beta1/conversion_test.go b/controlplane/kubeadm/api/v1beta1/conversion_test.go index 26a1baba8175..2d7debf1c5b8 100644 --- a/controlplane/kubeadm/api/v1beta1/conversion_test.go +++ b/controlplane/kubeadm/api/v1beta1/conversion_test.go @@ -21,7 +21,9 @@ package v1beta1 import ( "testing" + fuzz "github.com/google/gofuzz" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta2" utilconversion "sigs.k8s.io/cluster-api/util/conversion" @@ -33,12 +35,38 @@ func TestFuzzyConversion(t *testing.T) { t.Run("for KubeadmControlPlane", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &controlplanev1.KubeadmControlPlane{}, Spoke: &KubeadmControlPlane{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{KubeadmControlPlaneFuzzFuncs}, })) - t.Run("for KubeadmControlPlaneTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Hub: &controlplanev1.KubeadmControlPlaneTemplate{}, - Spoke: &KubeadmControlPlaneTemplate{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + Hub: &controlplanev1.KubeadmControlPlaneTemplate{}, + Spoke: &KubeadmControlPlaneTemplate{}, })) } + +func KubeadmControlPlaneFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubKubeadmControlPlaneStatus, + spokeKubeadmControlPlaneStatus, + } +} + +func hubKubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{} + } +} + +func spokeKubeadmControlPlaneStatus(in *KubeadmControlPlaneStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.V1Beta2 != nil { + if in.V1Beta2.Conditions == nil && in.V1Beta2.AvailableReplicas == nil && in.V1Beta2.ReadyReplicas == nil && in.V1Beta2.UpToDateReplicas == nil { + in.V1Beta2 = nil + } + } +} diff --git a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go index 918ad75aecaa..887dede76ef1 100644 --- a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go +++ b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go @@ -319,7 +319,7 @@ type KubeadmControlPlaneStatus struct { // be machines that are running but not yet ready or machines // that still have not been created. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional UnavailableReplicas int32 `json:"unavailableReplicas"` @@ -344,7 +344,7 @@ type KubeadmControlPlaneStatus struct { // state, and will be set to a token value suitable for // programmatic interpretation. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional FailureReason errors.KubeadmControlPlaneStatusError `json:"failureReason,omitempty"` @@ -352,7 +352,7 @@ type KubeadmControlPlaneStatus struct { // failureMessage indicates that there is a terminal problem reconciling the // state, and will be set to a descriptive error message. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional // +kubebuilder:validation:MinLength=1 diff --git a/controlplane/kubeadm/api/v1beta1/zz_generated.conversion.go b/controlplane/kubeadm/api/v1beta1/zz_generated.conversion.go index 0e0f3eb262d0..eba3864b37b1 100644 --- a/controlplane/kubeadm/api/v1beta1/zz_generated.conversion.go +++ b/controlplane/kubeadm/api/v1beta1/zz_generated.conversion.go @@ -28,12 +28,11 @@ import ( conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" intstr "k8s.io/apimachinery/pkg/util/intstr" - clusterapiapiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" + apiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterapiapiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" - apiv1beta1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1" + kubeadmapiv1beta1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1" apiv1beta2 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2" v1beta2 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta2" - errors "sigs.k8s.io/cluster-api/errors" ) func init() { @@ -83,16 +82,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*KubeadmControlPlaneStatus)(nil), (*v1beta2.KubeadmControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(a.(*KubeadmControlPlaneStatus), b.(*v1beta2.KubeadmControlPlaneStatus), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.KubeadmControlPlaneStatus)(nil), (*KubeadmControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_KubeadmControlPlaneStatus_To_v1beta1_KubeadmControlPlaneStatus(a.(*v1beta2.KubeadmControlPlaneStatus), b.(*KubeadmControlPlaneStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*KubeadmControlPlaneTemplate)(nil), (*v1beta2.KubeadmControlPlaneTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_KubeadmControlPlaneTemplate_To_v1beta2_KubeadmControlPlaneTemplate(a.(*KubeadmControlPlaneTemplate), b.(*v1beta2.KubeadmControlPlaneTemplate), scope) }); err != nil { @@ -153,16 +142,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*KubeadmControlPlaneV1Beta2Status)(nil), (*v1beta2.KubeadmControlPlaneV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_KubeadmControlPlaneV1Beta2Status_To_v1beta2_KubeadmControlPlaneV1Beta2Status(a.(*KubeadmControlPlaneV1Beta2Status), b.(*v1beta2.KubeadmControlPlaneV1Beta2Status), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*v1beta2.KubeadmControlPlaneV1Beta2Status)(nil), (*KubeadmControlPlaneV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_KubeadmControlPlaneV1Beta2Status_To_v1beta1_KubeadmControlPlaneV1Beta2Status(a.(*v1beta2.KubeadmControlPlaneV1Beta2Status), b.(*KubeadmControlPlaneV1Beta2Status), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*LastRemediationStatus)(nil), (*v1beta2.LastRemediationStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_LastRemediationStatus_To_v1beta2_LastRemediationStatus(a.(*LastRemediationStatus), b.(*v1beta2.LastRemediationStatus), scope) }); err != nil { @@ -223,23 +202,43 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddConversionFunc((*apiv1beta1.KubeadmConfigSpec)(nil), (*apiv1beta2.KubeadmConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(a.(*apiv1beta1.KubeadmConfigSpec), b.(*apiv1beta2.KubeadmConfigSpec), scope) + if err := s.AddConversionFunc((*v1.Condition)(nil), (*apiv1beta1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1beta1_Condition(a.(*v1.Condition), b.(*apiv1beta1.Condition), scope) }); err != nil { return err } - if err := s.AddConversionFunc((*clusterapiapiv1beta1.ObjectMeta)(nil), (*clusterapiapiv1beta2.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_ObjectMeta_To_v1beta2_ObjectMeta(a.(*clusterapiapiv1beta1.ObjectMeta), b.(*clusterapiapiv1beta2.ObjectMeta), scope) + if err := s.AddConversionFunc((*apiv1beta1.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_Condition_To_v1_Condition(a.(*apiv1beta1.Condition), b.(*v1.Condition), scope) }); err != nil { return err } - if err := s.AddConversionFunc((*apiv1beta2.KubeadmConfigSpec)(nil), (*apiv1beta1.KubeadmConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_KubeadmConfigSpec_To_v1beta1_KubeadmConfigSpec(a.(*apiv1beta2.KubeadmConfigSpec), b.(*apiv1beta1.KubeadmConfigSpec), scope) + if err := s.AddConversionFunc((*kubeadmapiv1beta1.KubeadmConfigSpec)(nil), (*apiv1beta2.KubeadmConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(a.(*kubeadmapiv1beta1.KubeadmConfigSpec), b.(*apiv1beta2.KubeadmConfigSpec), scope) }); err != nil { return err } - if err := s.AddConversionFunc((*clusterapiapiv1beta2.ObjectMeta)(nil), (*clusterapiapiv1beta1.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ObjectMeta_To_v1beta1_ObjectMeta(a.(*clusterapiapiv1beta2.ObjectMeta), b.(*clusterapiapiv1beta1.ObjectMeta), scope) + if err := s.AddConversionFunc((*KubeadmControlPlaneStatus)(nil), (*v1beta2.KubeadmControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(a.(*KubeadmControlPlaneStatus), b.(*v1beta2.KubeadmControlPlaneStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*apiv1beta1.ObjectMeta)(nil), (*clusterapiapiv1beta2.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_ObjectMeta_To_v1beta2_ObjectMeta(a.(*apiv1beta1.ObjectMeta), b.(*clusterapiapiv1beta2.ObjectMeta), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*apiv1beta2.KubeadmConfigSpec)(nil), (*kubeadmapiv1beta1.KubeadmConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KubeadmConfigSpec_To_v1beta1_KubeadmConfigSpec(a.(*apiv1beta2.KubeadmConfigSpec), b.(*kubeadmapiv1beta1.KubeadmConfigSpec), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*v1beta2.KubeadmControlPlaneStatus)(nil), (*KubeadmControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_KubeadmControlPlaneStatus_To_v1beta1_KubeadmControlPlaneStatus(a.(*v1beta2.KubeadmControlPlaneStatus), b.(*KubeadmControlPlaneStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*clusterapiapiv1beta2.ObjectMeta)(nil), (*apiv1beta1.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_ObjectMeta_To_v1beta1_ObjectMeta(a.(*clusterapiapiv1beta2.ObjectMeta), b.(*apiv1beta1.ObjectMeta), scope) }); err != nil { return err } @@ -342,7 +341,7 @@ func autoConvert_v1beta2_KubeadmControlPlaneMachineTemplate_To_v1beta1_KubeadmCo return err } out.InfrastructureRef = in.InfrastructureRef - out.ReadinessGates = *(*[]clusterapiapiv1beta1.MachineReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) + out.ReadinessGates = *(*[]apiv1beta1.MachineReadinessGate)(unsafe.Pointer(&in.ReadinessGates)) out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) out.NodeVolumeDetachTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeVolumeDetachTimeout)) out.NodeDeletionTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDeletionTimeout)) @@ -402,48 +401,60 @@ func autoConvert_v1beta1_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlan out.Selector = in.Selector out.Replicas = in.Replicas out.Version = (*string)(unsafe.Pointer(in.Version)) - out.UpdatedReplicas = in.UpdatedReplicas - out.ReadyReplicas = in.ReadyReplicas - out.UnavailableReplicas = in.UnavailableReplicas + // WARNING: in.UpdatedReplicas requires manual conversion: does not exist in peer-type + if err := v1.Convert_int32_To_Pointer_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + // WARNING: in.UnavailableReplicas requires manual conversion: does not exist in peer-type out.Initialized = in.Initialized out.Ready = in.Ready - out.FailureReason = errors.KubeadmControlPlaneStatusError(in.FailureReason) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*clusterapiapiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.LastRemediation = (*v1beta2.LastRemediationStatus)(unsafe.Pointer(in.LastRemediation)) - out.V1Beta2 = (*v1beta2.KubeadmControlPlaneV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus is an autogenerated conversion function. -func Convert_v1beta1_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in *KubeadmControlPlaneStatus, out *v1beta2.KubeadmControlPlaneStatus, s conversion.Scope) error { - return autoConvert_v1beta1_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in, out, s) -} - func autoConvert_v1beta2_KubeadmControlPlaneStatus_To_v1beta1_KubeadmControlPlaneStatus(in *v1beta2.KubeadmControlPlaneStatus, out *KubeadmControlPlaneStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(apiv1beta1.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1beta1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.Selector = in.Selector out.Replicas = in.Replicas + if err := v1.Convert_Pointer_int32_To_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + // WARNING: in.AvailableReplicas requires manual conversion: does not exist in peer-type + // WARNING: in.UpToDateReplicas requires manual conversion: does not exist in peer-type out.Version = (*string)(unsafe.Pointer(in.Version)) - out.UpdatedReplicas = in.UpdatedReplicas - out.ReadyReplicas = in.ReadyReplicas - out.UnavailableReplicas = in.UnavailableReplicas out.Initialized = in.Initialized out.Ready = in.Ready - out.FailureReason = errors.KubeadmControlPlaneStatusError(in.FailureReason) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*clusterapiapiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) out.LastRemediation = (*LastRemediationStatus)(unsafe.Pointer(in.LastRemediation)) - out.V1Beta2 = (*KubeadmControlPlaneV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta2_KubeadmControlPlaneStatus_To_v1beta1_KubeadmControlPlaneStatus is an autogenerated conversion function. -func Convert_v1beta2_KubeadmControlPlaneStatus_To_v1beta1_KubeadmControlPlaneStatus(in *v1beta2.KubeadmControlPlaneStatus, out *KubeadmControlPlaneStatus, s conversion.Scope) error { - return autoConvert_v1beta2_KubeadmControlPlaneStatus_To_v1beta1_KubeadmControlPlaneStatus(in, out, s) -} - func autoConvert_v1beta1_KubeadmControlPlaneTemplate_To_v1beta2_KubeadmControlPlaneTemplate(in *KubeadmControlPlaneTemplate, out *v1beta2.KubeadmControlPlaneTemplate, s conversion.Scope) error { out.ObjectMeta = in.ObjectMeta if err := Convert_v1beta1_KubeadmControlPlaneTemplateSpec_To_v1beta2_KubeadmControlPlaneTemplateSpec(&in.Spec, &out.Spec, s); err != nil { @@ -648,32 +659,6 @@ func Convert_v1beta2_KubeadmControlPlaneTemplateSpec_To_v1beta1_KubeadmControlPl return autoConvert_v1beta2_KubeadmControlPlaneTemplateSpec_To_v1beta1_KubeadmControlPlaneTemplateSpec(in, out, s) } -func autoConvert_v1beta1_KubeadmControlPlaneV1Beta2Status_To_v1beta2_KubeadmControlPlaneV1Beta2Status(in *KubeadmControlPlaneV1Beta2Status, out *v1beta2.KubeadmControlPlaneV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]v1.Condition)(unsafe.Pointer(&in.Conditions)) - out.ReadyReplicas = (*int32)(unsafe.Pointer(in.ReadyReplicas)) - out.AvailableReplicas = (*int32)(unsafe.Pointer(in.AvailableReplicas)) - out.UpToDateReplicas = (*int32)(unsafe.Pointer(in.UpToDateReplicas)) - return nil -} - -// Convert_v1beta1_KubeadmControlPlaneV1Beta2Status_To_v1beta2_KubeadmControlPlaneV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta1_KubeadmControlPlaneV1Beta2Status_To_v1beta2_KubeadmControlPlaneV1Beta2Status(in *KubeadmControlPlaneV1Beta2Status, out *v1beta2.KubeadmControlPlaneV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta1_KubeadmControlPlaneV1Beta2Status_To_v1beta2_KubeadmControlPlaneV1Beta2Status(in, out, s) -} - -func autoConvert_v1beta2_KubeadmControlPlaneV1Beta2Status_To_v1beta1_KubeadmControlPlaneV1Beta2Status(in *v1beta2.KubeadmControlPlaneV1Beta2Status, out *KubeadmControlPlaneV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]v1.Condition)(unsafe.Pointer(&in.Conditions)) - out.ReadyReplicas = (*int32)(unsafe.Pointer(in.ReadyReplicas)) - out.AvailableReplicas = (*int32)(unsafe.Pointer(in.AvailableReplicas)) - out.UpToDateReplicas = (*int32)(unsafe.Pointer(in.UpToDateReplicas)) - return nil -} - -// Convert_v1beta2_KubeadmControlPlaneV1Beta2Status_To_v1beta1_KubeadmControlPlaneV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta2_KubeadmControlPlaneV1Beta2Status_To_v1beta1_KubeadmControlPlaneV1Beta2Status(in *v1beta2.KubeadmControlPlaneV1Beta2Status, out *KubeadmControlPlaneV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta2_KubeadmControlPlaneV1Beta2Status_To_v1beta1_KubeadmControlPlaneV1Beta2Status(in, out, s) -} - func autoConvert_v1beta1_LastRemediationStatus_To_v1beta2_LastRemediationStatus(in *LastRemediationStatus, out *v1beta2.LastRemediationStatus, s conversion.Scope) error { out.Machine = in.Machine out.Timestamp = in.Timestamp diff --git a/exp/api/v1beta1/conversion.go b/exp/api/v1beta1/conversion.go index df075c76fa2b..9a063807cfe5 100644 --- a/exp/api/v1beta1/conversion.go +++ b/exp/api/v1beta1/conversion.go @@ -17,7 +17,8 @@ limitations under the License. package v1beta1 import ( - apiconversion "k8s.io/apimachinery/pkg/conversion" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -37,12 +38,98 @@ func (dst *MachinePool) ConvertFrom(srcRaw conversion.Hub) error { return Convert_v1beta2_MachinePool_To_v1beta1_MachinePool(src, dst, nil) } +func Convert_v1beta2_MachinePoolStatus_To_v1beta1_MachinePoolStatus(in *expv1.MachinePoolStatus, out *MachinePoolStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta2_MachinePoolStatus_To_v1beta1_MachinePoolStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). + out.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. + out.ReadyReplicas = 0 + out.AvailableReplicas = 0 + + // Retrieve legacy conditions (v1beta1), failureReason and failureMessage from the deprecated field. + if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { + if in.Deprecated.V1Beta1.Conditions != nil { + clusterv1beta1.Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + } + out.FailureReason = in.Deprecated.V1Beta1.FailureReason + out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage + out.ReadyReplicas = in.Deprecated.V1Beta1.ReadyReplicas + out.AvailableReplicas = in.Deprecated.V1Beta1.AvailableReplicas + out.UnavailableReplicas = in.Deprecated.V1Beta1.UnavailableReplicas + } + + // Move new conditions (v1beta2) to the v1beta2 field. + if in.Conditions == nil { + return nil + } + out.V1Beta2 = &MachinePoolV1Beta2Status{} + out.V1Beta2.Conditions = in.Conditions + out.V1Beta2.ReadyReplicas = in.ReadyReplicas + out.V1Beta2.AvailableReplicas = in.AvailableReplicas + out.V1Beta2.UpToDateReplicas = in.UpToDateReplicas + return nil +} + +func Convert_v1beta1_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachinePoolStatus, out *expv1.MachinePoolStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta1_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. + out.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: old replica counters should not be automatically be converted into replica counters with a new semantic. + out.ReadyReplicas = nil + out.AvailableReplicas = nil + + // Retrieve new conditions (v1beta2) from the v1beta2 field. + if in.V1Beta2 != nil { + out.Conditions = in.V1Beta2.Conditions + out.ReadyReplicas = in.V1Beta2.ReadyReplicas + out.AvailableReplicas = in.V1Beta2.AvailableReplicas + out.UpToDateReplicas = in.V1Beta2.UpToDateReplicas + } + + // Move legacy conditions (v1beta1), failureReason and failureMessage to the deprecated field. + if out.Deprecated == nil { + out.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + } + if in.Conditions != nil { + clusterv1beta1.Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + } + out.Deprecated.V1Beta1.FailureReason = in.FailureReason + out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage + out.Deprecated.V1Beta1.ReadyReplicas = in.ReadyReplicas + out.Deprecated.V1Beta1.AvailableReplicas = in.AvailableReplicas + out.Deprecated.V1Beta1.UnavailableReplicas = in.UnavailableReplicas + return nil +} + // Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) -func Convert_v1beta1_MachineTemplateSpec_To_v1beta2_MachineTemplateSpec(in *clusterv1beta1.MachineTemplateSpec, out *clusterv1.MachineTemplateSpec, s apiconversion.Scope) error { +func Convert_v1beta1_MachineTemplateSpec_To_v1beta2_MachineTemplateSpec(in *clusterv1beta1.MachineTemplateSpec, out *clusterv1.MachineTemplateSpec, s apimachineryconversion.Scope) error { return clusterv1beta1.Convert_v1beta1_MachineTemplateSpec_To_v1beta2_MachineTemplateSpec(in, out, s) } -func Convert_v1beta2_MachineTemplateSpec_To_v1beta1_MachineTemplateSpec(in *clusterv1.MachineTemplateSpec, out *clusterv1beta1.MachineTemplateSpec, s apiconversion.Scope) error { +func Convert_v1beta2_MachineTemplateSpec_To_v1beta1_MachineTemplateSpec(in *clusterv1.MachineTemplateSpec, out *clusterv1beta1.MachineTemplateSpec, s apimachineryconversion.Scope) error { return clusterv1beta1.Convert_v1beta2_MachineTemplateSpec_To_v1beta1_MachineTemplateSpec(in, out, s) } + +func Convert_v1_Condition_To_v1beta1_Condition(in *metav1.Condition, out *clusterv1beta1.Condition, s apimachineryconversion.Scope) error { + return clusterv1beta1.Convert_v1_Condition_To_v1beta1_Condition(in, out, s) +} + +func Convert_v1beta1_Condition_To_v1_Condition(in *clusterv1beta1.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1beta1.Convert_v1beta1_Condition_To_v1_Condition(in, out, s) +} diff --git a/exp/api/v1beta1/conversion_test.go b/exp/api/v1beta1/conversion_test.go index 886c0b4e1b48..5b8eea2bdd38 100644 --- a/exp/api/v1beta1/conversion_test.go +++ b/exp/api/v1beta1/conversion_test.go @@ -21,6 +21,10 @@ package v1beta1 import ( "testing" + fuzz "github.com/google/gofuzz" + "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta2" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -29,7 +33,36 @@ import ( func TestFuzzyConversion(t *testing.T) { t.Run("for MachinePool", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Hub: &expv1.MachinePool{}, - Spoke: &MachinePool{}, + Hub: &expv1.MachinePool{}, + Spoke: &MachinePool{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachinePoolFuzzFuncs}, })) } + +func MachinePoolFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubMachinePoolStatus, + spokeMachinePoolStatus, + } +} + +func hubMachinePoolStatus(in *expv1.MachinePoolStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + } +} + +func spokeMachinePoolStatus(in *MachinePoolStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.V1Beta2 != nil { + if in.V1Beta2.Conditions == nil && in.V1Beta2.AvailableReplicas == nil && in.V1Beta2.ReadyReplicas == nil && in.V1Beta2.UpToDateReplicas == nil { + in.V1Beta2 = nil + } + } +} diff --git a/exp/api/v1beta1/machinepool_types.go b/exp/api/v1beta1/machinepool_types.go index bf770a24804c..538af0217d18 100644 --- a/exp/api/v1beta1/machinepool_types.go +++ b/exp/api/v1beta1/machinepool_types.go @@ -100,7 +100,7 @@ type MachinePoolStatus struct { // be machine instances that are running but not yet available or machine instances // that still have not been created. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"` @@ -108,7 +108,7 @@ type MachinePoolStatus struct { // failureReason indicates that there is a problem reconciling the state, and // will be set to a token value suitable for programmatic interpretation. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional FailureReason *capierrors.MachinePoolStatusFailure `json:"failureReason,omitempty"` @@ -116,7 +116,7 @@ type MachinePoolStatus struct { // failureMessage indicates that there is a problem reconciling the state, // and will be set to a descriptive error message. // - // Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + // Deprecated: This field 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. // // +optional // +kubebuilder:validation:MinLength=1 diff --git a/exp/api/v1beta1/zz_generated.conversion.go b/exp/api/v1beta1/zz_generated.conversion.go index 527730b74705..44f26bddf029 100644 --- a/exp/api/v1beta1/zz_generated.conversion.go +++ b/exp/api/v1beta1/zz_generated.conversion.go @@ -24,13 +24,12 @@ package v1beta1 import ( unsafe "unsafe" - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" apiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" apiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" - errors "sigs.k8s.io/cluster-api/errors" v1beta2 "sigs.k8s.io/cluster-api/exp/api/v1beta2" ) @@ -71,28 +70,28 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachinePoolStatus)(nil), (*v1beta2.MachinePoolStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_MachinePoolStatus_To_v1beta2_MachinePoolStatus(a.(*MachinePoolStatus), b.(*v1beta2.MachinePoolStatus), scope) + if err := s.AddConversionFunc((*v1.Condition)(nil), (*apiv1beta1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1beta1_Condition(a.(*v1.Condition), b.(*apiv1beta1.Condition), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta2.MachinePoolStatus)(nil), (*MachinePoolStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_MachinePoolStatus_To_v1beta1_MachinePoolStatus(a.(*v1beta2.MachinePoolStatus), b.(*MachinePoolStatus), scope) + if err := s.AddConversionFunc((*apiv1beta1.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_Condition_To_v1_Condition(a.(*apiv1beta1.Condition), b.(*v1.Condition), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachinePoolV1Beta2Status)(nil), (*v1beta2.MachinePoolV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_MachinePoolV1Beta2Status_To_v1beta2_MachinePoolV1Beta2Status(a.(*MachinePoolV1Beta2Status), b.(*v1beta2.MachinePoolV1Beta2Status), scope) + if err := s.AddConversionFunc((*MachinePoolStatus)(nil), (*v1beta2.MachinePoolStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_MachinePoolStatus_To_v1beta2_MachinePoolStatus(a.(*MachinePoolStatus), b.(*v1beta2.MachinePoolStatus), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta2.MachinePoolV1Beta2Status)(nil), (*MachinePoolV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_MachinePoolV1Beta2Status_To_v1beta1_MachinePoolV1Beta2Status(a.(*v1beta2.MachinePoolV1Beta2Status), b.(*MachinePoolV1Beta2Status), scope) + if err := s.AddConversionFunc((*apiv1beta1.MachineTemplateSpec)(nil), (*apiv1beta2.MachineTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_MachineTemplateSpec_To_v1beta2_MachineTemplateSpec(a.(*apiv1beta1.MachineTemplateSpec), b.(*apiv1beta2.MachineTemplateSpec), scope) }); err != nil { return err } - if err := s.AddConversionFunc((*apiv1beta1.MachineTemplateSpec)(nil), (*apiv1beta2.MachineTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_MachineTemplateSpec_To_v1beta2_MachineTemplateSpec(a.(*apiv1beta1.MachineTemplateSpec), b.(*apiv1beta2.MachineTemplateSpec), scope) + if err := s.AddConversionFunc((*v1beta2.MachinePoolStatus)(nil), (*MachinePoolStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_MachinePoolStatus_To_v1beta1_MachinePoolStatus(a.(*v1beta2.MachinePoolStatus), b.(*MachinePoolStatus), scope) }); err != nil { return err } @@ -213,71 +212,61 @@ func Convert_v1beta2_MachinePoolSpec_To_v1beta1_MachinePoolSpec(in *v1beta2.Mach } func autoConvert_v1beta1_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachinePoolStatus, out *v1beta2.MachinePoolStatus, s conversion.Scope) error { - out.NodeRefs = *(*[]v1.ObjectReference)(unsafe.Pointer(&in.NodeRefs)) + out.NodeRefs = *(*[]corev1.ObjectReference)(unsafe.Pointer(&in.NodeRefs)) out.Replicas = in.Replicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas - out.UnavailableReplicas = in.UnavailableReplicas - out.FailureReason = (*errors.MachinePoolStatusFailure)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + if err := v1.Convert_int32_To_Pointer_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_int32_To_Pointer_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UnavailableReplicas requires manual conversion: does not exist in peer-type + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.Phase = in.Phase out.BootstrapReady = in.BootstrapReady out.InfrastructureReady = in.InfrastructureReady out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*apiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*v1beta2.MachinePoolV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_MachinePoolStatus_To_v1beta2_MachinePoolStatus is an autogenerated conversion function. -func Convert_v1beta1_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachinePoolStatus, out *v1beta2.MachinePoolStatus, s conversion.Scope) error { - return autoConvert_v1beta1_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in, out, s) -} - func autoConvert_v1beta2_MachinePoolStatus_To_v1beta1_MachinePoolStatus(in *v1beta2.MachinePoolStatus, out *MachinePoolStatus, s conversion.Scope) error { - out.NodeRefs = *(*[]v1.ObjectReference)(unsafe.Pointer(&in.NodeRefs)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(apiv1beta1.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1beta1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + out.NodeRefs = *(*[]corev1.ObjectReference)(unsafe.Pointer(&in.NodeRefs)) out.Replicas = in.Replicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas - out.UnavailableReplicas = in.UnavailableReplicas - out.FailureReason = (*errors.MachinePoolStatusFailure)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + if err := v1.Convert_Pointer_int32_To_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int32_To_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UpToDateReplicas requires manual conversion: does not exist in peer-type out.Phase = in.Phase out.BootstrapReady = in.BootstrapReady out.InfrastructureReady = in.InfrastructureReady out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*MachinePoolV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } - -// Convert_v1beta2_MachinePoolStatus_To_v1beta1_MachinePoolStatus is an autogenerated conversion function. -func Convert_v1beta2_MachinePoolStatus_To_v1beta1_MachinePoolStatus(in *v1beta2.MachinePoolStatus, out *MachinePoolStatus, s conversion.Scope) error { - return autoConvert_v1beta2_MachinePoolStatus_To_v1beta1_MachinePoolStatus(in, out, s) -} - -func autoConvert_v1beta1_MachinePoolV1Beta2Status_To_v1beta2_MachinePoolV1Beta2Status(in *MachinePoolV1Beta2Status, out *v1beta2.MachinePoolV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - out.ReadyReplicas = (*int32)(unsafe.Pointer(in.ReadyReplicas)) - out.AvailableReplicas = (*int32)(unsafe.Pointer(in.AvailableReplicas)) - out.UpToDateReplicas = (*int32)(unsafe.Pointer(in.UpToDateReplicas)) - return nil -} - -// Convert_v1beta1_MachinePoolV1Beta2Status_To_v1beta2_MachinePoolV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta1_MachinePoolV1Beta2Status_To_v1beta2_MachinePoolV1Beta2Status(in *MachinePoolV1Beta2Status, out *v1beta2.MachinePoolV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta1_MachinePoolV1Beta2Status_To_v1beta2_MachinePoolV1Beta2Status(in, out, s) -} - -func autoConvert_v1beta2_MachinePoolV1Beta2Status_To_v1beta1_MachinePoolV1Beta2Status(in *v1beta2.MachinePoolV1Beta2Status, out *MachinePoolV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]metav1.Condition)(unsafe.Pointer(&in.Conditions)) - out.ReadyReplicas = (*int32)(unsafe.Pointer(in.ReadyReplicas)) - out.AvailableReplicas = (*int32)(unsafe.Pointer(in.AvailableReplicas)) - out.UpToDateReplicas = (*int32)(unsafe.Pointer(in.UpToDateReplicas)) - return nil -} - -// Convert_v1beta2_MachinePoolV1Beta2Status_To_v1beta1_MachinePoolV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta2_MachinePoolV1Beta2Status_To_v1beta1_MachinePoolV1Beta2Status(in *v1beta2.MachinePoolV1Beta2Status, out *MachinePoolV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta2_MachinePoolV1Beta2Status_To_v1beta1_MachinePoolV1Beta2Status(in, out, s) -} diff --git a/exp/ipam/api/v1alpha1/conversion.go b/exp/ipam/api/v1alpha1/conversion.go index b7315991737c..85024f83eaa0 100644 --- a/exp/ipam/api/v1alpha1/conversion.go +++ b/exp/ipam/api/v1alpha1/conversion.go @@ -20,6 +20,7 @@ import ( apiconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" + clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2" ipamv1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta2" utilconversion "sigs.k8s.io/cluster-api/util/conversion" @@ -44,6 +45,13 @@ func (src *IPAddressClaim) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1beta1) to the deprecated field. + if src.Status.Conditions != nil { + dst.Status.Deprecated = &ipamv1.IPAddressClaimDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &ipamv1.IPAddressClaimV1Beta1DeprecatedStatus{} + clusterv1beta1.Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + if src.ObjectMeta.Labels != nil { dst.Spec.ClusterName = src.ObjectMeta.Labels[clusterv1.ClusterNameLabel] if dst.ObjectMeta.Annotations != nil { @@ -61,8 +69,7 @@ func (src *IPAddressClaim) ConvertTo(dstRaw conversion.Hub) error { if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { return err } - - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions return nil } @@ -74,6 +81,19 @@ func (dst *IPAddressClaim) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). + dst.Status.Conditions = nil + + // Retrieve legacy conditions (v1beta1) from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + clusterv1beta1.Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + } + } + if src.Spec.ClusterName != "" { if dst.ObjectMeta.Labels == nil { dst.ObjectMeta.Labels = map[string]string{} @@ -91,7 +111,6 @@ func (dst *IPAddressClaim) ConvertFrom(srcRaw conversion.Hub) error { if err := utilconversion.MarshalData(src, dst); err != nil { return err } - return nil } diff --git a/exp/ipam/api/v1alpha1/conversion_test.go b/exp/ipam/api/v1alpha1/conversion_test.go index 7a284b70382e..982d4b8a1f55 100644 --- a/exp/ipam/api/v1alpha1/conversion_test.go +++ b/exp/ipam/api/v1alpha1/conversion_test.go @@ -21,7 +21,9 @@ package v1alpha1 import ( "testing" + fuzz "github.com/google/gofuzz" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" ipamv1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta2" utilconversion "sigs.k8s.io/cluster-api/util/conversion" @@ -31,13 +33,28 @@ import ( func TestFuzzyConversion(t *testing.T) { t.Run("for IPAddress", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Hub: &ipamv1.IPAddress{}, - Spoke: &IPAddress{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + Hub: &ipamv1.IPAddress{}, + Spoke: &IPAddress{}, })) t.Run("for IPAddressClaim", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &ipamv1.IPAddressClaim{}, Spoke: &IPAddressClaim{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{IPAddressClaimFuzzFuncs}, })) } + +func IPAddressClaimFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubIPAddressClaimStatus, + } +} + +func hubIPAddressClaimStatus(in *ipamv1.IPAddressClaimStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + in.Deprecated = nil + } + } +} diff --git a/exp/ipam/api/v1alpha1/zz_generated.conversion.go b/exp/ipam/api/v1alpha1/zz_generated.conversion.go index 0839538d78a0..e55d9ece2a92 100644 --- a/exp/ipam/api/v1alpha1/zz_generated.conversion.go +++ b/exp/ipam/api/v1alpha1/zz_generated.conversion.go @@ -24,10 +24,11 @@ package v1alpha1 import ( unsafe "unsafe" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" - v1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" - apiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" + apiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" + v1beta1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1" v1beta2 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta2" ) @@ -229,7 +230,17 @@ func autoConvert_v1beta2_IPAddressClaimSpec_To_v1alpha1_IPAddressClaimSpec(in *v func autoConvert_v1alpha1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus(in *IPAddressClaimStatus, out *v1beta2.IPAddressClaimStatus, s conversion.Scope) error { out.AddressRef = in.AddressRef - out.Conditions = *(*apiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := v1beta1.Convert_v1beta1_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } @@ -239,9 +250,19 @@ func Convert_v1alpha1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus(in *I } func autoConvert_v1beta2_IPAddressClaimStatus_To_v1alpha1_IPAddressClaimStatus(in *v1beta2.IPAddressClaimStatus, out *IPAddressClaimStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(apiv1beta1.Conditions, len(*in)) + for i := range *in { + if err := v1beta1.Convert_v1_Condition_To_v1beta1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.AddressRef = in.AddressRef - out.Conditions = *(*v1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } diff --git a/exp/ipam/api/v1beta1/conversion.go b/exp/ipam/api/v1beta1/conversion.go index 56a3f2f9a483..b87a00c6e74e 100644 --- a/exp/ipam/api/v1beta1/conversion.go +++ b/exp/ipam/api/v1beta1/conversion.go @@ -17,8 +17,11 @@ limitations under the License. package v1beta1 import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" + clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" ipamv1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta2" ) @@ -45,3 +48,65 @@ func (dst *IPAddressClaim) ConvertFrom(srcRaw conversion.Hub) error { return Convert_v1beta2_IPAddressClaim_To_v1beta1_IPAddressClaim(src, dst, nil) } + +func Convert_v1beta2_IPAddressClaimStatus_To_v1beta1_IPAddressClaimStatus(in *ipamv1.IPAddressClaimStatus, out *IPAddressClaimStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta2_IPAddressClaimStatus_To_v1beta1_IPAddressClaimStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). + out.Conditions = nil + + // Retrieve legacy conditions (v1beta1), failureReason and failureMessage from the deprecated field. + if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { + if in.Deprecated.V1Beta1.Conditions != nil { + clusterv1beta1.Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + } + } + + // Move new conditions (v1beta2) to the v1beta2 field. + if in.Conditions == nil { + return nil + } + out.V1Beta2 = &IPAddressClaimV1Beta2Status{} + out.V1Beta2.Conditions = in.Conditions + return nil +} + +func Convert_v1beta1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus(in *IPAddressClaimStatus, out *ipamv1.IPAddressClaimStatus, s apimachineryconversion.Scope) error { + if err := autoConvert_v1beta1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus(in, out, s); err != nil { + return err + } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. + out.Conditions = nil + + // Retrieve new conditions (v1beta2) from the v1beta2 field. + if in.V1Beta2 != nil { + out.Conditions = in.V1Beta2.Conditions + } + + // Move legacy conditions (v1beta1), failureReason and failureMessage to the deprecated field. + if out.Deprecated == nil { + out.Deprecated = &ipamv1.IPAddressClaimDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &ipamv1.IPAddressClaimV1Beta1DeprecatedStatus{} + } + if in.Conditions != nil { + clusterv1beta1.Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + } + return nil +} + +// Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) + +func Convert_v1_Condition_To_v1beta1_Condition(in *metav1.Condition, out *clusterv1beta1.Condition, s apimachineryconversion.Scope) error { + return clusterv1beta1.Convert_v1_Condition_To_v1beta1_Condition(in, out, s) +} + +func Convert_v1beta1_Condition_To_v1_Condition(in *clusterv1beta1.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1beta1.Convert_v1beta1_Condition_To_v1_Condition(in, out, s) +} diff --git a/exp/ipam/api/v1beta1/conversion_test.go b/exp/ipam/api/v1beta1/conversion_test.go index 15087769b8d8..32929da5d661 100644 --- a/exp/ipam/api/v1beta1/conversion_test.go +++ b/exp/ipam/api/v1beta1/conversion_test.go @@ -21,7 +21,9 @@ package v1beta1 import ( "testing" + fuzz "github.com/google/gofuzz" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" ipamv1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta2" utilconversion "sigs.k8s.io/cluster-api/util/conversion" @@ -31,13 +33,40 @@ import ( func TestFuzzyConversion(t *testing.T) { t.Run("for IPAddress", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Hub: &ipamv1.IPAddress{}, - Spoke: &IPAddress{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + Hub: &ipamv1.IPAddress{}, + Spoke: &IPAddress{}, })) t.Run("for IPAddressClaim", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &ipamv1.IPAddressClaim{}, Spoke: &IPAddressClaim{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{IPAddressClaimFuzzFuncs}, })) } + +func IPAddressClaimFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubIPAddressClaimStatus, + spokeIPAddressClaimStatus, + } +} + +func hubIPAddressClaimStatus(in *ipamv1.IPAddressClaimStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &ipamv1.IPAddressClaimDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &ipamv1.IPAddressClaimV1Beta1DeprecatedStatus{} + } +} + +func spokeIPAddressClaimStatus(in *IPAddressClaimStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.V1Beta2 != nil { + if in.V1Beta2.Conditions == nil { + in.V1Beta2 = nil + } + } +} diff --git a/exp/ipam/api/v1beta1/zz_generated.conversion.go b/exp/ipam/api/v1beta1/zz_generated.conversion.go index 092988f64d75..b8b74faac53e 100644 --- a/exp/ipam/api/v1beta1/zz_generated.conversion.go +++ b/exp/ipam/api/v1beta1/zz_generated.conversion.go @@ -28,7 +28,6 @@ import ( conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" apiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" - apiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" v1beta2 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta2" ) @@ -79,43 +78,43 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*IPAddressClaimStatus)(nil), (*v1beta2.IPAddressClaimStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus(a.(*IPAddressClaimStatus), b.(*v1beta2.IPAddressClaimStatus), scope) + if err := s.AddGeneratedConversionFunc((*IPAddressList)(nil), (*v1beta2.IPAddressList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_IPAddressList_To_v1beta2_IPAddressList(a.(*IPAddressList), b.(*v1beta2.IPAddressList), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta2.IPAddressClaimStatus)(nil), (*IPAddressClaimStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_IPAddressClaimStatus_To_v1beta1_IPAddressClaimStatus(a.(*v1beta2.IPAddressClaimStatus), b.(*IPAddressClaimStatus), scope) + if err := s.AddGeneratedConversionFunc((*v1beta2.IPAddressList)(nil), (*IPAddressList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_IPAddressList_To_v1beta1_IPAddressList(a.(*v1beta2.IPAddressList), b.(*IPAddressList), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*IPAddressClaimV1Beta2Status)(nil), (*v1beta2.IPAddressClaimV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_IPAddressClaimV1Beta2Status_To_v1beta2_IPAddressClaimV1Beta2Status(a.(*IPAddressClaimV1Beta2Status), b.(*v1beta2.IPAddressClaimV1Beta2Status), scope) + if err := s.AddGeneratedConversionFunc((*IPAddressSpec)(nil), (*v1beta2.IPAddressSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_IPAddressSpec_To_v1beta2_IPAddressSpec(a.(*IPAddressSpec), b.(*v1beta2.IPAddressSpec), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta2.IPAddressClaimV1Beta2Status)(nil), (*IPAddressClaimV1Beta2Status)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_IPAddressClaimV1Beta2Status_To_v1beta1_IPAddressClaimV1Beta2Status(a.(*v1beta2.IPAddressClaimV1Beta2Status), b.(*IPAddressClaimV1Beta2Status), scope) + if err := s.AddGeneratedConversionFunc((*v1beta2.IPAddressSpec)(nil), (*IPAddressSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_IPAddressSpec_To_v1beta1_IPAddressSpec(a.(*v1beta2.IPAddressSpec), b.(*IPAddressSpec), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*IPAddressList)(nil), (*v1beta2.IPAddressList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_IPAddressList_To_v1beta2_IPAddressList(a.(*IPAddressList), b.(*v1beta2.IPAddressList), scope) + if err := s.AddConversionFunc((*v1.Condition)(nil), (*apiv1beta1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1beta1_Condition(a.(*v1.Condition), b.(*apiv1beta1.Condition), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta2.IPAddressList)(nil), (*IPAddressList)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_IPAddressList_To_v1beta1_IPAddressList(a.(*v1beta2.IPAddressList), b.(*IPAddressList), scope) + if err := s.AddConversionFunc((*apiv1beta1.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_Condition_To_v1_Condition(a.(*apiv1beta1.Condition), b.(*v1.Condition), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*IPAddressSpec)(nil), (*v1beta2.IPAddressSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_IPAddressSpec_To_v1beta2_IPAddressSpec(a.(*IPAddressSpec), b.(*v1beta2.IPAddressSpec), scope) + if err := s.AddConversionFunc((*IPAddressClaimStatus)(nil), (*v1beta2.IPAddressClaimStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus(a.(*IPAddressClaimStatus), b.(*v1beta2.IPAddressClaimStatus), scope) }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*v1beta2.IPAddressSpec)(nil), (*IPAddressSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_IPAddressSpec_To_v1beta1_IPAddressSpec(a.(*v1beta2.IPAddressSpec), b.(*IPAddressSpec), scope) + if err := s.AddConversionFunc((*v1beta2.IPAddressClaimStatus)(nil), (*IPAddressClaimStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_IPAddressClaimStatus_To_v1beta1_IPAddressClaimStatus(a.(*v1beta2.IPAddressClaimStatus), b.(*IPAddressClaimStatus), scope) }); err != nil { return err } @@ -182,7 +181,17 @@ func Convert_v1beta2_IPAddressClaim_To_v1beta1_IPAddressClaim(in *v1beta2.IPAddr func autoConvert_v1beta1_IPAddressClaimList_To_v1beta2_IPAddressClaimList(in *IPAddressClaimList, out *v1beta2.IPAddressClaimList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]v1beta2.IPAddressClaim)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]v1beta2.IPAddressClaim, len(*in)) + for i := range *in { + if err := Convert_v1beta1_IPAddressClaim_To_v1beta2_IPAddressClaim(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -193,7 +202,17 @@ func Convert_v1beta1_IPAddressClaimList_To_v1beta2_IPAddressClaimList(in *IPAddr func autoConvert_v1beta2_IPAddressClaimList_To_v1beta1_IPAddressClaimList(in *v1beta2.IPAddressClaimList, out *IPAddressClaimList, s conversion.Scope) error { out.ListMeta = in.ListMeta - out.Items = *(*[]IPAddressClaim)(unsafe.Pointer(&in.Items)) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IPAddressClaim, len(*in)) + for i := range *in { + if err := Convert_v1beta2_IPAddressClaim_To_v1beta1_IPAddressClaim(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Items = nil + } return nil } @@ -226,48 +245,38 @@ func Convert_v1beta2_IPAddressClaimSpec_To_v1beta1_IPAddressClaimSpec(in *v1beta func autoConvert_v1beta1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus(in *IPAddressClaimStatus, out *v1beta2.IPAddressClaimStatus, s conversion.Scope) error { out.AddressRef = in.AddressRef - out.Conditions = *(*apiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*v1beta2.IPAddressClaimV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1beta1_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus is an autogenerated conversion function. -func Convert_v1beta1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus(in *IPAddressClaimStatus, out *v1beta2.IPAddressClaimStatus, s conversion.Scope) error { - return autoConvert_v1beta1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus(in, out, s) -} - func autoConvert_v1beta2_IPAddressClaimStatus_To_v1beta1_IPAddressClaimStatus(in *v1beta2.IPAddressClaimStatus, out *IPAddressClaimStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(apiv1beta1.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1beta1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.AddressRef = in.AddressRef - out.Conditions = *(*apiv1beta1.Conditions)(unsafe.Pointer(&in.Conditions)) - out.V1Beta2 = (*IPAddressClaimV1Beta2Status)(unsafe.Pointer(in.V1Beta2)) + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } -// Convert_v1beta2_IPAddressClaimStatus_To_v1beta1_IPAddressClaimStatus is an autogenerated conversion function. -func Convert_v1beta2_IPAddressClaimStatus_To_v1beta1_IPAddressClaimStatus(in *v1beta2.IPAddressClaimStatus, out *IPAddressClaimStatus, s conversion.Scope) error { - return autoConvert_v1beta2_IPAddressClaimStatus_To_v1beta1_IPAddressClaimStatus(in, out, s) -} - -func autoConvert_v1beta1_IPAddressClaimV1Beta2Status_To_v1beta2_IPAddressClaimV1Beta2Status(in *IPAddressClaimV1Beta2Status, out *v1beta2.IPAddressClaimV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]v1.Condition)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta1_IPAddressClaimV1Beta2Status_To_v1beta2_IPAddressClaimV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta1_IPAddressClaimV1Beta2Status_To_v1beta2_IPAddressClaimV1Beta2Status(in *IPAddressClaimV1Beta2Status, out *v1beta2.IPAddressClaimV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta1_IPAddressClaimV1Beta2Status_To_v1beta2_IPAddressClaimV1Beta2Status(in, out, s) -} - -func autoConvert_v1beta2_IPAddressClaimV1Beta2Status_To_v1beta1_IPAddressClaimV1Beta2Status(in *v1beta2.IPAddressClaimV1Beta2Status, out *IPAddressClaimV1Beta2Status, s conversion.Scope) error { - out.Conditions = *(*[]v1.Condition)(unsafe.Pointer(&in.Conditions)) - return nil -} - -// Convert_v1beta2_IPAddressClaimV1Beta2Status_To_v1beta1_IPAddressClaimV1Beta2Status is an autogenerated conversion function. -func Convert_v1beta2_IPAddressClaimV1Beta2Status_To_v1beta1_IPAddressClaimV1Beta2Status(in *v1beta2.IPAddressClaimV1Beta2Status, out *IPAddressClaimV1Beta2Status, s conversion.Scope) error { - return autoConvert_v1beta2_IPAddressClaimV1Beta2Status_To_v1beta1_IPAddressClaimV1Beta2Status(in, out, s) -} - func autoConvert_v1beta1_IPAddressList_To_v1beta2_IPAddressList(in *IPAddressList, out *v1beta2.IPAddressList, s conversion.Scope) error { out.ListMeta = in.ListMeta out.Items = *(*[]v1beta2.IPAddress)(unsafe.Pointer(&in.Items)) diff --git a/internal/apis/addons/v1alpha3/conversion.go b/internal/apis/addons/v1alpha3/conversion.go index 06e2f2934bea..eddd71600f74 100644 --- a/internal/apis/addons/v1alpha3/conversion.go +++ b/internal/apis/addons/v1alpha3/conversion.go @@ -17,11 +17,12 @@ limitations under the License. package v1alpha3 import ( - apiconversion "k8s.io/apimachinery/pkg/conversion" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" addonsv1 "sigs.k8s.io/cluster-api/api/addons/v1beta2" - + clusterv1alpha3 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha3" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -32,12 +33,21 @@ func (src *ClusterResourceSet) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha3) to the deprecated field. + if src.Status.Conditions != nil { + dst.Status.Deprecated = &addonsv1.ClusterResourceSetDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &addonsv1.ClusterResourceSetV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + clusterv1alpha3.Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + } + // Manually restore data. restored := &addonsv1.ClusterResourceSet{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { return err } - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions return nil } @@ -49,6 +59,19 @@ func (dst *ClusterResourceSet) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha3). + dst.Status.Conditions = nil + + // Retrieve legacy conditions (v1alpha3) from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + clusterv1alpha3.Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + } + } + // Preserve Hub data on down-conversion except for metadata return utilconversion.MarshalData(src, dst) } @@ -84,12 +107,22 @@ func (dst *ClusterResourceSetBinding) ConvertFrom(srcRaw conversion.Hub) error { } // Convert_v1beta2_ClusterResourceSetBindingSpec_To_v1alpha3_ClusterResourceSetBindingSpec is a conversion function. -func Convert_v1beta2_ClusterResourceSetBindingSpec_To_v1alpha3_ClusterResourceSetBindingSpec(in *addonsv1.ClusterResourceSetBindingSpec, out *ClusterResourceSetBindingSpec, s apiconversion.Scope) error { +func Convert_v1beta2_ClusterResourceSetBindingSpec_To_v1alpha3_ClusterResourceSetBindingSpec(in *addonsv1.ClusterResourceSetBindingSpec, out *ClusterResourceSetBindingSpec, s apimachineryconversion.Scope) error { // Spec.ClusterName does not exist in ClusterResourceSetBinding v1alpha3 API. return autoConvert_v1beta2_ClusterResourceSetBindingSpec_To_v1alpha3_ClusterResourceSetBindingSpec(in, out, s) } -func Convert_v1beta2_ClusterResourceSetStatus_To_v1alpha3_ClusterResourceSetStatus(in *addonsv1.ClusterResourceSetStatus, out *ClusterResourceSetStatus, s apiconversion.Scope) error { +func Convert_v1beta2_ClusterResourceSetStatus_To_v1alpha3_ClusterResourceSetStatus(in *addonsv1.ClusterResourceSetStatus, out *ClusterResourceSetStatus, s apimachineryconversion.Scope) error { // V1Beta2 was added in v1beta1 return autoConvert_v1beta2_ClusterResourceSetStatus_To_v1alpha3_ClusterResourceSetStatus(in, out, s) } + +// Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) + +func Convert_v1_Condition_To_v1alpha3_Condition(in *metav1.Condition, out *clusterv1alpha3.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha3.Convert_v1_Condition_To_v1alpha3_Condition(in, out, s) +} + +func Convert_v1alpha3_Condition_To_v1_Condition(in *clusterv1alpha3.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha3.Convert_v1alpha3_Condition_To_v1_Condition(in, out, s) +} diff --git a/internal/apis/addons/v1alpha3/conversion_test.go b/internal/apis/addons/v1alpha3/conversion_test.go index e02bc7583953..e6b870d579f1 100644 --- a/internal/apis/addons/v1alpha3/conversion_test.go +++ b/internal/apis/addons/v1alpha3/conversion_test.go @@ -21,6 +21,10 @@ package v1alpha3 import ( "testing" + fuzz "github.com/google/gofuzz" + "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" + addonsv1 "sigs.k8s.io/cluster-api/api/addons/v1beta2" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -29,11 +33,28 @@ import ( func TestFuzzyConversion(t *testing.T) { t.Run("for ClusterResourceSet", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Hub: &addonsv1.ClusterResourceSet{}, - Spoke: &ClusterResourceSet{}, + Hub: &addonsv1.ClusterResourceSet{}, + Spoke: &ClusterResourceSet{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{ClusterResourceSetFuzzFuncs}, })) t.Run("for ClusterResourceSetBinding", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &addonsv1.ClusterResourceSetBinding{}, Spoke: &ClusterResourceSetBinding{}, })) } + +func ClusterResourceSetFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubClusterResourceSetStatus, + } +} + +func hubClusterResourceSetStatus(in *addonsv1.ClusterResourceSetStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + in.Deprecated = nil + } + } +} diff --git a/internal/apis/addons/v1alpha3/zz_generated.conversion.go b/internal/apis/addons/v1alpha3/zz_generated.conversion.go index 5832f4c1fbbc..aa2f8f38ff07 100644 --- a/internal/apis/addons/v1alpha3/zz_generated.conversion.go +++ b/internal/apis/addons/v1alpha3/zz_generated.conversion.go @@ -28,7 +28,6 @@ import ( conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" v1beta2 "sigs.k8s.io/cluster-api/api/addons/v1beta2" - apiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" corev1alpha3 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha3" ) @@ -129,6 +128,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1.Condition)(nil), (*corev1alpha3.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1alpha3_Condition(a.(*v1.Condition), b.(*corev1alpha3.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*corev1alpha3.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha3_Condition_To_v1_Condition(a.(*corev1alpha3.Condition), b.(*v1.Condition), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1beta2.ClusterResourceSetBindingSpec)(nil), (*ClusterResourceSetBindingSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta2_ClusterResourceSetBindingSpec_To_v1alpha3_ClusterResourceSetBindingSpec(a.(*v1beta2.ClusterResourceSetBindingSpec), b.(*ClusterResourceSetBindingSpec), scope) }); err != nil { @@ -326,7 +335,17 @@ func Convert_v1beta2_ClusterResourceSetSpec_To_v1alpha3_ClusterResourceSetSpec(i func autoConvert_v1alpha3_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStatus(in *ClusterResourceSetStatus, out *v1beta2.ClusterResourceSetStatus, s conversion.Scope) error { out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*apiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha3_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } @@ -336,9 +355,19 @@ func Convert_v1alpha3_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStat } func autoConvert_v1beta2_ClusterResourceSetStatus_To_v1alpha3_ClusterResourceSetStatus(in *v1beta2.ClusterResourceSetStatus, out *ClusterResourceSetStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(corev1alpha3.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha3_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*corev1alpha3.Conditions)(unsafe.Pointer(&in.Conditions)) - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } diff --git a/internal/apis/addons/v1alpha4/conversion.go b/internal/apis/addons/v1alpha4/conversion.go index da4ce872a84b..99835a66f85c 100644 --- a/internal/apis/addons/v1alpha4/conversion.go +++ b/internal/apis/addons/v1alpha4/conversion.go @@ -17,10 +17,12 @@ limitations under the License. package v1alpha4 import ( - apiconversion "k8s.io/apimachinery/pkg/conversion" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" addonsv1 "sigs.k8s.io/cluster-api/api/addons/v1beta2" + clusterv1alpha4 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha4" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -32,12 +34,21 @@ func (src *ClusterResourceSet) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha4) to the deprecated field. + if src.Status.Conditions != nil { + dst.Status.Deprecated = &addonsv1.ClusterResourceSetDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &addonsv1.ClusterResourceSetV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + clusterv1alpha4.Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + } + // Manually restore data. restored := &addonsv1.ClusterResourceSet{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { return err } - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions return nil } @@ -49,6 +60,19 @@ func (dst *ClusterResourceSet) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha4). + dst.Status.Conditions = nil + + // Retrieve legacy conditions (v1alpha4) from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + clusterv1alpha4.Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + } + } + // Preserve Hub data on down-conversion except for metadata return utilconversion.MarshalData(src, dst) } @@ -84,12 +108,22 @@ func (dst *ClusterResourceSetBinding) ConvertFrom(srcRaw conversion.Hub) error { } // Convert_v1beta2_ClusterResourceSetBindingSpec_To_v1alpha4_ClusterResourceSetBindingSpec is a conversion function. -func Convert_v1beta2_ClusterResourceSetBindingSpec_To_v1alpha4_ClusterResourceSetBindingSpec(in *addonsv1.ClusterResourceSetBindingSpec, out *ClusterResourceSetBindingSpec, s apiconversion.Scope) error { +func Convert_v1beta2_ClusterResourceSetBindingSpec_To_v1alpha4_ClusterResourceSetBindingSpec(in *addonsv1.ClusterResourceSetBindingSpec, out *ClusterResourceSetBindingSpec, s apimachineryconversion.Scope) error { // Spec.ClusterName does not exist in ClusterResourceSetBinding v1alpha4 API. return autoConvert_v1beta2_ClusterResourceSetBindingSpec_To_v1alpha4_ClusterResourceSetBindingSpec(in, out, s) } -func Convert_v1beta2_ClusterResourceSetStatus_To_v1alpha4_ClusterResourceSetStatus(in *addonsv1.ClusterResourceSetStatus, out *ClusterResourceSetStatus, s apiconversion.Scope) error { +func Convert_v1beta2_ClusterResourceSetStatus_To_v1alpha4_ClusterResourceSetStatus(in *addonsv1.ClusterResourceSetStatus, out *ClusterResourceSetStatus, s apimachineryconversion.Scope) error { // V1Beta2 was added in v1beta1 return autoConvert_v1beta2_ClusterResourceSetStatus_To_v1alpha4_ClusterResourceSetStatus(in, out, s) } + +// Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) + +func Convert_v1_Condition_To_v1alpha4_Condition(in *metav1.Condition, out *clusterv1alpha4.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha4.Convert_v1_Condition_To_v1alpha4_Condition(in, out, s) +} + +func Convert_v1alpha4_Condition_To_v1_Condition(in *clusterv1alpha4.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha4.Convert_v1alpha4_Condition_To_v1_Condition(in, out, s) +} diff --git a/internal/apis/addons/v1alpha4/conversion_test.go b/internal/apis/addons/v1alpha4/conversion_test.go index cd61d0cbed52..f45fc0fbef5c 100644 --- a/internal/apis/addons/v1alpha4/conversion_test.go +++ b/internal/apis/addons/v1alpha4/conversion_test.go @@ -21,6 +21,10 @@ package v1alpha4 import ( "testing" + fuzz "github.com/google/gofuzz" + "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" + addonsv1 "sigs.k8s.io/cluster-api/api/addons/v1beta2" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -29,11 +33,28 @@ import ( func TestFuzzyConversion(t *testing.T) { t.Run("for ClusterResourceSet", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Hub: &addonsv1.ClusterResourceSet{}, - Spoke: &ClusterResourceSet{}, + Hub: &addonsv1.ClusterResourceSet{}, + Spoke: &ClusterResourceSet{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{ClusterResourceSetFuzzFuncs}, })) t.Run("for ClusterResourceSetBinding", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &addonsv1.ClusterResourceSetBinding{}, Spoke: &ClusterResourceSetBinding{}, })) } + +func ClusterResourceSetFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubClusterResourceSetStatus, + } +} + +func hubClusterResourceSetStatus(in *addonsv1.ClusterResourceSetStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + in.Deprecated = nil + } + } +} diff --git a/internal/apis/addons/v1alpha4/zz_generated.conversion.go b/internal/apis/addons/v1alpha4/zz_generated.conversion.go index 69a3dbcbe87f..1cfa9564b0b4 100644 --- a/internal/apis/addons/v1alpha4/zz_generated.conversion.go +++ b/internal/apis/addons/v1alpha4/zz_generated.conversion.go @@ -28,7 +28,6 @@ import ( conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" v1beta2 "sigs.k8s.io/cluster-api/api/addons/v1beta2" - apiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" corev1alpha4 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha4" ) @@ -129,6 +128,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1.Condition)(nil), (*corev1alpha4.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1alpha4_Condition(a.(*v1.Condition), b.(*corev1alpha4.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*corev1alpha4.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_Condition_To_v1_Condition(a.(*corev1alpha4.Condition), b.(*v1.Condition), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1beta2.ClusterResourceSetBindingSpec)(nil), (*ClusterResourceSetBindingSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta2_ClusterResourceSetBindingSpec_To_v1alpha4_ClusterResourceSetBindingSpec(a.(*v1beta2.ClusterResourceSetBindingSpec), b.(*ClusterResourceSetBindingSpec), scope) }); err != nil { @@ -326,7 +335,17 @@ func Convert_v1beta2_ClusterResourceSetSpec_To_v1alpha4_ClusterResourceSetSpec(i func autoConvert_v1alpha4_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStatus(in *ClusterResourceSetStatus, out *v1beta2.ClusterResourceSetStatus, s conversion.Scope) error { out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*apiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha4_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } @@ -336,9 +355,19 @@ func Convert_v1alpha4_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStat } func autoConvert_v1beta2_ClusterResourceSetStatus_To_v1alpha4_ClusterResourceSetStatus(in *v1beta2.ClusterResourceSetStatus, out *ClusterResourceSetStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(corev1alpha4.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha4_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*corev1alpha4.Conditions)(unsafe.Pointer(&in.Conditions)) - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } diff --git a/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go b/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go index 0a6af48c263a..ff1b0d5739fb 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go @@ -17,11 +17,13 @@ limitations under the License. package v1alpha3 import ( - apiconversion "k8s.io/apimachinery/pkg/conversion" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2" "sigs.k8s.io/cluster-api/bootstrap/kubeadm/types/upstreamv1beta1" + clusterv1alpha3 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha3" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -32,13 +34,22 @@ func (src *KubeadmConfig) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha3), failureReason and failureMessage to the deprecated field. + dst.Status.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &bootstrapv1.KubeadmConfigV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + clusterv1alpha3.Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason + dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage + // Manually restore data. restored := &bootstrapv1.KubeadmConfig{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { return err } MergeRestoredKubeadmConfigSpec(&dst.Spec, &restored.Spec) - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions return nil } @@ -119,6 +130,21 @@ func (dst *KubeadmConfig) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha4). + dst.Status.Conditions = nil + + // Retrieve legacy conditions (v1alpha4), failureReason and failureMessage from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + clusterv1alpha3.Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason + dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage + } + } + // Preserve Hub data on down-conversion except for metadata if err := utilconversion.MarshalData(src, dst); err != nil { return err @@ -162,12 +188,12 @@ func (dst *KubeadmConfigTemplate) ConvertFrom(srcRaw conversion.Hub) error { return nil } -func Convert_v1alpha3_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in *KubeadmConfigStatus, out *bootstrapv1.KubeadmConfigStatus, s apiconversion.Scope) error { +func Convert_v1alpha3_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in *KubeadmConfigStatus, out *bootstrapv1.KubeadmConfigStatus, s apimachineryconversion.Scope) error { // KubeadmConfigStatus.BootstrapData has been removed in v1alpha4 because its content has been moved to the bootstrap data secret, value will be lost during conversion. return autoConvert_v1alpha3_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in, out, s) } -func Convert_v1beta2_ClusterConfiguration_To_upstreamv1beta1_ClusterConfiguration(in *bootstrapv1.ClusterConfiguration, out *upstreamv1beta1.ClusterConfiguration, s apiconversion.Scope) error { +func Convert_v1beta2_ClusterConfiguration_To_upstreamv1beta1_ClusterConfiguration(in *bootstrapv1.ClusterConfiguration, out *upstreamv1beta1.ClusterConfiguration, s apimachineryconversion.Scope) error { // DNS.Type was removed in v1alpha4 because only CoreDNS is supported; the information will be left to empty (kubeadm defaults it to CoredDNS); // Existing clusters using kube-dns or other DNS solutions will continue to be managed/supported via the skip-coredns annotation. @@ -175,54 +201,66 @@ func Convert_v1beta2_ClusterConfiguration_To_upstreamv1beta1_ClusterConfiguratio return upstreamv1beta1.Convert_v1beta2_ClusterConfiguration_To_upstreamv1beta1_ClusterConfiguration(in, out, s) } -func Convert_upstreamv1beta1_ClusterConfiguration_To_v1beta2_ClusterConfiguration(in *upstreamv1beta1.ClusterConfiguration, out *bootstrapv1.ClusterConfiguration, s apiconversion.Scope) error { +func Convert_upstreamv1beta1_ClusterConfiguration_To_v1beta2_ClusterConfiguration(in *upstreamv1beta1.ClusterConfiguration, out *bootstrapv1.ClusterConfiguration, s apimachineryconversion.Scope) error { // DNS.Type was removed in v1alpha4 because only CoreDNS is supported; the information will be left to empty (kubeadm defaults it to CoredDNS); // ClusterConfiguration.UseHyperKubeImage was removed in kubeadm v1alpha4 API return upstreamv1beta1.Convert_upstreamv1beta1_ClusterConfiguration_To_v1beta2_ClusterConfiguration(in, out, s) } -func Convert_upstreamv1beta1_InitConfiguration_To_v1beta2_InitConfiguration(in *upstreamv1beta1.InitConfiguration, out *bootstrapv1.InitConfiguration, s apiconversion.Scope) error { +func Convert_upstreamv1beta1_InitConfiguration_To_v1beta2_InitConfiguration(in *upstreamv1beta1.InitConfiguration, out *bootstrapv1.InitConfiguration, s apimachineryconversion.Scope) error { // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API return upstreamv1beta1.Convert_upstreamv1beta1_InitConfiguration_To_v1beta2_InitConfiguration(in, out, s) } -func Convert_v1beta2_InitConfiguration_To_upstreamv1beta1_InitConfiguration(in *bootstrapv1.InitConfiguration, out *upstreamv1beta1.InitConfiguration, s apiconversion.Scope) error { +func Convert_v1beta2_InitConfiguration_To_upstreamv1beta1_InitConfiguration(in *bootstrapv1.InitConfiguration, out *upstreamv1beta1.InitConfiguration, s apimachineryconversion.Scope) error { // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API return upstreamv1beta1.Convert_v1beta2_InitConfiguration_To_upstreamv1beta1_InitConfiguration(in, out, s) } -func Convert_upstreamv1beta1_JoinConfiguration_To_v1beta2_JoinConfiguration(in *upstreamv1beta1.JoinConfiguration, out *bootstrapv1.JoinConfiguration, s apiconversion.Scope) error { +func Convert_upstreamv1beta1_JoinConfiguration_To_v1beta2_JoinConfiguration(in *upstreamv1beta1.JoinConfiguration, out *bootstrapv1.JoinConfiguration, s apimachineryconversion.Scope) error { // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API return upstreamv1beta1.Convert_upstreamv1beta1_JoinConfiguration_To_v1beta2_JoinConfiguration(in, out, s) } -func Convert_v1beta2_JoinConfiguration_To_upstreamv1beta1_JoinConfiguration(in *bootstrapv1.JoinConfiguration, out *upstreamv1beta1.JoinConfiguration, s apiconversion.Scope) error { +func Convert_v1beta2_JoinConfiguration_To_upstreamv1beta1_JoinConfiguration(in *bootstrapv1.JoinConfiguration, out *upstreamv1beta1.JoinConfiguration, s apimachineryconversion.Scope) error { // NodeRegistrationOptions.IgnorePreflightErrors does not exist in kubeadm v1beta1 API return upstreamv1beta1.Convert_v1beta2_JoinConfiguration_To_upstreamv1beta1_JoinConfiguration(in, out, s) } // Convert_v1beta2_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec is an autogenerated conversion function. -func Convert_v1beta2_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in *bootstrapv1.KubeadmConfigSpec, out *KubeadmConfigSpec, s apiconversion.Scope) error { +func Convert_v1beta2_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in *bootstrapv1.KubeadmConfigSpec, out *KubeadmConfigSpec, s apimachineryconversion.Scope) error { // KubeadmConfigSpec.Ignition does not exist in kubeadm v1alpha3 API. return autoConvert_v1beta2_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in, out, s) } -func Convert_v1beta2_File_To_v1alpha3_File(in *bootstrapv1.File, out *File, s apiconversion.Scope) error { +func Convert_v1beta2_File_To_v1alpha3_File(in *bootstrapv1.File, out *File, s apimachineryconversion.Scope) error { // File.Append does not exist in kubeadm v1alpha3 API. return autoConvert_v1beta2_File_To_v1alpha3_File(in, out, s) } -func Convert_v1beta2_User_To_v1alpha3_User(in *bootstrapv1.User, out *User, s apiconversion.Scope) error { +func Convert_v1beta2_User_To_v1alpha3_User(in *bootstrapv1.User, out *User, s apimachineryconversion.Scope) error { // User.PasswdFrom does not exist in kubeadm v1alpha3 API. return autoConvert_v1beta2_User_To_v1alpha3_User(in, out, s) } -func Convert_v1beta2_KubeadmConfigTemplateResource_To_v1alpha3_KubeadmConfigTemplateResource(in *bootstrapv1.KubeadmConfigTemplateResource, out *KubeadmConfigTemplateResource, s apiconversion.Scope) error { +func Convert_v1beta2_KubeadmConfigTemplateResource_To_v1alpha3_KubeadmConfigTemplateResource(in *bootstrapv1.KubeadmConfigTemplateResource, out *KubeadmConfigTemplateResource, s apimachineryconversion.Scope) error { // KubeadmConfigTemplateResource.metadata does not exist in kubeadm v1alpha3. return autoConvert_v1beta2_KubeadmConfigTemplateResource_To_v1alpha3_KubeadmConfigTemplateResource(in, out, s) } -func Convert_v1beta2_KubeadmConfigStatus_To_v1alpha3_KubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, out *KubeadmConfigStatus, s apiconversion.Scope) error { +func Convert_v1beta2_KubeadmConfigStatus_To_v1alpha3_KubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, out *KubeadmConfigStatus, s apimachineryconversion.Scope) error { // V1Beta2 was added in v1beta1. return autoConvert_v1beta2_KubeadmConfigStatus_To_v1alpha3_KubeadmConfigStatus(in, out, s) } + +// Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) + +func Convert_v1_Condition_To_v1alpha3_Condition(_ *metav1.Condition, _ *clusterv1alpha3.Condition, _ apimachineryconversion.Scope) error { + // NOTE: v1beta2 conditions should not be automatically converted into v1beta1 conditions. + return nil +} + +func Convert_v1alpha3_Condition_To_v1_Condition(_ *clusterv1alpha3.Condition, _ *metav1.Condition, _ apimachineryconversion.Scope) error { + // NOTE: v1beta1 conditions should not be automatically converted into v1beta2 conditions. + return nil +} diff --git a/internal/apis/bootstrap/kubeadm/v1alpha3/conversion_test.go b/internal/apis/bootstrap/kubeadm/v1alpha3/conversion_test.go index 3c6b71c90486..d4a3abf40021 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha3/conversion_test.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha3/conversion_test.go @@ -36,20 +36,21 @@ func TestFuzzyConversion(t *testing.T) { t.Run("for KubeadmConfig", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &bootstrapv1.KubeadmConfig{}, Spoke: &KubeadmConfig{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{KubeadmConfigFuzzFuncs}, })) t.Run("for KubeadmConfigTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &bootstrapv1.KubeadmConfigTemplate{}, Spoke: &KubeadmConfigTemplate{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{KubeadmConfigTemplateFuzzFuncs}, })) } -func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { +func KubeadmConfigFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - KubeadmConfigStatusFuzzer, - dnsFuzzer, - clusterConfigurationFuzzer, + spokeKubeadmConfigStatus, + spokeDNS, + spokeClusterConfiguration, + hubKubeadmConfigStatus, // This custom functions are needed when ConvertTo/ConvertFrom functions // uses the json package to unmarshal the bootstrap token string. // @@ -60,38 +61,69 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { // // This function effectively disables any fuzzing for the token by setting // the values for ID and Secret to working alphanumeric values. - kubeadmBootstrapTokenStringFuzzerV1UpstreamBeta1, - kubeadmBootstrapTokenStringFuzzerV1Beta1, + spokeKubeadmBootstrapTokenString, + hubKubeadmBootstrapTokenString, } } -func KubeadmConfigStatusFuzzer(obj *KubeadmConfigStatus, c fuzz.Continue) { +func hubKubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &bootstrapv1.KubeadmConfigV1Beta1DeprecatedStatus{} + } +} + +func KubeadmConfigTemplateFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + spokeKubeadmConfigStatus, + spokeDNS, + spokeClusterConfiguration, + // This custom functions are needed when ConvertTo/ConvertFrom functions + // uses the json package to unmarshal the bootstrap token string. + // + // The Kubeadm BootstrapTokenString type ships with a custom + // json string representation, in particular it supplies a customized + // UnmarshalJSON function that can return an error if the string + // isn't in the correct form. + // + // This function effectively disables any fuzzing for the token by setting + // the values for ID and Secret to working alphanumeric values. + spokeKubeadmBootstrapTokenString, + hubKubeadmBootstrapTokenString, + } +} + +func spokeKubeadmConfigStatus(obj *KubeadmConfigStatus, c fuzz.Continue) { c.FuzzNoCustom(obj) // KubeadmConfigStatus.BootstrapData has been removed in v1alpha4, so setting it to nil in order to avoid v1alpha3 --> --> v1alpha3 round trip errors. obj.BootstrapData = nil } -func dnsFuzzer(obj *upstreamv1beta1.DNS, c fuzz.Continue) { +func spokeDNS(obj *upstreamv1beta1.DNS, c fuzz.Continue) { c.FuzzNoCustom(obj) // DNS.Type does not exists in v1alpha4, so setting it to empty string in order to avoid v1alpha3 --> --> v1alpha3 round trip errors. obj.Type = "" } -func clusterConfigurationFuzzer(obj *upstreamv1beta1.ClusterConfiguration, c fuzz.Continue) { +func spokeClusterConfiguration(obj *upstreamv1beta1.ClusterConfiguration, c fuzz.Continue) { c.FuzzNoCustom(obj) // ClusterConfiguration.UseHyperKubeImage has been removed in v1alpha4, so setting it to false in order to avoid v1beta1 --> --> v1beta1 round trip errors. obj.UseHyperKubeImage = false } -func kubeadmBootstrapTokenStringFuzzerV1UpstreamBeta1(in *upstreamv1beta1.BootstrapTokenString, _ fuzz.Continue) { +func spokeKubeadmBootstrapTokenString(in *upstreamv1beta1.BootstrapTokenString, _ fuzz.Continue) { in.ID = "abcdef" in.Secret = "abcdef0123456789" } -func kubeadmBootstrapTokenStringFuzzerV1Beta1(in *bootstrapv1.BootstrapTokenString, _ fuzz.Continue) { +func hubKubeadmBootstrapTokenString(in *bootstrapv1.BootstrapTokenString, _ fuzz.Continue) { in.ID = "abcdef" in.Secret = "abcdef0123456789" } diff --git a/internal/apis/bootstrap/kubeadm/v1alpha3/zz_generated.conversion.go b/internal/apis/bootstrap/kubeadm/v1alpha3/zz_generated.conversion.go index 80550a0c6ac1..2213d5e92de9 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha3/zz_generated.conversion.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha3/zz_generated.conversion.go @@ -24,9 +24,9 @@ package v1alpha3 import ( unsafe "unsafe" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" - apiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" v1beta2 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2" upstreamv1beta1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/types/upstreamv1beta1" corev1alpha3 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha3" @@ -184,6 +184,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1.Condition)(nil), (*corev1alpha3.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1alpha3_Condition(a.(*v1.Condition), b.(*corev1alpha3.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*corev1alpha3.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha3_Condition_To_v1_Condition(a.(*corev1alpha3.Condition), b.(*v1.Condition), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*KubeadmConfigStatus)(nil), (*v1beta2.KubeadmConfigStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha3_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(a.(*KubeadmConfigStatus), b.(*v1beta2.KubeadmConfigStatus), scope) }); err != nil { @@ -543,21 +553,39 @@ func autoConvert_v1alpha3_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in out.Ready = in.Ready out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) // WARNING: in.BootstrapData requires manual conversion: does not exist in peer-type - out.FailureReason = in.FailureReason - out.FailureMessage = in.FailureMessage + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*apiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha3_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } func autoConvert_v1beta2_KubeadmConfigStatus_To_v1alpha3_KubeadmConfigStatus(in *v1beta2.KubeadmConfigStatus, out *KubeadmConfigStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(corev1alpha3.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha3_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.Ready = in.Ready out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) - out.FailureReason = in.FailureReason - out.FailureMessage = in.FailureMessage out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*corev1alpha3.Conditions)(unsafe.Pointer(&in.Conditions)) - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } diff --git a/internal/apis/bootstrap/kubeadm/v1alpha4/conversion.go b/internal/apis/bootstrap/kubeadm/v1alpha4/conversion.go index b4c5f7739bcc..de6a57d18256 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha4/conversion.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha4/conversion.go @@ -17,10 +17,12 @@ limitations under the License. package v1alpha4 import ( - apiconversion "k8s.io/apimachinery/pkg/conversion" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2" + clusterv1alpha4 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha4" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -31,13 +33,22 @@ func (src *KubeadmConfig) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha4), failureReason and failureMessage to the deprecated field. + dst.Status.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &bootstrapv1.KubeadmConfigV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + clusterv1alpha4.Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason + dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage + // Manually restore data. restored := &bootstrapv1.KubeadmConfig{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { return err } MergeRestoredKubeadmConfigSpec(&dst.Spec, &restored.Spec) - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions return nil } @@ -115,6 +126,22 @@ func (dst *KubeadmConfig) ConvertFrom(srcRaw conversion.Hub) error { if err := Convert_v1beta2_KubeadmConfig_To_v1alpha4_KubeadmConfig(src, dst, nil); err != nil { return err } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha4). + dst.Status.Conditions = nil + + // Retrieve legacy conditions (v1alpha4), failureReason and failureMessage from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + clusterv1alpha4.Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason + dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage + } + } + // Preserve Hub data on down-conversion except for metadata. return utilconversion.MarshalData(src, dst) } @@ -150,58 +177,72 @@ func (dst *KubeadmConfigTemplate) ConvertFrom(srcRaw conversion.Hub) error { } // Convert_v1beta2_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec is an autogenerated conversion function. -func Convert_v1beta2_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in *bootstrapv1.KubeadmConfigSpec, out *KubeadmConfigSpec, s apiconversion.Scope) error { +func Convert_v1beta2_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in *bootstrapv1.KubeadmConfigSpec, out *KubeadmConfigSpec, s apimachineryconversion.Scope) error { // KubeadmConfigSpec.Ignition does not exist in kubeadm v1alpha4 API. return autoConvert_v1beta2_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in, out, s) } -func Convert_v1beta2_InitConfiguration_To_v1alpha4_InitConfiguration(in *bootstrapv1.InitConfiguration, out *InitConfiguration, s apiconversion.Scope) error { +func Convert_v1beta2_InitConfiguration_To_v1alpha4_InitConfiguration(in *bootstrapv1.InitConfiguration, out *InitConfiguration, s apimachineryconversion.Scope) error { // InitConfiguration.Patches does not exist in kubeadm v1alpha4 API. return autoConvert_v1beta2_InitConfiguration_To_v1alpha4_InitConfiguration(in, out, s) } -func Convert_v1beta2_JoinConfiguration_To_v1alpha4_JoinConfiguration(in *bootstrapv1.JoinConfiguration, out *JoinConfiguration, s apiconversion.Scope) error { +func Convert_v1beta2_JoinConfiguration_To_v1alpha4_JoinConfiguration(in *bootstrapv1.JoinConfiguration, out *JoinConfiguration, s apimachineryconversion.Scope) error { // InitConfiguration.Patches does not exist in kubeadm v1alpha4 API. return autoConvert_v1beta2_JoinConfiguration_To_v1alpha4_JoinConfiguration(in, out, s) } -func Convert_v1beta2_File_To_v1alpha4_File(in *bootstrapv1.File, out *File, s apiconversion.Scope) error { +func Convert_v1beta2_File_To_v1alpha4_File(in *bootstrapv1.File, out *File, s apimachineryconversion.Scope) error { // File.Append does not exist in kubeadm v1alpha4 API. return autoConvert_v1beta2_File_To_v1alpha4_File(in, out, s) } -func Convert_v1beta2_User_To_v1alpha4_User(in *bootstrapv1.User, out *User, s apiconversion.Scope) error { +func Convert_v1beta2_User_To_v1alpha4_User(in *bootstrapv1.User, out *User, s apimachineryconversion.Scope) error { // User.PasswdFrom does not exist in kubeadm v1alpha4 API. return autoConvert_v1beta2_User_To_v1alpha4_User(in, out, s) } -func Convert_v1beta2_NodeRegistrationOptions_To_v1alpha4_NodeRegistrationOptions(in *bootstrapv1.NodeRegistrationOptions, out *NodeRegistrationOptions, s apiconversion.Scope) error { +func Convert_v1beta2_NodeRegistrationOptions_To_v1alpha4_NodeRegistrationOptions(in *bootstrapv1.NodeRegistrationOptions, out *NodeRegistrationOptions, s apimachineryconversion.Scope) error { // NodeRegistrationOptions.ImagePullPolicy does not exit in // kubeadm v1alpha4 API. return autoConvert_v1beta2_NodeRegistrationOptions_To_v1alpha4_NodeRegistrationOptions(in, out, s) } -func Convert_v1beta2_KubeadmConfigTemplateResource_To_v1alpha4_KubeadmConfigTemplateResource(in *bootstrapv1.KubeadmConfigTemplateResource, out *KubeadmConfigTemplateResource, s apiconversion.Scope) error { +func Convert_v1beta2_KubeadmConfigTemplateResource_To_v1alpha4_KubeadmConfigTemplateResource(in *bootstrapv1.KubeadmConfigTemplateResource, out *KubeadmConfigTemplateResource, s apimachineryconversion.Scope) error { // KubeadmConfigTemplateResource.metadata does not exist in kubeadm v1alpha4. return autoConvert_v1beta2_KubeadmConfigTemplateResource_To_v1alpha4_KubeadmConfigTemplateResource(in, out, s) } -func Convert_v1beta2_FileDiscovery_To_v1alpha4_FileDiscovery(in *bootstrapv1.FileDiscovery, out *FileDiscovery, s apiconversion.Scope) error { +func Convert_v1beta2_FileDiscovery_To_v1alpha4_FileDiscovery(in *bootstrapv1.FileDiscovery, out *FileDiscovery, s apimachineryconversion.Scope) error { // JoinConfiguration.Discovery.File.KubeConfig does not exist in v1alpha4 APIs. return autoConvert_v1beta2_FileDiscovery_To_v1alpha4_FileDiscovery(in, out, s) } -func Convert_v1beta2_ControlPlaneComponent_To_v1alpha4_ControlPlaneComponent(in *bootstrapv1.ControlPlaneComponent, out *ControlPlaneComponent, s apiconversion.Scope) error { +func Convert_v1beta2_ControlPlaneComponent_To_v1alpha4_ControlPlaneComponent(in *bootstrapv1.ControlPlaneComponent, out *ControlPlaneComponent, s apimachineryconversion.Scope) error { // ControlPlaneComponent.ExtraEnvs does not exist in v1alpha4 APIs. return autoConvert_v1beta2_ControlPlaneComponent_To_v1alpha4_ControlPlaneComponent(in, out, s) } -func Convert_v1beta2_LocalEtcd_To_v1alpha4_LocalEtcd(in *bootstrapv1.LocalEtcd, out *LocalEtcd, s apiconversion.Scope) error { +func Convert_v1beta2_LocalEtcd_To_v1alpha4_LocalEtcd(in *bootstrapv1.LocalEtcd, out *LocalEtcd, s apimachineryconversion.Scope) error { // LocalEtcd.ExtraEnvs does not exist in v1alpha4 APIs. return autoConvert_v1beta2_LocalEtcd_To_v1alpha4_LocalEtcd(in, out, s) } -func Convert_v1beta2_KubeadmConfigStatus_To_v1alpha4_KubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, out *KubeadmConfigStatus, s apiconversion.Scope) error { +func Convert_v1beta2_KubeadmConfigStatus_To_v1alpha4_KubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, out *KubeadmConfigStatus, s apimachineryconversion.Scope) error { // V1Beta2 was added in v1beta1. return autoConvert_v1beta2_KubeadmConfigStatus_To_v1alpha4_KubeadmConfigStatus(in, out, s) } + +func Convert_v1alpha4_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in *KubeadmConfigStatus, out *bootstrapv1.KubeadmConfigStatus, s apimachineryconversion.Scope) error { + return autoConvert_v1alpha4_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in, out, s) +} + +// Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) + +func Convert_v1_Condition_To_v1alpha4_Condition(in *metav1.Condition, out *clusterv1alpha4.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha4.Convert_v1_Condition_To_v1alpha4_Condition(in, out, s) +} + +func Convert_v1alpha4_Condition_To_v1_Condition(in *clusterv1alpha4.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha4.Convert_v1alpha4_Condition_To_v1_Condition(in, out, s) +} diff --git a/internal/apis/bootstrap/kubeadm/v1alpha4/conversion_test.go b/internal/apis/bootstrap/kubeadm/v1alpha4/conversion_test.go index ec68cc107e19..bcf57837e9f9 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha4/conversion_test.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha4/conversion_test.go @@ -40,7 +40,7 @@ func TestFuzzyConversion(t *testing.T) { t.Run("for KubeadmConfig", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &bootstrapv1.KubeadmConfig{}, Spoke: &KubeadmConfig{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{KubeadmConfigFuzzFuncs, fuzzFuncs}, })) t.Run("for KubeadmConfigTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &bootstrapv1.KubeadmConfigTemplate{}, @@ -49,6 +49,23 @@ func TestFuzzyConversion(t *testing.T) { })) } +func KubeadmConfigFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubKubeadmConfigStatus, + } +} + +func hubKubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &bootstrapv1.KubeadmConfigV1Beta1DeprecatedStatus{} + } +} + func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ // This custom functions are needed when ConvertTo/ConvertFrom functions diff --git a/internal/apis/bootstrap/kubeadm/v1alpha4/zz_generated.conversion.go b/internal/apis/bootstrap/kubeadm/v1alpha4/zz_generated.conversion.go index 19f9a4d3210e..c84b6bdc1396 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha4/zz_generated.conversion.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha4/zz_generated.conversion.go @@ -28,7 +28,6 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" - apiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" v1beta2 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2" corev1alpha4 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha4" ) @@ -260,11 +259,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*KubeadmConfigStatus)(nil), (*v1beta2.KubeadmConfigStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha4_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(a.(*KubeadmConfigStatus), b.(*v1beta2.KubeadmConfigStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*KubeadmConfigTemplate)(nil), (*v1beta2.KubeadmConfigTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_KubeadmConfigTemplate_To_v1beta2_KubeadmConfigTemplate(a.(*KubeadmConfigTemplate), b.(*v1beta2.KubeadmConfigTemplate), scope) }); err != nil { @@ -355,6 +349,21 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1.Condition)(nil), (*corev1alpha4.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1alpha4_Condition(a.(*v1.Condition), b.(*corev1alpha4.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*corev1alpha4.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_Condition_To_v1_Condition(a.(*corev1alpha4.Condition), b.(*v1.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*KubeadmConfigStatus)(nil), (*v1beta2.KubeadmConfigStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(a.(*KubeadmConfigStatus), b.(*v1beta2.KubeadmConfigStatus), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1beta2.ControlPlaneComponent)(nil), (*ControlPlaneComponent)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta2_ControlPlaneComponent_To_v1alpha4_ControlPlaneComponent(a.(*v1beta2.ControlPlaneComponent), b.(*ControlPlaneComponent), scope) }); err != nil { @@ -1235,26 +1244,39 @@ func autoConvert_v1beta2_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in *v1b func autoConvert_v1alpha4_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in *KubeadmConfigStatus, out *v1beta2.KubeadmConfigStatus, s conversion.Scope) error { out.Ready = in.Ready out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) - out.FailureReason = in.FailureReason - out.FailureMessage = in.FailureMessage + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*apiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha4_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } -// Convert_v1alpha4_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus is an autogenerated conversion function. -func Convert_v1alpha4_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in *KubeadmConfigStatus, out *v1beta2.KubeadmConfigStatus, s conversion.Scope) error { - return autoConvert_v1alpha4_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in, out, s) -} - func autoConvert_v1beta2_KubeadmConfigStatus_To_v1alpha4_KubeadmConfigStatus(in *v1beta2.KubeadmConfigStatus, out *KubeadmConfigStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(corev1alpha4.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha4_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.Ready = in.Ready out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) - out.FailureReason = in.FailureReason - out.FailureMessage = in.FailureMessage out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*corev1alpha4.Conditions)(unsafe.Pointer(&in.Conditions)) - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } diff --git a/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go b/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go index d015ce3e3437..c4fdd8b16f07 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go +++ b/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go @@ -17,12 +17,14 @@ limitations under the License. package v1alpha3 import ( - apiconversion "k8s.io/apimachinery/pkg/conversion" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2" controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta2" bootstrapv1alpha3 "sigs.k8s.io/cluster-api/internal/apis/bootstrap/kubeadm/v1alpha3" + clusterv1alpha3 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha3" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -33,6 +35,18 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha3), failureReason, failureMessage and replica counters to the deprecated field. + dst.Status.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + clusterv1alpha3.Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason + dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage + dst.Status.Deprecated.V1Beta1.ReadyReplicas = src.Status.ReadyReplicas + dst.Status.Deprecated.V1Beta1.UpdatedReplicas = src.Status.UpdatedReplicas + dst.Status.Deprecated.V1Beta1.UnavailableReplicas = src.Status.UnavailableReplicas + // Manually restore data. restored := &controlplanev1.KubeadmControlPlane{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -59,7 +73,10 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error { bootstrapv1alpha3.MergeRestoredKubeadmConfigSpec(&dst.Spec.KubeadmConfigSpec, &restored.Spec.KubeadmConfigSpec) dst.Status.Version = restored.Status.Version - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions + dst.Status.AvailableReplicas = restored.Status.AvailableReplicas + dst.Status.ReadyReplicas = restored.Status.ReadyReplicas + dst.Status.UpToDateReplicas = restored.Status.UpToDateReplicas return nil } @@ -71,6 +88,28 @@ func (dst *KubeadmControlPlane) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha3). + dst.Status.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. + dst.Status.ReadyReplicas = 0 + + // Retrieve legacy conditions (v1alpha3), failureReason, failureMessage and replica counters from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + clusterv1alpha3.Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason + dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage + dst.Status.ReadyReplicas = src.Status.Deprecated.V1Beta1.ReadyReplicas + dst.Status.UpdatedReplicas = src.Status.Deprecated.V1Beta1.UpdatedReplicas + dst.Status.UnavailableReplicas = src.Status.Deprecated.V1Beta1.UnavailableReplicas + } + } + // Preserve Hub data on down-conversion except for metadata if err := utilconversion.MarshalData(src, dst); err != nil { return err @@ -79,30 +118,46 @@ func (dst *KubeadmControlPlane) ConvertFrom(srcRaw conversion.Hub) error { return nil } -func Convert_v1beta2_KubeadmControlPlaneSpec_To_v1alpha3_KubeadmControlPlaneSpec(in *controlplanev1.KubeadmControlPlaneSpec, out *KubeadmControlPlaneSpec, s apiconversion.Scope) error { +func Convert_v1beta2_KubeadmControlPlaneSpec_To_v1alpha3_KubeadmControlPlaneSpec(in *controlplanev1.KubeadmControlPlaneSpec, out *KubeadmControlPlaneSpec, s apimachineryconversion.Scope) error { out.UpgradeAfter = in.RolloutAfter out.InfrastructureTemplate = in.MachineTemplate.InfrastructureRef out.NodeDrainTimeout = in.MachineTemplate.NodeDrainTimeout return autoConvert_v1beta2_KubeadmControlPlaneSpec_To_v1alpha3_KubeadmControlPlaneSpec(in, out, s) } -func Convert_v1beta2_KubeadmControlPlaneStatus_To_v1alpha3_KubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus, out *KubeadmControlPlaneStatus, s apiconversion.Scope) error { +func Convert_v1beta2_KubeadmControlPlaneStatus_To_v1alpha3_KubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus, out *KubeadmControlPlaneStatus, s apimachineryconversion.Scope) error { // NOTE: custom conversion func is required because status.Version does not exist in v1alpha3. // .V1Beta2 was added in v1beta1. return autoConvert_v1beta2_KubeadmControlPlaneStatus_To_v1alpha3_KubeadmControlPlaneStatus(in, out, s) } -func Convert_v1alpha3_KubeadmControlPlaneSpec_To_v1beta2_KubeadmControlPlaneSpec(in *KubeadmControlPlaneSpec, out *controlplanev1.KubeadmControlPlaneSpec, s apiconversion.Scope) error { +func Convert_v1alpha3_KubeadmControlPlaneSpec_To_v1beta2_KubeadmControlPlaneSpec(in *KubeadmControlPlaneSpec, out *controlplanev1.KubeadmControlPlaneSpec, s apimachineryconversion.Scope) error { out.RolloutAfter = in.UpgradeAfter out.MachineTemplate.InfrastructureRef = in.InfrastructureTemplate out.MachineTemplate.NodeDrainTimeout = in.NodeDrainTimeout return autoConvert_v1alpha3_KubeadmControlPlaneSpec_To_v1beta2_KubeadmControlPlaneSpec(in, out, s) } -func Convert_v1beta2_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in *bootstrapv1.KubeadmConfigSpec, out *bootstrapv1alpha3.KubeadmConfigSpec, s apiconversion.Scope) error { +func Convert_v1alpha3_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in *KubeadmControlPlaneStatus, out *controlplanev1.KubeadmControlPlaneStatus, s apimachineryconversion.Scope) error { + return autoConvert_v1alpha3_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in, out, s) +} + +// Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) + +func Convert_v1_Condition_To_v1alpha3_Condition(_ *metav1.Condition, _ *clusterv1alpha3.Condition, _ apimachineryconversion.Scope) error { + // NOTE: v1beta2 conditions should not be automatically converted into v1beta1 conditions. + return nil +} + +func Convert_v1alpha3_Condition_To_v1_Condition(_ *clusterv1alpha3.Condition, _ *metav1.Condition, _ apimachineryconversion.Scope) error { + // NOTE: v1beta1 conditions should not be automatically converted into v1beta2 conditions. + return nil +} + +func Convert_v1beta2_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in *bootstrapv1.KubeadmConfigSpec, out *bootstrapv1alpha3.KubeadmConfigSpec, s apimachineryconversion.Scope) error { return bootstrapv1alpha3.Convert_v1beta2_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in, out, s) } -func Convert_v1alpha3_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in *bootstrapv1alpha3.KubeadmConfigSpec, out *bootstrapv1.KubeadmConfigSpec, s apiconversion.Scope) error { +func Convert_v1alpha3_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in *bootstrapv1alpha3.KubeadmConfigSpec, out *bootstrapv1.KubeadmConfigSpec, s apimachineryconversion.Scope) error { return bootstrapv1alpha3.Convert_v1alpha3_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in, out, s) } diff --git a/internal/apis/controlplane/kubeadm/v1alpha3/conversion_test.go b/internal/apis/controlplane/kubeadm/v1alpha3/conversion_test.go index df6173296820..b63dbda2c52c 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha3/conversion_test.go +++ b/internal/apis/controlplane/kubeadm/v1alpha3/conversion_test.go @@ -37,46 +37,59 @@ func TestFuzzyConversion(t *testing.T) { t.Run("for KubeadmControlPlane", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &controlplanev1.KubeadmControlPlane{}, Spoke: &KubeadmControlPlane{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{KubeadmControlPlaneFuzzFuncs}, })) } -func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { - // This custom function is needed when ConvertTo/ConvertFrom functions - // uses the json package to unmarshal the bootstrap token string. - // - // The Kubeadm v1beta1.BootstrapTokenString type ships with a custom - // json string representation, in particular it supplies a customized - // UnmarshalJSON function that can return an error if the string - // isn't in the correct form. - // - // This function effectively disables any fuzzing for the token by setting - // the values for ID and Secret to working alphanumeric values. +func KubeadmControlPlaneFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - kubeadmBootstrapTokenStringFuzzer, - cabpkBootstrapTokenStringFuzzer, - dnsFuzzer, - kubeadmClusterConfigurationFuzzer, + hubKubeadmControlPlaneStatus, + spokeDNS, + spokeKubeadmClusterConfiguration, + // This custom function is needed when ConvertTo/ConvertFrom functions + // uses the json package to unmarshal the bootstrap token string. + // + // The Kubeadm v1beta1.BootstrapTokenString type ships with a custom + // json string representation, in particular it supplies a customized + // UnmarshalJSON function that can return an error if the string + // isn't in the correct form. + // + // This function effectively disables any fuzzing for the token by setting + // the values for ID and Secret to working alphanumeric values. + hubBootstrapTokenString, + spokeKubeadmBootstrapTokenString, } } -func kubeadmBootstrapTokenStringFuzzer(in *upstreamv1beta1.BootstrapTokenString, _ fuzz.Continue) { +func hubKubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{} + } +} + +func hubBootstrapTokenString(in *bootstrapv1.BootstrapTokenString, _ fuzz.Continue) { in.ID = "abcdef" in.Secret = "abcdef0123456789" } -func cabpkBootstrapTokenStringFuzzer(in *bootstrapv1.BootstrapTokenString, _ fuzz.Continue) { + +func spokeKubeadmBootstrapTokenString(in *upstreamv1beta1.BootstrapTokenString, _ fuzz.Continue) { in.ID = "abcdef" in.Secret = "abcdef0123456789" } -func dnsFuzzer(obj *upstreamv1beta1.DNS, c fuzz.Continue) { +func spokeDNS(obj *upstreamv1beta1.DNS, c fuzz.Continue) { c.FuzzNoCustom(obj) // DNS.Type does not exists in v1alpha4, so setting it to empty string in order to avoid v1alpha3 --> v1alpha4 --> v1alpha3 round trip errors. obj.Type = "" } -func kubeadmClusterConfigurationFuzzer(obj *upstreamv1beta1.ClusterConfiguration, c fuzz.Continue) { +func spokeKubeadmClusterConfiguration(obj *upstreamv1beta1.ClusterConfiguration, c fuzz.Continue) { c.FuzzNoCustom(obj) // ClusterConfiguration.UseHyperKubeImage has been removed in v1alpha4, so setting it to false in order to avoid v1alpha3 --> v1alpha4 --> v1alpha3 round trip errors. diff --git a/internal/apis/controlplane/kubeadm/v1alpha3/zz_generated.conversion.go b/internal/apis/controlplane/kubeadm/v1alpha3/zz_generated.conversion.go index c0fd49174fda..6e8768df0833 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha3/zz_generated.conversion.go +++ b/internal/apis/controlplane/kubeadm/v1alpha3/zz_generated.conversion.go @@ -24,13 +24,12 @@ package v1alpha3 import ( unsafe "unsafe" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" intstr "k8s.io/apimachinery/pkg/util/intstr" - clusterapiapiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" apiv1beta2 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2" v1beta2 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta2" - errors "sigs.k8s.io/cluster-api/errors" kubeadmv1alpha3 "sigs.k8s.io/cluster-api/internal/apis/bootstrap/kubeadm/v1alpha3" corev1alpha3 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha3" ) @@ -62,11 +61,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*KubeadmControlPlaneStatus)(nil), (*v1beta2.KubeadmControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha3_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(a.(*KubeadmControlPlaneStatus), b.(*v1beta2.KubeadmControlPlaneStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*RollingUpdate)(nil), (*v1beta2.RollingUpdate)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha3_RollingUpdate_To_v1beta2_RollingUpdate(a.(*RollingUpdate), b.(*v1beta2.RollingUpdate), scope) }); err != nil { @@ -87,6 +81,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1.Condition)(nil), (*corev1alpha3.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1alpha3_Condition(a.(*v1.Condition), b.(*corev1alpha3.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*corev1alpha3.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha3_Condition_To_v1_Condition(a.(*corev1alpha3.Condition), b.(*v1.Condition), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*kubeadmv1alpha3.KubeadmConfigSpec)(nil), (*apiv1beta2.KubeadmConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha3_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(a.(*kubeadmv1alpha3.KubeadmConfigSpec), b.(*apiv1beta2.KubeadmConfigSpec), scope) }); err != nil { @@ -97,6 +101,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*KubeadmControlPlaneStatus)(nil), (*v1beta2.KubeadmControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha3_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(a.(*KubeadmControlPlaneStatus), b.(*v1beta2.KubeadmControlPlaneStatus), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*apiv1beta2.KubeadmConfigSpec)(nil), (*kubeadmv1alpha3.KubeadmConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta2_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(a.(*apiv1beta2.KubeadmConfigSpec), b.(*kubeadmv1alpha3.KubeadmConfigSpec), scope) }); err != nil { @@ -220,38 +229,55 @@ func autoConvert_v1beta2_KubeadmControlPlaneSpec_To_v1alpha3_KubeadmControlPlane func autoConvert_v1alpha3_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in *KubeadmControlPlaneStatus, out *v1beta2.KubeadmControlPlaneStatus, s conversion.Scope) error { out.Selector = in.Selector out.Replicas = in.Replicas - out.UpdatedReplicas = in.UpdatedReplicas - out.ReadyReplicas = in.ReadyReplicas - out.UnavailableReplicas = in.UnavailableReplicas + // WARNING: in.UpdatedReplicas requires manual conversion: does not exist in peer-type + if err := v1.Convert_int32_To_Pointer_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + // WARNING: in.UnavailableReplicas requires manual conversion: does not exist in peer-type out.Initialized = in.Initialized out.Ready = in.Ready - out.FailureReason = errors.KubeadmControlPlaneStatusError(in.FailureReason) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*clusterapiapiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha3_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } -// Convert_v1alpha3_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus is an autogenerated conversion function. -func Convert_v1alpha3_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in *KubeadmControlPlaneStatus, out *v1beta2.KubeadmControlPlaneStatus, s conversion.Scope) error { - return autoConvert_v1alpha3_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in, out, s) -} - func autoConvert_v1beta2_KubeadmControlPlaneStatus_To_v1alpha3_KubeadmControlPlaneStatus(in *v1beta2.KubeadmControlPlaneStatus, out *KubeadmControlPlaneStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(corev1alpha3.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha3_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.Selector = in.Selector out.Replicas = in.Replicas + if err := v1.Convert_Pointer_int32_To_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + // WARNING: in.AvailableReplicas requires manual conversion: does not exist in peer-type + // WARNING: in.UpToDateReplicas requires manual conversion: does not exist in peer-type // WARNING: in.Version requires manual conversion: does not exist in peer-type - out.UpdatedReplicas = in.UpdatedReplicas - out.ReadyReplicas = in.ReadyReplicas - out.UnavailableReplicas = in.UnavailableReplicas out.Initialized = in.Initialized out.Ready = in.Ready - out.FailureReason = errors.KubeadmControlPlaneStatusError(in.FailureReason) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*corev1alpha3.Conditions)(unsafe.Pointer(&in.Conditions)) // WARNING: in.LastRemediation requires manual conversion: does not exist in peer-type - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } diff --git a/internal/apis/controlplane/kubeadm/v1alpha4/conversion.go b/internal/apis/controlplane/kubeadm/v1alpha4/conversion.go index d961063eb8b8..a6c6ed88ebbb 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha4/conversion.go +++ b/internal/apis/controlplane/kubeadm/v1alpha4/conversion.go @@ -17,7 +17,8 @@ limitations under the License. package v1alpha4 import ( - apiconversion "k8s.io/apimachinery/pkg/conversion" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2" @@ -35,6 +36,18 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha4), failureReason, failureMessage and replica counters to the deprecated field. + dst.Status.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + clusterv1alpha4.Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason + dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage + dst.Status.Deprecated.V1Beta1.ReadyReplicas = src.Status.ReadyReplicas + dst.Status.Deprecated.V1Beta1.UpdatedReplicas = src.Status.UpdatedReplicas + dst.Status.Deprecated.V1Beta1.UnavailableReplicas = src.Status.UnavailableReplicas + // Manually restore data. restored := &controlplanev1.KubeadmControlPlane{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -58,7 +71,10 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error { } bootstrapv1alpha4.MergeRestoredKubeadmConfigSpec(&dst.Spec.KubeadmConfigSpec, &restored.Spec.KubeadmConfigSpec) - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions + dst.Status.AvailableReplicas = restored.Status.AvailableReplicas + dst.Status.ReadyReplicas = restored.Status.ReadyReplicas + dst.Status.UpToDateReplicas = restored.Status.UpToDateReplicas return nil } @@ -70,6 +86,28 @@ func (dst *KubeadmControlPlane) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha4). + dst.Status.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. + dst.Status.ReadyReplicas = 0 + + // Retrieve legacy conditions (v1alpha4), failureReason, failureMessage and replica counters from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + clusterv1alpha4.Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason + dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage + dst.Status.ReadyReplicas = src.Status.Deprecated.V1Beta1.ReadyReplicas + dst.Status.UpdatedReplicas = src.Status.Deprecated.V1Beta1.UpdatedReplicas + dst.Status.UnavailableReplicas = src.Status.Deprecated.V1Beta1.UnavailableReplicas + } + } + // Preserve Hub data on down-conversion except for metadata return utilconversion.MarshalData(src, dst) } @@ -127,7 +165,7 @@ func (dst *KubeadmControlPlaneTemplate) ConvertFrom(srcRaw conversion.Hub) error return utilconversion.MarshalData(src, dst) } -func Convert_v1alpha4_KubeadmControlPlaneSpec_To_v1beta2_KubeadmControlPlaneTemplateResourceSpec(in *KubeadmControlPlaneSpec, out *controlplanev1.KubeadmControlPlaneTemplateResourceSpec, s apiconversion.Scope) error { +func Convert_v1alpha4_KubeadmControlPlaneSpec_To_v1beta2_KubeadmControlPlaneTemplateResourceSpec(in *KubeadmControlPlaneSpec, out *controlplanev1.KubeadmControlPlaneTemplateResourceSpec, s apimachineryconversion.Scope) error { out.MachineTemplate = &controlplanev1.KubeadmControlPlaneTemplateMachineTemplate{ NodeDrainTimeout: in.MachineTemplate.NodeDrainTimeout, } @@ -155,7 +193,7 @@ func Convert_v1alpha4_KubeadmControlPlaneSpec_To_v1beta2_KubeadmControlPlaneTemp return nil } -func Convert_v1beta2_KubeadmControlPlaneTemplateResourceSpec_To_v1alpha4_KubeadmControlPlaneSpec(in *controlplanev1.KubeadmControlPlaneTemplateResourceSpec, out *KubeadmControlPlaneSpec, s apiconversion.Scope) error { +func Convert_v1beta2_KubeadmControlPlaneTemplateResourceSpec_To_v1alpha4_KubeadmControlPlaneSpec(in *controlplanev1.KubeadmControlPlaneTemplateResourceSpec, out *KubeadmControlPlaneSpec, s apimachineryconversion.Scope) error { if in.MachineTemplate != nil { out.MachineTemplate.NodeDrainTimeout = in.MachineTemplate.NodeDrainTimeout } @@ -183,40 +221,54 @@ func Convert_v1beta2_KubeadmControlPlaneTemplateResourceSpec_To_v1alpha4_Kubeadm return nil } -func Convert_v1beta2_KubeadmControlPlaneMachineTemplate_To_v1alpha4_KubeadmControlPlaneMachineTemplate(in *controlplanev1.KubeadmControlPlaneMachineTemplate, out *KubeadmControlPlaneMachineTemplate, s apiconversion.Scope) error { +func Convert_v1beta2_KubeadmControlPlaneMachineTemplate_To_v1alpha4_KubeadmControlPlaneMachineTemplate(in *controlplanev1.KubeadmControlPlaneMachineTemplate, out *KubeadmControlPlaneMachineTemplate, s apimachineryconversion.Scope) error { // .NodeDrainTimeout was added in v1beta1. return autoConvert_v1beta2_KubeadmControlPlaneMachineTemplate_To_v1alpha4_KubeadmControlPlaneMachineTemplate(in, out, s) } -func Convert_v1beta2_KubeadmControlPlaneSpec_To_v1alpha4_KubeadmControlPlaneSpec(in *controlplanev1.KubeadmControlPlaneSpec, out *KubeadmControlPlaneSpec, scope apiconversion.Scope) error { +func Convert_v1beta2_KubeadmControlPlaneSpec_To_v1alpha4_KubeadmControlPlaneSpec(in *controlplanev1.KubeadmControlPlaneSpec, out *KubeadmControlPlaneSpec, scope apimachineryconversion.Scope) error { // .RolloutBefore was added in v1beta1. // .RemediationStrategy was added in v1beta1. return autoConvert_v1beta2_KubeadmControlPlaneSpec_To_v1alpha4_KubeadmControlPlaneSpec(in, out, scope) } -func Convert_v1beta2_KubeadmControlPlaneStatus_To_v1alpha4_KubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus, out *KubeadmControlPlaneStatus, scope apiconversion.Scope) error { +func Convert_v1beta2_KubeadmControlPlaneStatus_To_v1alpha4_KubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus, out *KubeadmControlPlaneStatus, scope apimachineryconversion.Scope) error { // .LastRemediation was added in v1beta1. // .V1Beta2 was added in v1beta1. return autoConvert_v1beta2_KubeadmControlPlaneStatus_To_v1alpha4_KubeadmControlPlaneStatus(in, out, scope) } -func Convert_v1beta2_KubeadmControlPlaneTemplateResource_To_v1alpha4_KubeadmControlPlaneTemplateResource(in *controlplanev1.KubeadmControlPlaneTemplateResource, out *KubeadmControlPlaneTemplateResource, scope apiconversion.Scope) error { +func Convert_v1beta2_KubeadmControlPlaneTemplateResource_To_v1alpha4_KubeadmControlPlaneTemplateResource(in *controlplanev1.KubeadmControlPlaneTemplateResource, out *KubeadmControlPlaneTemplateResource, scope apimachineryconversion.Scope) error { // .metadata and .spec.machineTemplate.metadata was added in v1beta1. return autoConvert_v1beta2_KubeadmControlPlaneTemplateResource_To_v1alpha4_KubeadmControlPlaneTemplateResource(in, out, scope) } -func Convert_v1beta2_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in *bootstrapv1.KubeadmConfigSpec, out *bootstrapv1alpha4.KubeadmConfigSpec, s apiconversion.Scope) error { +func Convert_v1alpha4_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in *KubeadmControlPlaneStatus, out *controlplanev1.KubeadmControlPlaneStatus, scope apimachineryconversion.Scope) error { + return autoConvert_v1alpha4_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in, out, scope) +} + +// Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) + +func Convert_v1beta2_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in *bootstrapv1.KubeadmConfigSpec, out *bootstrapv1alpha4.KubeadmConfigSpec, s apimachineryconversion.Scope) error { return bootstrapv1alpha4.Convert_v1beta2_KubeadmConfigSpec_To_v1alpha4_KubeadmConfigSpec(in, out, s) } -func Convert_v1alpha4_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in *bootstrapv1alpha4.KubeadmConfigSpec, out *bootstrapv1.KubeadmConfigSpec, s apiconversion.Scope) error { +func Convert_v1alpha4_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in *bootstrapv1alpha4.KubeadmConfigSpec, out *bootstrapv1.KubeadmConfigSpec, s apimachineryconversion.Scope) error { return bootstrapv1alpha4.Convert_v1alpha4_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in, out, s) } -func Convert_v1alpha4_ObjectMeta_To_v1beta2_ObjectMeta(in *clusterv1alpha4.ObjectMeta, out *clusterv1.ObjectMeta, s apiconversion.Scope) error { +func Convert_v1alpha4_ObjectMeta_To_v1beta2_ObjectMeta(in *clusterv1alpha4.ObjectMeta, out *clusterv1.ObjectMeta, s apimachineryconversion.Scope) error { return clusterv1alpha4.Convert_v1alpha4_ObjectMeta_To_v1beta2_ObjectMeta(in, out, s) } -func Convert_v1beta2_ObjectMeta_To_v1alpha4_ObjectMeta(in *clusterv1.ObjectMeta, out *clusterv1alpha4.ObjectMeta, s apiconversion.Scope) error { +func Convert_v1beta2_ObjectMeta_To_v1alpha4_ObjectMeta(in *clusterv1.ObjectMeta, out *clusterv1alpha4.ObjectMeta, s apimachineryconversion.Scope) error { return clusterv1alpha4.Convert_v1beta2_ObjectMeta_To_v1alpha4_ObjectMeta(in, out, s) } + +func Convert_v1_Condition_To_v1alpha4_Condition(in *metav1.Condition, out *clusterv1alpha4.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha4.Convert_v1_Condition_To_v1alpha4_Condition(in, out, s) +} + +func Convert_v1alpha4_Condition_To_v1_Condition(in *clusterv1alpha4.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha4.Convert_v1alpha4_Condition_To_v1_Condition(in, out, s) +} diff --git a/internal/apis/controlplane/kubeadm/v1alpha4/conversion_test.go b/internal/apis/controlplane/kubeadm/v1alpha4/conversion_test.go index 5b9239109a63..2b51206b662d 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha4/conversion_test.go +++ b/internal/apis/controlplane/kubeadm/v1alpha4/conversion_test.go @@ -44,45 +44,75 @@ func TestFuzzyConversion(t *testing.T) { t.Run("for KubeadmControlPlane", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &controlplanev1.KubeadmControlPlane{}, Spoke: &KubeadmControlPlane{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{KubeadmControlPlaneFuzzFuncs}, })) t.Run("for KubeadmControlPlaneTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &controlplanev1.KubeadmControlPlaneTemplate{}, Spoke: &KubeadmControlPlaneTemplate{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{KubeadmControlPlaneTemplateFuzzFuncs}, })) } -func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { - // This custom function is needed when ConvertTo/ConvertFrom functions - // uses the json package to unmarshal the bootstrap token string. - // - // The Kubeadm v1beta1.BootstrapTokenString type ships with a custom - // json string representation, in particular it supplies a customized - // UnmarshalJSON function that can return an error if the string - // isn't in the correct form. - // - // This function effectively disables any fuzzing for the token by setting - // the values for ID and Secret to working alphanumeric values. +func KubeadmControlPlaneFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - cabpkBootstrapTokenStringFuzzer, - kubeadmBootstrapTokenStringFuzzerV1Alpha4, - kubeadmControlPlaneTemplateResourceSpecFuzzerV1Alpha4, + hubKubeadmControlPlaneStatus, + spokeKubeadmControlPlaneTemplateResource, + // This custom function is needed when ConvertTo/ConvertFrom functions + // uses the json package to unmarshal the bootstrap token string. + // + // The Kubeadm v1beta1.BootstrapTokenString type ships with a custom + // json string representation, in particular it supplies a customized + // UnmarshalJSON function that can return an error if the string + // isn't in the correct form. + // + // This function effectively disables any fuzzing for the token by setting + // the values for ID and Secret to working alphanumeric values. + hubBootstrapTokenString, + spokeBootstrapTokenString, } } -func cabpkBootstrapTokenStringFuzzer(in *bootstrapv1.BootstrapTokenString, _ fuzz.Continue) { +func hubKubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{} + } +} + +func KubeadmControlPlaneTemplateFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + spokeKubeadmControlPlaneTemplateResource, + // This custom function is needed when ConvertTo/ConvertFrom functions + // uses the json package to unmarshal the bootstrap token string. + // + // The Kubeadm v1beta1.BootstrapTokenString type ships with a custom + // json string representation, in particular it supplies a customized + // UnmarshalJSON function that can return an error if the string + // isn't in the correct form. + // + // This function effectively disables any fuzzing for the token by setting + // the values for ID and Secret to working alphanumeric values. + hubBootstrapTokenString, + spokeBootstrapTokenString, + } +} + +func hubBootstrapTokenString(in *bootstrapv1.BootstrapTokenString, _ fuzz.Continue) { in.ID = fakeID in.Secret = fakeSecret } -func kubeadmBootstrapTokenStringFuzzerV1Alpha4(in *bootstrapv1alpha4.BootstrapTokenString, _ fuzz.Continue) { +func spokeBootstrapTokenString(in *bootstrapv1alpha4.BootstrapTokenString, _ fuzz.Continue) { in.ID = fakeID in.Secret = fakeSecret } -func kubeadmControlPlaneTemplateResourceSpecFuzzerV1Alpha4(in *KubeadmControlPlaneTemplateResource, c fuzz.Continue) { +func spokeKubeadmControlPlaneTemplateResource(in *KubeadmControlPlaneTemplateResource, c fuzz.Continue) { c.Fuzz(in) // Fields have been dropped in KCPTemplate. diff --git a/internal/apis/controlplane/kubeadm/v1alpha4/zz_generated.conversion.go b/internal/apis/controlplane/kubeadm/v1alpha4/zz_generated.conversion.go index 70a642d21f48..0e1cce482999 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha4/zz_generated.conversion.go +++ b/internal/apis/controlplane/kubeadm/v1alpha4/zz_generated.conversion.go @@ -31,7 +31,6 @@ import ( clusterapiapiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" apiv1beta2 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2" v1beta2 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta2" - errors "sigs.k8s.io/cluster-api/errors" kubeadmv1alpha4 "sigs.k8s.io/cluster-api/internal/apis/bootstrap/kubeadm/v1alpha4" corev1alpha4 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha4" ) @@ -73,11 +72,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*KubeadmControlPlaneStatus)(nil), (*v1beta2.KubeadmControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha4_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(a.(*KubeadmControlPlaneStatus), b.(*v1beta2.KubeadmControlPlaneStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*KubeadmControlPlaneTemplate)(nil), (*v1beta2.KubeadmControlPlaneTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_KubeadmControlPlaneTemplate_To_v1beta2_KubeadmControlPlaneTemplate(a.(*KubeadmControlPlaneTemplate), b.(*v1beta2.KubeadmControlPlaneTemplate), scope) }); err != nil { @@ -133,6 +127,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1.Condition)(nil), (*corev1alpha4.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1alpha4_Condition(a.(*v1.Condition), b.(*corev1alpha4.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*corev1alpha4.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_Condition_To_v1_Condition(a.(*corev1alpha4.Condition), b.(*v1.Condition), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*kubeadmv1alpha4.KubeadmConfigSpec)(nil), (*apiv1beta2.KubeadmConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(a.(*kubeadmv1alpha4.KubeadmConfigSpec), b.(*apiv1beta2.KubeadmConfigSpec), scope) }); err != nil { @@ -143,6 +147,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*KubeadmControlPlaneStatus)(nil), (*v1beta2.KubeadmControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(a.(*KubeadmControlPlaneStatus), b.(*v1beta2.KubeadmControlPlaneStatus), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*corev1alpha4.ObjectMeta)(nil), (*clusterapiapiv1beta2.ObjectMeta)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_ObjectMeta_To_v1beta2_ObjectMeta(a.(*corev1alpha4.ObjectMeta), b.(*clusterapiapiv1beta2.ObjectMeta), scope) }); err != nil { @@ -326,38 +335,55 @@ func autoConvert_v1alpha4_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPla out.Selector = in.Selector out.Replicas = in.Replicas out.Version = (*string)(unsafe.Pointer(in.Version)) - out.UpdatedReplicas = in.UpdatedReplicas - out.ReadyReplicas = in.ReadyReplicas - out.UnavailableReplicas = in.UnavailableReplicas + // WARNING: in.UpdatedReplicas requires manual conversion: does not exist in peer-type + if err := v1.Convert_int32_To_Pointer_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + // WARNING: in.UnavailableReplicas requires manual conversion: does not exist in peer-type out.Initialized = in.Initialized out.Ready = in.Ready - out.FailureReason = errors.KubeadmControlPlaneStatusError(in.FailureReason) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*clusterapiapiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha4_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } -// Convert_v1alpha4_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus is an autogenerated conversion function. -func Convert_v1alpha4_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in *KubeadmControlPlaneStatus, out *v1beta2.KubeadmControlPlaneStatus, s conversion.Scope) error { - return autoConvert_v1alpha4_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneStatus(in, out, s) -} - func autoConvert_v1beta2_KubeadmControlPlaneStatus_To_v1alpha4_KubeadmControlPlaneStatus(in *v1beta2.KubeadmControlPlaneStatus, out *KubeadmControlPlaneStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(corev1alpha4.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha4_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.Selector = in.Selector out.Replicas = in.Replicas + if err := v1.Convert_Pointer_int32_To_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + // WARNING: in.AvailableReplicas requires manual conversion: does not exist in peer-type + // WARNING: in.UpToDateReplicas requires manual conversion: does not exist in peer-type out.Version = (*string)(unsafe.Pointer(in.Version)) - out.UpdatedReplicas = in.UpdatedReplicas - out.ReadyReplicas = in.ReadyReplicas - out.UnavailableReplicas = in.UnavailableReplicas out.Initialized = in.Initialized out.Ready = in.Ready - out.FailureReason = errors.KubeadmControlPlaneStatusError(in.FailureReason) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*corev1alpha4.Conditions)(unsafe.Pointer(&in.Conditions)) // WARNING: in.LastRemediation requires manual conversion: does not exist in peer-type - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } diff --git a/internal/apis/core/exp/v1alpha3/conversion.go b/internal/apis/core/exp/v1alpha3/conversion.go index dcd39b9eddde..e1a172556eea 100644 --- a/internal/apis/core/exp/v1alpha3/conversion.go +++ b/internal/apis/core/exp/v1alpha3/conversion.go @@ -17,6 +17,9 @@ limitations under the License. package v1alpha3 import ( + "unsafe" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/conversion" @@ -67,6 +70,18 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha3), failureReason, failureMessage and replica counters to the deprecated field. + dst.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + clusterv1alpha3.Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason + dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage + dst.Status.Deprecated.V1Beta1.ReadyReplicas = src.Status.ReadyReplicas + dst.Status.Deprecated.V1Beta1.AvailableReplicas = src.Status.AvailableReplicas + dst.Status.Deprecated.V1Beta1.UnavailableReplicas = src.Status.UnavailableReplicas + // Manually restore data. restored := &expv1.MachinePool{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -75,7 +90,10 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Template.Spec.ReadinessGates = restored.Spec.Template.Spec.ReadinessGates dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions + dst.Status.AvailableReplicas = restored.Status.AvailableReplicas + dst.Status.ReadyReplicas = restored.Status.ReadyReplicas + dst.Status.UpToDateReplicas = restored.Status.UpToDateReplicas return nil } @@ -87,6 +105,29 @@ func (dst *MachinePool) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha3). + dst.Status.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. + dst.Status.ReadyReplicas = 0 + dst.Status.AvailableReplicas = 0 + + // Retrieve legacy conditions (v1alpha3), failureReason, failureMessage and replica counters from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + clusterv1alpha3.Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason + dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage + dst.Status.ReadyReplicas = src.Status.Deprecated.V1Beta1.ReadyReplicas + dst.Status.AvailableReplicas = src.Status.Deprecated.V1Beta1.AvailableReplicas + dst.Status.UnavailableReplicas = src.Status.Deprecated.V1Beta1.UnavailableReplicas + } + } + return utilconversion.MarshalData(src, dst) } @@ -100,5 +141,76 @@ func Convert_v1beta2_MachineTemplateSpec_To_v1alpha3_MachineTemplateSpec(in *clu func Convert_v1beta2_MachinePoolStatus_To_v1alpha3_MachinePoolStatus(in *expv1.MachinePoolStatus, out *MachinePoolStatus, s apimachineryconversion.Scope) error { // V1Beta2 was added in v1beta1 - return autoConvert_v1beta2_MachinePoolStatus_To_v1alpha3_MachinePoolStatus(in, out, s) + if err := autoConvert_v1beta2_MachinePoolStatus_To_v1alpha3_MachinePoolStatus(in, out, s); err != nil { + return err + } + + // undo autogenerated conversion conditions + // NOTE: v1beta2 conditions should not be automatically converted into v1beta1 conditions. + out.Conditions = nil + + // v1beta1 conditions, failureReason, failureMessage moved to deprecated. + if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { + out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage + out.FailureReason = in.Deprecated.V1Beta1.FailureReason + if in.Deprecated.V1Beta1.Conditions != nil { + in, out := &in.Deprecated.V1Beta1.Conditions, &out.Conditions + *out = make(clusterv1alpha3.Conditions, len(*in)) + for i := range *in { + (*out)[i] = *(*clusterv1alpha3.Condition)(unsafe.Pointer(&(*in)[i])) + } + } else { + out.Conditions = nil + } + } + + return nil +} + +func Convert_v1alpha3_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachinePoolStatus, out *expv1.MachinePoolStatus, s apimachineryconversion.Scope) error { + // V1Beta2 was added in v1beta1 + if err := autoConvert_v1alpha3_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in, out, s); err != nil { + return err + } + + // undo autogenerated conversion conditions + // NOTE: v1beta1 conditions should not be automatically converted into v1beta2 conditions. + out.Conditions = nil + + // v1beta1 conditions, failureReason, failureMessage moved to deprecated. + if in.Conditions == nil && in.FailureReason == nil && in.FailureMessage == nil { + return nil + } + if out.Deprecated == nil { + out.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + } + + if in.Conditions != nil { + in, out := &in.Conditions, &out.Deprecated.V1Beta1.Conditions + *out = make(clusterv1.Conditions, len(*in)) + for i := range *in { + (*out)[i] = *(*clusterv1.Condition)(unsafe.Pointer(&(*in)[i])) + } + } else { + out.Deprecated.V1Beta1.Conditions = nil + } + + out.Deprecated.V1Beta1.FailureReason = in.FailureReason + out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage + return nil +} + +// Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) + +func Convert_v1_Condition_To_v1alpha3_Condition(_ *metav1.Condition, _ *clusterv1alpha3.Condition, _ apimachineryconversion.Scope) error { + // NOTE: v1beta2 conditions should not be automatically converted into v1beta1 conditions. + return nil +} + +func Convert_v1alpha3_Condition_To_v1_Condition(_ *clusterv1alpha3.Condition, _ *metav1.Condition, _ apimachineryconversion.Scope) error { + // NOTE: v1beta1 conditions should not be automatically converted into v1beta2 conditions. + return nil } diff --git a/internal/apis/core/exp/v1alpha3/conversion_test.go b/internal/apis/core/exp/v1alpha3/conversion_test.go index 568415263017..d4a9d374dd0d 100644 --- a/internal/apis/core/exp/v1alpha3/conversion_test.go +++ b/internal/apis/core/exp/v1alpha3/conversion_test.go @@ -36,26 +36,38 @@ func TestFuzzyConversion(t *testing.T) { t.Run("for MachinePool", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &expv1.MachinePool{}, Spoke: &MachinePool{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{fuzzFuncs}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachinePoolFuzzFuncs}, })) } -func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { +func MachinePoolFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - BootstrapFuzzer, - MachinePoolSpecFuzzer, - ObjectMetaFuzzer, + spokeBootstrap, + spokeObjectMeta, + spokeMachinePoolSpec, + hubMachinePoolStatus, } } -func BootstrapFuzzer(in *clusterv1alpha3.Bootstrap, c fuzz.Continue) { +func hubMachinePoolStatus(in *expv1.MachinePoolStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + } +} + +func spokeBootstrap(in *clusterv1alpha3.Bootstrap, c fuzz.Continue) { c.FuzzNoCustom(in) // Bootstrap.Data has been removed in v1alpha4, so setting it to nil in order to avoid v1alpha3 --> --> v1alpha3 round trip errors. in.Data = nil } -func ObjectMetaFuzzer(in *clusterv1alpha3.ObjectMeta, c fuzz.Continue) { +func spokeObjectMeta(in *clusterv1alpha3.ObjectMeta, c fuzz.Continue) { c.FuzzNoCustom(in) // These fields have been removed in v1beta1 @@ -66,7 +78,7 @@ func ObjectMetaFuzzer(in *clusterv1alpha3.ObjectMeta, c fuzz.Continue) { in.OwnerReferences = nil } -func MachinePoolSpecFuzzer(in *MachinePoolSpec, c fuzz.Continue) { +func spokeMachinePoolSpec(in *MachinePoolSpec, c fuzz.Continue) { c.Fuzz(in) // These fields have been removed in v1beta1 diff --git a/internal/apis/core/exp/v1alpha3/zz_generated.conversion.go b/internal/apis/core/exp/v1alpha3/zz_generated.conversion.go index 61cf8f04b113..168c51c6e6a5 100644 --- a/internal/apis/core/exp/v1alpha3/zz_generated.conversion.go +++ b/internal/apis/core/exp/v1alpha3/zz_generated.conversion.go @@ -24,11 +24,11 @@ package v1alpha3 import ( unsafe "unsafe" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" apiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" - errors "sigs.k8s.io/cluster-api/errors" v1beta2 "sigs.k8s.io/cluster-api/exp/api/v1beta2" corev1alpha3 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha3" ) @@ -55,8 +55,13 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachinePoolStatus)(nil), (*v1beta2.MachinePoolStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha3_MachinePoolStatus_To_v1beta2_MachinePoolStatus(a.(*MachinePoolStatus), b.(*v1beta2.MachinePoolStatus), scope) + if err := s.AddConversionFunc((*v1.Condition)(nil), (*corev1alpha3.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1alpha3_Condition(a.(*v1.Condition), b.(*corev1alpha3.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*corev1alpha3.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha3_Condition_To_v1_Condition(a.(*corev1alpha3.Condition), b.(*v1.Condition), scope) }); err != nil { return err } @@ -65,6 +70,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*MachinePoolStatus)(nil), (*v1beta2.MachinePoolStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha3_MachinePoolStatus_To_v1beta2_MachinePoolStatus(a.(*MachinePoolStatus), b.(*v1beta2.MachinePoolStatus), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*MachinePool)(nil), (*v1beta2.MachinePool)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha3_MachinePool_To_v1beta2_MachinePool(a.(*MachinePool), b.(*v1beta2.MachinePool), scope) }); err != nil { @@ -188,39 +198,60 @@ func Convert_v1beta2_MachinePoolSpec_To_v1alpha3_MachinePoolSpec(in *v1beta2.Mac } func autoConvert_v1alpha3_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachinePoolStatus, out *v1beta2.MachinePoolStatus, s conversion.Scope) error { - out.NodeRefs = *(*[]v1.ObjectReference)(unsafe.Pointer(&in.NodeRefs)) + out.NodeRefs = *(*[]corev1.ObjectReference)(unsafe.Pointer(&in.NodeRefs)) out.Replicas = in.Replicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas - out.UnavailableReplicas = in.UnavailableReplicas - out.FailureReason = (*errors.MachinePoolStatusFailure)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + if err := v1.Convert_int32_To_Pointer_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_int32_To_Pointer_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UnavailableReplicas requires manual conversion: does not exist in peer-type + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.Phase = in.Phase out.BootstrapReady = in.BootstrapReady out.InfrastructureReady = in.InfrastructureReady out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*apiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha3_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } -// Convert_v1alpha3_MachinePoolStatus_To_v1beta2_MachinePoolStatus is an autogenerated conversion function. -func Convert_v1alpha3_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachinePoolStatus, out *v1beta2.MachinePoolStatus, s conversion.Scope) error { - return autoConvert_v1alpha3_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in, out, s) -} - func autoConvert_v1beta2_MachinePoolStatus_To_v1alpha3_MachinePoolStatus(in *v1beta2.MachinePoolStatus, out *MachinePoolStatus, s conversion.Scope) error { - out.NodeRefs = *(*[]v1.ObjectReference)(unsafe.Pointer(&in.NodeRefs)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(corev1alpha3.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha3_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + out.NodeRefs = *(*[]corev1.ObjectReference)(unsafe.Pointer(&in.NodeRefs)) out.Replicas = in.Replicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas - out.UnavailableReplicas = in.UnavailableReplicas - out.FailureReason = (*errors.MachinePoolStatusFailure)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + if err := v1.Convert_Pointer_int32_To_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int32_To_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UpToDateReplicas requires manual conversion: does not exist in peer-type out.Phase = in.Phase out.BootstrapReady = in.BootstrapReady out.InfrastructureReady = in.InfrastructureReady out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*corev1alpha3.Conditions)(unsafe.Pointer(&in.Conditions)) - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } diff --git a/internal/apis/core/exp/v1alpha4/conversion.go b/internal/apis/core/exp/v1alpha4/conversion.go index 220c88b26a5c..d97f8137c0d8 100644 --- a/internal/apis/core/exp/v1alpha4/conversion.go +++ b/internal/apis/core/exp/v1alpha4/conversion.go @@ -17,6 +17,7 @@ limitations under the License. package v1alpha4 import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" @@ -33,6 +34,18 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha4), failureReason, failureMessage and replica counters to the deprecated field. + dst.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + clusterv1alpha4.Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason + dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage + dst.Status.Deprecated.V1Beta1.ReadyReplicas = src.Status.ReadyReplicas + dst.Status.Deprecated.V1Beta1.AvailableReplicas = src.Status.AvailableReplicas + dst.Status.Deprecated.V1Beta1.UnavailableReplicas = src.Status.UnavailableReplicas + // Manually restore data. restored := &expv1.MachinePool{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -41,7 +54,10 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Template.Spec.ReadinessGates = restored.Spec.Template.Spec.ReadinessGates dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions + dst.Status.AvailableReplicas = restored.Status.AvailableReplicas + dst.Status.ReadyReplicas = restored.Status.ReadyReplicas + dst.Status.UpToDateReplicas = restored.Status.UpToDateReplicas return nil } @@ -52,6 +68,31 @@ func (dst *MachinePool) ConvertFrom(srcRaw conversion.Hub) error { if err := Convert_v1beta2_MachinePool_To_v1alpha4_MachinePool(src, dst, nil); err != nil { return err } + + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha4). + dst.Status.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. + dst.Status.ReadyReplicas = 0 + dst.Status.AvailableReplicas = 0 + + // Retrieve legacy conditions (v1alpha4), failureReason, failureMessage and replica counters from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + clusterv1alpha4.Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason + dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage + dst.Status.ReadyReplicas = src.Status.Deprecated.V1Beta1.ReadyReplicas + dst.Status.AvailableReplicas = src.Status.Deprecated.V1Beta1.AvailableReplicas + dst.Status.UnavailableReplicas = src.Status.Deprecated.V1Beta1.UnavailableReplicas + } + } + + // Preserve Hub data on down-conversion except for metadata return utilconversion.MarshalData(src, dst) } @@ -67,3 +108,17 @@ func Convert_v1beta2_MachinePoolStatus_To_v1alpha4_MachinePoolStatus(in *expv1.M // V1Beta2 was added in v1beta1 return autoConvert_v1beta2_MachinePoolStatus_To_v1alpha4_MachinePoolStatus(in, out, s) } + +func Convert_v1alpha4_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachinePoolStatus, out *expv1.MachinePoolStatus, scope apimachineryconversion.Scope) error { + return autoConvert_v1alpha4_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in, out, scope) +} + +// Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) + +func Convert_v1_Condition_To_v1alpha4_Condition(in *metav1.Condition, out *clusterv1alpha4.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha4.Convert_v1_Condition_To_v1alpha4_Condition(in, out, s) +} + +func Convert_v1alpha4_Condition_To_v1_Condition(in *clusterv1alpha4.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha4.Convert_v1alpha4_Condition_To_v1_Condition(in, out, s) +} diff --git a/internal/apis/core/exp/v1alpha4/conversion_test.go b/internal/apis/core/exp/v1alpha4/conversion_test.go index 33c2913ff099..781fff5b92c8 100644 --- a/internal/apis/core/exp/v1alpha4/conversion_test.go +++ b/internal/apis/core/exp/v1alpha4/conversion_test.go @@ -21,6 +21,10 @@ package v1alpha4 import ( "testing" + fuzz "github.com/google/gofuzz" + "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" + runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta2" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) @@ -29,7 +33,25 @@ import ( func TestFuzzyConversion(t *testing.T) { t.Run("for MachinePool", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Hub: &expv1.MachinePool{}, - Spoke: &MachinePool{}, + Hub: &expv1.MachinePool{}, + Spoke: &MachinePool{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachinePoolFuzzFuncs}, })) } + +func MachinePoolFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubMachinePoolStatus, + } +} + +func hubMachinePoolStatus(in *expv1.MachinePoolStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + } +} diff --git a/internal/apis/core/exp/v1alpha4/zz_generated.conversion.go b/internal/apis/core/exp/v1alpha4/zz_generated.conversion.go index b6f6a42f07e6..15a0f0f73df8 100644 --- a/internal/apis/core/exp/v1alpha4/zz_generated.conversion.go +++ b/internal/apis/core/exp/v1alpha4/zz_generated.conversion.go @@ -24,11 +24,11 @@ package v1alpha4 import ( unsafe "unsafe" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" apiv1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" - errors "sigs.k8s.io/cluster-api/errors" v1beta2 "sigs.k8s.io/cluster-api/exp/api/v1beta2" corev1alpha4 "sigs.k8s.io/cluster-api/internal/apis/core/v1alpha4" ) @@ -70,7 +70,17 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachinePoolStatus)(nil), (*v1beta2.MachinePoolStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + if err := s.AddConversionFunc((*v1.Condition)(nil), (*corev1alpha4.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1alpha4_Condition(a.(*v1.Condition), b.(*corev1alpha4.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*corev1alpha4.Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_Condition_To_v1_Condition(a.(*corev1alpha4.Condition), b.(*v1.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*MachinePoolStatus)(nil), (*v1beta2.MachinePoolStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_MachinePoolStatus_To_v1beta2_MachinePoolStatus(a.(*MachinePoolStatus), b.(*v1beta2.MachinePoolStatus), scope) }); err != nil { return err @@ -202,39 +212,60 @@ func Convert_v1beta2_MachinePoolSpec_To_v1alpha4_MachinePoolSpec(in *v1beta2.Mac } func autoConvert_v1alpha4_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachinePoolStatus, out *v1beta2.MachinePoolStatus, s conversion.Scope) error { - out.NodeRefs = *(*[]v1.ObjectReference)(unsafe.Pointer(&in.NodeRefs)) + out.NodeRefs = *(*[]corev1.ObjectReference)(unsafe.Pointer(&in.NodeRefs)) out.Replicas = in.Replicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas - out.UnavailableReplicas = in.UnavailableReplicas - out.FailureReason = (*errors.MachinePoolStatusFailure)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + if err := v1.Convert_int32_To_Pointer_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_int32_To_Pointer_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UnavailableReplicas requires manual conversion: does not exist in peer-type + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.Phase = in.Phase out.BootstrapReady = in.BootstrapReady out.InfrastructureReady = in.InfrastructureReady out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*apiv1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha4_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } -// Convert_v1alpha4_MachinePoolStatus_To_v1beta2_MachinePoolStatus is an autogenerated conversion function. -func Convert_v1alpha4_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachinePoolStatus, out *v1beta2.MachinePoolStatus, s conversion.Scope) error { - return autoConvert_v1alpha4_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in, out, s) -} - func autoConvert_v1beta2_MachinePoolStatus_To_v1alpha4_MachinePoolStatus(in *v1beta2.MachinePoolStatus, out *MachinePoolStatus, s conversion.Scope) error { - out.NodeRefs = *(*[]v1.ObjectReference)(unsafe.Pointer(&in.NodeRefs)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(corev1alpha4.Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha4_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + out.NodeRefs = *(*[]corev1.ObjectReference)(unsafe.Pointer(&in.NodeRefs)) out.Replicas = in.Replicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas - out.UnavailableReplicas = in.UnavailableReplicas - out.FailureReason = (*errors.MachinePoolStatusFailure)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + if err := v1.Convert_Pointer_int32_To_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int32_To_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UpToDateReplicas requires manual conversion: does not exist in peer-type out.Phase = in.Phase out.BootstrapReady = in.BootstrapReady out.InfrastructureReady = in.InfrastructureReady out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*corev1alpha4.Conditions)(unsafe.Pointer(&in.Conditions)) - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } diff --git a/internal/apis/core/v1alpha3/conversion.go b/internal/apis/core/v1alpha3/conversion.go index d8c4cfb53376..fd8d6e37edc3 100644 --- a/internal/apis/core/v1alpha3/conversion.go +++ b/internal/apis/core/v1alpha3/conversion.go @@ -17,7 +17,10 @@ limitations under the License. package v1alpha3 import ( - apiconversion "k8s.io/apimachinery/pkg/conversion" + "unsafe" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2" @@ -32,6 +35,17 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha3), failureReason and failureMessage to the deprecated field. + if src.Status.Conditions != nil || src.Status.FailureReason != nil || src.Status.FailureMessage != nil { + dst.Status.Deprecated = &clusterv1.ClusterDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &clusterv1.ClusterV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason + dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage + } + // Given this is a bool and there is no timestamp associated with it, when this condition is set, its timestamp // will be "now". See https://github.com/kubernetes-sigs/cluster-api/issues/3798#issuecomment-708619826 for more // discussion. @@ -49,7 +63,9 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error { if restored.Spec.Topology != nil { dst.Spec.Topology = restored.Spec.Topology } - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions + dst.Status.ControlPlane = restored.Status.ControlPlane + dst.Status.Workers = restored.Status.Workers return nil } @@ -61,6 +77,21 @@ func (dst *Cluster) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha3). + dst.Status.Conditions = nil + + // Retrieve legacy conditions (v1alpha3), failureReason and failureMessage from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason + dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage + } + } + // Set the v1alpha3 boolean status field if the v1alpha4 condition was true if conditions.IsTrue(src, clusterv1.ControlPlaneInitializedCondition) { dst.Status.ControlPlaneInitialized = true @@ -81,6 +112,17 @@ func (src *Machine) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha3), failureReason and failureMessage to the deprecated field. + if src.Status.Conditions != nil || src.Status.FailureReason != nil || src.Status.FailureMessage != nil { + dst.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason + dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage + } + // Manually restore data. restored := &clusterv1.Machine{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -93,7 +135,7 @@ func (src *Machine) ConvertTo(dstRaw conversion.Hub) error { dst.Status.NodeInfo = restored.Status.NodeInfo dst.Status.CertificatesExpiryDate = restored.Status.CertificatesExpiryDate dst.Status.Deletion = restored.Status.Deletion - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions return nil } @@ -105,6 +147,21 @@ func (dst *Machine) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha3). + dst.Status.Conditions = nil + + // Retrieve legacy conditions (v1alpha3), failureReason and failureMessage from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason + dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage + } + } + // Preserve Hub data on down-conversion except for metadata if err := utilconversion.MarshalData(src, dst); err != nil { return err @@ -119,6 +176,16 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error { if err := Convert_v1alpha3_MachineSet_To_v1beta2_MachineSet(src, dst, nil); err != nil { return err } + + // Move failureReason, failureMessage and replica counters to the deprecated field. + dst.Status.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} + dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason + dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage + dst.Status.Deprecated.V1Beta1.ReadyReplicas = src.Status.ReadyReplicas + dst.Status.Deprecated.V1Beta1.AvailableReplicas = src.Status.AvailableReplicas + dst.Status.Deprecated.V1Beta1.FullyLabeledReplicas = src.Status.FullyLabeledReplicas + // Manually restore data. restored := &clusterv1.MachineSet{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -128,7 +195,9 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout dst.Status.Conditions = restored.Status.Conditions - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.AvailableReplicas = restored.Status.AvailableReplicas + dst.Status.ReadyReplicas = restored.Status.ReadyReplicas + dst.Status.UpToDateReplicas = restored.Status.UpToDateReplicas if restored.Spec.MachineNamingStrategy != nil { dst.Spec.MachineNamingStrategy = restored.Spec.MachineNamingStrategy @@ -143,6 +212,22 @@ func (dst *MachineSet) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset replica counters from autogenerated conversions + // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. + dst.Status.AvailableReplicas = 0 + dst.Status.ReadyReplicas = 0 + + // Retrieve failureReason, failureMessage and replica counters from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason + dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage + dst.Status.ReadyReplicas = src.Status.Deprecated.V1Beta1.ReadyReplicas + dst.Status.AvailableReplicas = src.Status.Deprecated.V1Beta1.AvailableReplicas + dst.Status.FullyLabeledReplicas = src.Status.Deprecated.V1Beta1.FullyLabeledReplicas + } + } + // Preserve Hub data on down-conversion except for metadata if err := utilconversion.MarshalData(src, dst); err != nil { return err @@ -157,6 +242,14 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move replica counters to the deprecated field. + dst.Status.Deprecated = &clusterv1.MachineDeploymentDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{} + dst.Status.Deprecated.V1Beta1.ReadyReplicas = src.Status.ReadyReplicas + dst.Status.Deprecated.V1Beta1.AvailableReplicas = src.Status.AvailableReplicas + dst.Status.Deprecated.V1Beta1.UpdatedReplicas = src.Status.UpdatedReplicas + dst.Status.Deprecated.V1Beta1.UnavailableReplicas = src.Status.UnavailableReplicas + // Manually restore data. restored := &clusterv1.MachineDeployment{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -185,7 +278,9 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout dst.Spec.RolloutAfter = restored.Spec.RolloutAfter dst.Status.Conditions = restored.Status.Conditions - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.AvailableReplicas = restored.Status.AvailableReplicas + dst.Status.ReadyReplicas = restored.Status.ReadyReplicas + dst.Status.UpToDateReplicas = restored.Status.UpToDateReplicas return nil } @@ -197,6 +292,21 @@ func (dst *MachineDeployment) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset replica counters from autogenerated conversions + // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. + dst.Status.AvailableReplicas = 0 + dst.Status.ReadyReplicas = 0 + + // Retrieve failureReason, failureMessage and replica counters from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + dst.Status.ReadyReplicas = src.Status.Deprecated.V1Beta1.ReadyReplicas + dst.Status.AvailableReplicas = src.Status.Deprecated.V1Beta1.AvailableReplicas + dst.Status.UpdatedReplicas = src.Status.Deprecated.V1Beta1.UpdatedReplicas + dst.Status.UnavailableReplicas = src.Status.Deprecated.V1Beta1.UnavailableReplicas + } + } + // Preserve Hub data on down-conversion except for metadata if err := utilconversion.MarshalData(src, dst); err != nil { return err @@ -212,6 +322,15 @@ func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha3) to the deprecated field. + if src.Status.Conditions != nil { + dst.Status.Deprecated = &clusterv1.MachineHealthCheckDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + } + // Manually restore data. restored := &clusterv1.MachineHealthCheck{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -221,7 +340,7 @@ func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error { if restored.Spec.UnhealthyRange != nil { dst.Spec.UnhealthyRange = restored.Spec.UnhealthyRange } - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions return nil } @@ -233,6 +352,19 @@ func (dst *MachineHealthCheck) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha3). + dst.Status.Conditions = nil + + // Retrieve legacy conditions (v1alpha3) from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + } + } + // Preserve Hub data on down-conversion except for metadata if err := utilconversion.MarshalData(src, dst); err != nil { return err @@ -241,78 +373,110 @@ func (dst *MachineHealthCheck) ConvertFrom(srcRaw conversion.Hub) error { return nil } -func Convert_v1beta2_MachineSetStatus_To_v1alpha3_MachineSetStatus(in *clusterv1.MachineSetStatus, out *MachineSetStatus, _ apiconversion.Scope) error { +func Convert_v1beta2_MachineSetStatus_To_v1alpha3_MachineSetStatus(in *clusterv1.MachineSetStatus, out *MachineSetStatus, _ apimachineryconversion.Scope) error { // Status.Conditions was introduced in v1alpha4, thus requiring a custom conversion function; the values is going to be preserved in an annotation thus allowing roundtrip without loosing informations // V1Beta2 was added in v1beta1. return autoConvert_v1beta2_MachineSetStatus_To_v1alpha3_MachineSetStatus(in, out, nil) } -func Convert_v1beta2_ClusterSpec_To_v1alpha3_ClusterSpec(in *clusterv1.ClusterSpec, out *ClusterSpec, s apiconversion.Scope) error { +func Convert_v1beta2_ClusterSpec_To_v1alpha3_ClusterSpec(in *clusterv1.ClusterSpec, out *ClusterSpec, s apimachineryconversion.Scope) error { // NOTE: custom conversion func is required because spec.Topology does not exist in v1alpha3 // AvailabilityGates was added in v1beta1. return autoConvert_v1beta2_ClusterSpec_To_v1alpha3_ClusterSpec(in, out, s) } -func Convert_v1beta2_ClusterStatus_To_v1alpha3_ClusterStatus(in *clusterv1.ClusterStatus, out *ClusterStatus, s apiconversion.Scope) error { +func Convert_v1beta2_ClusterStatus_To_v1alpha3_ClusterStatus(in *clusterv1.ClusterStatus, out *ClusterStatus, s apimachineryconversion.Scope) error { // V1Beta2 was added in v1beta1. return autoConvert_v1beta2_ClusterStatus_To_v1alpha3_ClusterStatus(in, out, s) } -func Convert_v1alpha3_Bootstrap_To_v1beta2_Bootstrap(in *Bootstrap, out *clusterv1.Bootstrap, s apiconversion.Scope) error { +func Convert_v1alpha3_Bootstrap_To_v1beta2_Bootstrap(in *Bootstrap, out *clusterv1.Bootstrap, s apimachineryconversion.Scope) error { return autoConvert_v1alpha3_Bootstrap_To_v1beta2_Bootstrap(in, out, s) } -func Convert_v1beta2_MachineRollingUpdateDeployment_To_v1alpha3_MachineRollingUpdateDeployment(in *clusterv1.MachineRollingUpdateDeployment, out *MachineRollingUpdateDeployment, s apiconversion.Scope) error { +func Convert_v1beta2_MachineRollingUpdateDeployment_To_v1alpha3_MachineRollingUpdateDeployment(in *clusterv1.MachineRollingUpdateDeployment, out *MachineRollingUpdateDeployment, s apimachineryconversion.Scope) error { return autoConvert_v1beta2_MachineRollingUpdateDeployment_To_v1alpha3_MachineRollingUpdateDeployment(in, out, s) } -func Convert_v1beta2_MachineHealthCheckSpec_To_v1alpha3_MachineHealthCheckSpec(in *clusterv1.MachineHealthCheckSpec, out *MachineHealthCheckSpec, s apiconversion.Scope) error { +func Convert_v1beta2_MachineHealthCheckSpec_To_v1alpha3_MachineHealthCheckSpec(in *clusterv1.MachineHealthCheckSpec, out *MachineHealthCheckSpec, s apimachineryconversion.Scope) error { return autoConvert_v1beta2_MachineHealthCheckSpec_To_v1alpha3_MachineHealthCheckSpec(in, out, s) } -func Convert_v1beta2_MachineHealthCheckStatus_To_v1alpha3_MachineHealthCheckStatus(in *clusterv1.MachineHealthCheckStatus, out *MachineHealthCheckStatus, s apiconversion.Scope) error { +func Convert_v1beta2_MachineHealthCheckStatus_To_v1alpha3_MachineHealthCheckStatus(in *clusterv1.MachineHealthCheckStatus, out *MachineHealthCheckStatus, s apimachineryconversion.Scope) error { // V1Beta2 was added in v1beta1. return autoConvert_v1beta2_MachineHealthCheckStatus_To_v1alpha3_MachineHealthCheckStatus(in, out, s) } -func Convert_v1alpha3_ClusterStatus_To_v1beta2_ClusterStatus(in *ClusterStatus, out *clusterv1.ClusterStatus, s apiconversion.Scope) error { +func Convert_v1alpha3_ClusterStatus_To_v1beta2_ClusterStatus(in *ClusterStatus, out *clusterv1.ClusterStatus, s apimachineryconversion.Scope) error { return autoConvert_v1alpha3_ClusterStatus_To_v1beta2_ClusterStatus(in, out, s) } -func Convert_v1alpha3_ObjectMeta_To_v1beta2_ObjectMeta(in *ObjectMeta, out *clusterv1.ObjectMeta, s apiconversion.Scope) error { +func Convert_v1alpha3_ObjectMeta_To_v1beta2_ObjectMeta(in *ObjectMeta, out *clusterv1.ObjectMeta, s apimachineryconversion.Scope) error { return autoConvert_v1alpha3_ObjectMeta_To_v1beta2_ObjectMeta(in, out, s) } -func Convert_v1beta2_MachineStatus_To_v1alpha3_MachineStatus(in *clusterv1.MachineStatus, out *MachineStatus, s apiconversion.Scope) error { +func Convert_v1beta2_MachineStatus_To_v1alpha3_MachineStatus(in *clusterv1.MachineStatus, out *MachineStatus, s apimachineryconversion.Scope) error { // V1Beta2 was added in v1beta1. return autoConvert_v1beta2_MachineStatus_To_v1alpha3_MachineStatus(in, out, s) } -func Convert_v1beta2_MachineSpec_To_v1alpha3_MachineSpec(in *clusterv1.MachineSpec, out *MachineSpec, s apiconversion.Scope) error { +func Convert_v1beta2_MachineSpec_To_v1alpha3_MachineSpec(in *clusterv1.MachineSpec, out *MachineSpec, s apimachineryconversion.Scope) error { // spec.nodeDeletionTimeout was added in v1beta1. // ReadinessGates was added in v1beta1. return autoConvert_v1beta2_MachineSpec_To_v1alpha3_MachineSpec(in, out, s) } -func Convert_v1beta2_MachineDeploymentSpec_To_v1alpha3_MachineDeploymentSpec(in *clusterv1.MachineDeploymentSpec, out *MachineDeploymentSpec, s apiconversion.Scope) error { +func Convert_v1beta2_MachineDeploymentSpec_To_v1alpha3_MachineDeploymentSpec(in *clusterv1.MachineDeploymentSpec, out *MachineDeploymentSpec, s apimachineryconversion.Scope) error { return autoConvert_v1beta2_MachineDeploymentSpec_To_v1alpha3_MachineDeploymentSpec(in, out, s) } -func Convert_v1beta2_MachineDeploymentStatus_To_v1alpha3_MachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, out *MachineDeploymentStatus, s apiconversion.Scope) error { +func Convert_v1beta2_MachineDeploymentStatus_To_v1alpha3_MachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, out *MachineDeploymentStatus, s apimachineryconversion.Scope) error { // Status.Conditions was introduced in v1alpha4, thus requiring a custom conversion function; the values is going to be preserved in an annotation thus allowing roundtrip without loosing informations // V1Beta2 was added in v1beta1. return autoConvert_v1beta2_MachineDeploymentStatus_To_v1alpha3_MachineDeploymentStatus(in, out, s) } -func Convert_v1alpha3_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, out *clusterv1.MachineStatus, s apiconversion.Scope) error { +func Convert_v1alpha3_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, out *clusterv1.MachineStatus, s apimachineryconversion.Scope) error { // Status.version has been removed in v1beta1, thus requiring custom conversion function. the information will be dropped. return autoConvert_v1alpha3_MachineStatus_To_v1beta2_MachineStatus(in, out, s) } -func Convert_v1beta2_MachineDeploymentStrategy_To_v1alpha3_MachineDeploymentStrategy(in *clusterv1.MachineDeploymentStrategy, out *MachineDeploymentStrategy, s apiconversion.Scope) error { +func Convert_v1beta2_MachineDeploymentStrategy_To_v1alpha3_MachineDeploymentStrategy(in *clusterv1.MachineDeploymentStrategy, out *MachineDeploymentStrategy, s apimachineryconversion.Scope) error { return autoConvert_v1beta2_MachineDeploymentStrategy_To_v1alpha3_MachineDeploymentStrategy(in, out, s) } -func Convert_v1beta2_MachineSetSpec_To_v1alpha3_MachineSetSpec(in *clusterv1.MachineSetSpec, out *MachineSetSpec, s apiconversion.Scope) error { +func Convert_v1beta2_MachineSetSpec_To_v1alpha3_MachineSetSpec(in *clusterv1.MachineSetSpec, out *MachineSetSpec, s apimachineryconversion.Scope) error { return autoConvert_v1beta2_MachineSetSpec_To_v1alpha3_MachineSetSpec(in, out, s) } + +func Convert_v1alpha3_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(in *MachineDeploymentStatus, out *clusterv1.MachineDeploymentStatus, s apimachineryconversion.Scope) error { + return autoConvert_v1alpha3_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(in, out, s) +} + +func Convert_v1alpha3_MachineSetStatus_To_v1beta2_MachineSetStatus(in *MachineSetStatus, out *clusterv1.MachineSetStatus, s apimachineryconversion.Scope) error { + return autoConvert_v1alpha3_MachineSetStatus_To_v1beta2_MachineSetStatus(in, out, s) +} + +func Convert_v1_Condition_To_v1alpha3_Condition(_ *metav1.Condition, _ *Condition, _ apimachineryconversion.Scope) error { + // NOTE: v1beta2 conditions should not be automatically converted into legacy (v1alpha3) conditions. + return nil +} + +func Convert_v1alpha3_Condition_To_v1_Condition(_ *Condition, _ *metav1.Condition, _ apimachineryconversion.Scope) error { + // NOTE: legacy (v1alpha3) conditions should not be automatically converted into v1beta2 conditions. + return nil +} + +func Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(in *clusterv1.Conditions, out *Conditions) { + *out = make(Conditions, len(*in)) + for i := range *in { + (*out)[i] = *(*Condition)(unsafe.Pointer(&(*in)[i])) + } +} + +func Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(in *Conditions, out *clusterv1.Conditions) { + *out = make(clusterv1.Conditions, len(*in)) + for i := range *in { + (*out)[i] = *(*clusterv1.Condition)(unsafe.Pointer(&(*in)[i])) + } +} diff --git a/internal/apis/core/v1alpha3/conversion_test.go b/internal/apis/core/v1alpha3/conversion_test.go index 77c17e085c43..888c55e52ddf 100644 --- a/internal/apis/core/v1alpha3/conversion_test.go +++ b/internal/apis/core/v1alpha3/conversion_test.go @@ -38,40 +38,53 @@ func TestFuzzyConversion(t *testing.T) { Hub: &clusterv1.Cluster{}, Spoke: &Cluster{}, SpokeAfterMutation: clusterSpokeAfterMutation, - FuzzerFuncs: []fuzzer.FuzzerFuncs{ClusterJSONFuzzFuncs}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{ClusterFuncs}, })) t.Run("for Machine", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.Machine{}, Spoke: &Machine{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{BootstrapFuzzFuncs, MachineStatusFuzzFunc}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineFuzzFunc}, })) t.Run("for MachineSet", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.MachineSet{}, Spoke: &MachineSet{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{BootstrapFuzzFuncs, CustomObjectMetaFuzzFunc}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineSetFuzzFunc}, })) t.Run("for MachineDeployment", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.MachineDeployment{}, Spoke: &MachineDeployment{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{BootstrapFuzzFuncs, CustomObjectMetaFuzzFunc}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineDeploymentFuzzFunc}, })) t.Run("for MachineHealthCheck", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Hub: &clusterv1.MachineHealthCheck{}, - Spoke: &MachineHealthCheck{}, + Hub: &clusterv1.MachineHealthCheck{}, + Spoke: &MachineHealthCheck{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineHealthCheckFuzzFunc}, })) } -func MachineStatusFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { +func MachineFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - MachineStatusFuzzer, + hubMachineStatus, + spokeMachineStatus, + spokeBootstrap, } } -func MachineStatusFuzzer(in *MachineStatus, c fuzz.Continue) { +func hubMachineStatus(in *clusterv1.MachineStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + in.Deprecated = nil + } + } +} + +func spokeMachineStatus(in *MachineStatus, c fuzz.Continue) { c.FuzzNoCustom(in) // These fields have been removed in v1beta1 @@ -79,13 +92,45 @@ func MachineStatusFuzzer(in *MachineStatus, c fuzz.Continue) { in.Version = nil } -func CustomObjectMetaFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { +func MachineSetFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubMachineSetStatus, + spokeObjectMeta, + spokeBootstrap, + } +} + +func hubMachineSetStatus(in *clusterv1.MachineSetStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} + } +} + +func MachineDeploymentFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - CustomObjectMetaFuzzer, + hubMachineDeploymentStatus, + spokeObjectMeta, + spokeBootstrap, + } +} + +func hubMachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &clusterv1.MachineDeploymentDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{} } } -func CustomObjectMetaFuzzer(in *ObjectMeta, c fuzz.Continue) { +func spokeObjectMeta(in *ObjectMeta, c fuzz.Continue) { c.FuzzNoCustom(in) // These fields have been removed in v1alpha4 @@ -96,13 +141,7 @@ func CustomObjectMetaFuzzer(in *ObjectMeta, c fuzz.Continue) { in.OwnerReferences = nil } -func BootstrapFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { - return []interface{}{ - BootstrapFuzzer, - } -} - -func BootstrapFuzzer(obj *Bootstrap, c fuzz.Continue) { +func spokeBootstrap(obj *Bootstrap, c fuzz.Continue) { c.FuzzNoCustom(obj) // Bootstrap.Data has been removed in v1alpha4, so setting it to nil in order to avoid v1alpha3 --> --> v1alpha3 round trip errors. @@ -131,15 +170,42 @@ func clusterSpokeAfterMutation(c conversion.Convertible) { cluster.Status.Conditions = tmp } -func ClusterJSONFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { +func ClusterFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - ClusterVariableFuzzer, + hubClusterStatus, + hubClusterVariable, + } +} + +func hubClusterStatus(in *clusterv1.ClusterStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + in.Deprecated = nil + } } } -func ClusterVariableFuzzer(in *clusterv1.ClusterVariable, c fuzz.Continue) { +func hubClusterVariable(in *clusterv1.ClusterVariable, c fuzz.Continue) { c.FuzzNoCustom(in) // Not every random byte array is valid JSON, e.g. a string without `""`,so we're setting a valid value. in.Value = apiextensionsv1.JSON{Raw: []byte("\"test-string\"")} } + +func MachineHealthCheckFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubMachineHealthCheckStatus, + } +} + +func hubMachineHealthCheckStatus(in *clusterv1.MachineHealthCheckStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + in.Deprecated = nil + } + } +} diff --git a/internal/apis/core/v1alpha3/zz_generated.conversion.go b/internal/apis/core/v1alpha3/zz_generated.conversion.go index 4472dff79fb7..560f097d4f36 100644 --- a/internal/apis/core/v1alpha3/zz_generated.conversion.go +++ b/internal/apis/core/v1alpha3/zz_generated.conversion.go @@ -24,13 +24,12 @@ package v1alpha3 import ( unsafe "unsafe" - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" intstr "k8s.io/apimachinery/pkg/util/intstr" v1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" - errors "sigs.k8s.io/cluster-api/errors" ) func init() { @@ -155,11 +154,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachineDeploymentStatus)(nil), (*v1beta2.MachineDeploymentStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha3_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(a.(*MachineDeploymentStatus), b.(*v1beta2.MachineDeploymentStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*MachineDeploymentStrategy)(nil), (*v1beta2.MachineDeploymentStrategy)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha3_MachineDeploymentStrategy_To_v1beta2_MachineDeploymentStrategy(a.(*MachineDeploymentStrategy), b.(*v1beta2.MachineDeploymentStrategy), scope) }); err != nil { @@ -235,11 +229,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachineSetStatus)(nil), (*v1beta2.MachineSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha3_MachineSetStatus_To_v1beta2_MachineSetStatus(a.(*MachineSetStatus), b.(*v1beta2.MachineSetStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*MachineSpec)(nil), (*v1beta2.MachineSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha3_MachineSpec_To_v1beta2_MachineSpec(a.(*MachineSpec), b.(*v1beta2.MachineSpec), scope) }); err != nil { @@ -280,6 +269,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1.Condition)(nil), (*Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1alpha3_Condition(a.(*v1.Condition), b.(*Condition), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*Bootstrap)(nil), (*v1beta2.Bootstrap)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha3_Bootstrap_To_v1beta2_Bootstrap(a.(*Bootstrap), b.(*v1beta2.Bootstrap), scope) }); err != nil { @@ -290,6 +284,21 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha3_Condition_To_v1_Condition(a.(*Condition), b.(*v1.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*MachineDeploymentStatus)(nil), (*v1beta2.MachineDeploymentStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha3_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(a.(*MachineDeploymentStatus), b.(*v1beta2.MachineDeploymentStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*MachineSetStatus)(nil), (*v1beta2.MachineSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha3_MachineSetStatus_To_v1beta2_MachineSetStatus(a.(*MachineSetStatus), b.(*v1beta2.MachineSetStatus), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*MachineStatus)(nil), (*v1beta2.MachineStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha3_MachineStatus_To_v1beta2_MachineStatus(a.(*MachineStatus), b.(*v1beta2.MachineStatus), scope) }); err != nil { @@ -386,14 +395,14 @@ func Convert_v1beta2_APIEndpoint_To_v1alpha3_APIEndpoint(in *v1beta2.APIEndpoint } func autoConvert_v1alpha3_Bootstrap_To_v1beta2_Bootstrap(in *Bootstrap, out *v1beta2.Bootstrap, s conversion.Scope) error { - out.ConfigRef = (*v1.ObjectReference)(unsafe.Pointer(in.ConfigRef)) + out.ConfigRef = (*corev1.ObjectReference)(unsafe.Pointer(in.ConfigRef)) // WARNING: in.Data requires manual conversion: does not exist in peer-type out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) return nil } func autoConvert_v1beta2_Bootstrap_To_v1alpha3_Bootstrap(in *v1beta2.Bootstrap, out *Bootstrap, s conversion.Scope) error { - out.ConfigRef = (*v1.ObjectReference)(unsafe.Pointer(in.ConfigRef)) + out.ConfigRef = (*corev1.ObjectReference)(unsafe.Pointer(in.ConfigRef)) out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) return nil } @@ -509,8 +518,8 @@ func autoConvert_v1alpha3_ClusterSpec_To_v1beta2_ClusterSpec(in *ClusterSpec, ou if err := Convert_v1alpha3_APIEndpoint_To_v1beta2_APIEndpoint(&in.ControlPlaneEndpoint, &out.ControlPlaneEndpoint, s); err != nil { return err } - out.ControlPlaneRef = (*v1.ObjectReference)(unsafe.Pointer(in.ControlPlaneRef)) - out.InfrastructureRef = (*v1.ObjectReference)(unsafe.Pointer(in.InfrastructureRef)) + out.ControlPlaneRef = (*corev1.ObjectReference)(unsafe.Pointer(in.ControlPlaneRef)) + out.InfrastructureRef = (*corev1.ObjectReference)(unsafe.Pointer(in.InfrastructureRef)) return nil } @@ -525,8 +534,8 @@ func autoConvert_v1beta2_ClusterSpec_To_v1alpha3_ClusterSpec(in *v1beta2.Cluster if err := Convert_v1beta2_APIEndpoint_To_v1alpha3_APIEndpoint(&in.ControlPlaneEndpoint, &out.ControlPlaneEndpoint, s); err != nil { return err } - out.ControlPlaneRef = (*v1.ObjectReference)(unsafe.Pointer(in.ControlPlaneRef)) - out.InfrastructureRef = (*v1.ObjectReference)(unsafe.Pointer(in.InfrastructureRef)) + out.ControlPlaneRef = (*corev1.ObjectReference)(unsafe.Pointer(in.ControlPlaneRef)) + out.InfrastructureRef = (*corev1.ObjectReference)(unsafe.Pointer(in.InfrastructureRef)) // WARNING: in.Topology requires manual conversion: does not exist in peer-type // WARNING: in.AvailabilityGates requires manual conversion: does not exist in peer-type return nil @@ -534,33 +543,53 @@ func autoConvert_v1beta2_ClusterSpec_To_v1alpha3_ClusterSpec(in *v1beta2.Cluster func autoConvert_v1alpha3_ClusterStatus_To_v1beta2_ClusterStatus(in *ClusterStatus, out *v1beta2.ClusterStatus, s conversion.Scope) error { out.FailureDomains = *(*v1beta2.FailureDomains)(unsafe.Pointer(&in.FailureDomains)) - out.FailureReason = (*errors.ClusterStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.Phase = in.Phase out.InfrastructureReady = in.InfrastructureReady // WARNING: in.ControlPlaneInitialized requires manual conversion: does not exist in peer-type out.ControlPlaneReady = in.ControlPlaneReady - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha3_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.ObservedGeneration = in.ObservedGeneration return nil } func autoConvert_v1beta2_ClusterStatus_To_v1alpha3_ClusterStatus(in *v1beta2.ClusterStatus, out *ClusterStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha3_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + // WARNING: in.ControlPlane requires manual conversion: does not exist in peer-type + // WARNING: in.Workers requires manual conversion: does not exist in peer-type out.FailureDomains = *(*FailureDomains)(unsafe.Pointer(&in.FailureDomains)) - out.FailureReason = (*errors.ClusterStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) out.Phase = in.Phase out.InfrastructureReady = in.InfrastructureReady out.ControlPlaneReady = in.ControlPlaneReady - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) out.ObservedGeneration = in.ObservedGeneration - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } func autoConvert_v1alpha3_Condition_To_v1beta2_Condition(in *Condition, out *v1beta2.Condition, s conversion.Scope) error { out.Type = v1beta2.ConditionType(in.Type) - out.Status = v1.ConditionStatus(in.Status) + out.Status = corev1.ConditionStatus(in.Status) out.Severity = v1beta2.ConditionSeverity(in.Severity) out.LastTransitionTime = in.LastTransitionTime out.Reason = in.Reason @@ -575,7 +604,7 @@ func Convert_v1alpha3_Condition_To_v1beta2_Condition(in *Condition, out *v1beta2 func autoConvert_v1beta2_Condition_To_v1alpha3_Condition(in *v1beta2.Condition, out *Condition, s conversion.Scope) error { out.Type = ConditionType(in.Type) - out.Status = v1.ConditionStatus(in.Status) + out.Status = corev1.ConditionStatus(in.Status) out.Severity = ConditionSeverity(in.Severity) out.LastTransitionTime = in.LastTransitionTime out.Reason = in.Reason @@ -795,30 +824,32 @@ func autoConvert_v1alpha3_MachineDeploymentStatus_To_v1beta2_MachineDeploymentSt out.ObservedGeneration = in.ObservedGeneration out.Selector = in.Selector out.Replicas = in.Replicas - out.UpdatedReplicas = in.UpdatedReplicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas - out.UnavailableReplicas = in.UnavailableReplicas + // WARNING: in.UpdatedReplicas requires manual conversion: does not exist in peer-type + if err := v1.Convert_int32_To_Pointer_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_int32_To_Pointer_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UnavailableReplicas requires manual conversion: does not exist in peer-type out.Phase = in.Phase return nil } -// Convert_v1alpha3_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus is an autogenerated conversion function. -func Convert_v1alpha3_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(in *MachineDeploymentStatus, out *v1beta2.MachineDeploymentStatus, s conversion.Scope) error { - return autoConvert_v1alpha3_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(in, out, s) -} - func autoConvert_v1beta2_MachineDeploymentStatus_To_v1alpha3_MachineDeploymentStatus(in *v1beta2.MachineDeploymentStatus, out *MachineDeploymentStatus, s conversion.Scope) error { + // WARNING: in.Conditions requires manual conversion: does not exist in peer-type out.ObservedGeneration = in.ObservedGeneration out.Selector = in.Selector out.Replicas = in.Replicas - out.UpdatedReplicas = in.UpdatedReplicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas - out.UnavailableReplicas = in.UnavailableReplicas + if err := v1.Convert_Pointer_int32_To_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int32_To_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UpToDateReplicas requires manual conversion: does not exist in peer-type out.Phase = in.Phase - // WARNING: in.Conditions requires manual conversion: does not exist in peer-type - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } @@ -935,8 +966,8 @@ func autoConvert_v1alpha3_MachineHealthCheckSpec_To_v1beta2_MachineHealthCheckSp out.Selector = in.Selector out.UnhealthyConditions = *(*[]v1beta2.UnhealthyCondition)(unsafe.Pointer(&in.UnhealthyConditions)) out.MaxUnhealthy = (*intstr.IntOrString)(unsafe.Pointer(in.MaxUnhealthy)) - out.NodeStartupTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) - out.RemediationTemplate = (*v1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) + out.NodeStartupTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) + out.RemediationTemplate = (*corev1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) return nil } @@ -951,8 +982,8 @@ func autoConvert_v1beta2_MachineHealthCheckSpec_To_v1alpha3_MachineHealthCheckSp out.UnhealthyConditions = *(*[]UnhealthyCondition)(unsafe.Pointer(&in.UnhealthyConditions)) out.MaxUnhealthy = (*intstr.IntOrString)(unsafe.Pointer(in.MaxUnhealthy)) // WARNING: in.UnhealthyRange requires manual conversion: does not exist in peer-type - out.NodeStartupTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) - out.RemediationTemplate = (*v1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) + out.NodeStartupTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) + out.RemediationTemplate = (*corev1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) return nil } @@ -962,7 +993,17 @@ func autoConvert_v1alpha3_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheck out.RemediationsAllowed = in.RemediationsAllowed out.ObservedGeneration = in.ObservedGeneration out.Targets = *(*[]string)(unsafe.Pointer(&in.Targets)) - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha3_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } @@ -972,13 +1013,23 @@ func Convert_v1alpha3_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheckStat } func autoConvert_v1beta2_MachineHealthCheckStatus_To_v1alpha3_MachineHealthCheckStatus(in *v1beta2.MachineHealthCheckStatus, out *MachineHealthCheckStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha3_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.ExpectedMachines = in.ExpectedMachines out.CurrentHealthy = in.CurrentHealthy out.RemediationsAllowed = in.RemediationsAllowed out.ObservedGeneration = in.ObservedGeneration out.Targets = *(*[]string)(unsafe.Pointer(&in.Targets)) - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } @@ -1149,31 +1200,32 @@ func autoConvert_v1beta2_MachineSetSpec_To_v1alpha3_MachineSetSpec(in *v1beta2.M func autoConvert_v1alpha3_MachineSetStatus_To_v1beta2_MachineSetStatus(in *MachineSetStatus, out *v1beta2.MachineSetStatus, s conversion.Scope) error { out.Selector = in.Selector out.Replicas = in.Replicas - out.FullyLabeledReplicas = in.FullyLabeledReplicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas + // WARNING: in.FullyLabeledReplicas requires manual conversion: does not exist in peer-type + if err := v1.Convert_int32_To_Pointer_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_int32_To_Pointer_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } out.ObservedGeneration = in.ObservedGeneration - out.FailureReason = (*errors.MachineSetStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type return nil } -// Convert_v1alpha3_MachineSetStatus_To_v1beta2_MachineSetStatus is an autogenerated conversion function. -func Convert_v1alpha3_MachineSetStatus_To_v1beta2_MachineSetStatus(in *MachineSetStatus, out *v1beta2.MachineSetStatus, s conversion.Scope) error { - return autoConvert_v1alpha3_MachineSetStatus_To_v1beta2_MachineSetStatus(in, out, s) -} - func autoConvert_v1beta2_MachineSetStatus_To_v1alpha3_MachineSetStatus(in *v1beta2.MachineSetStatus, out *MachineSetStatus, s conversion.Scope) error { + // WARNING: in.Conditions requires manual conversion: does not exist in peer-type out.Selector = in.Selector out.Replicas = in.Replicas - out.FullyLabeledReplicas = in.FullyLabeledReplicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas + if err := v1.Convert_Pointer_int32_To_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int32_To_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UpToDateReplicas requires manual conversion: does not exist in peer-type out.ObservedGeneration = in.ObservedGeneration - out.FailureReason = (*errors.MachineSetStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) - // WARNING: in.Conditions requires manual conversion: does not exist in peer-type - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } @@ -1186,7 +1238,7 @@ func autoConvert_v1alpha3_MachineSpec_To_v1beta2_MachineSpec(in *MachineSpec, ou out.Version = (*string)(unsafe.Pointer(in.Version)) out.ProviderID = (*string)(unsafe.Pointer(in.ProviderID)) out.FailureDomain = (*string)(unsafe.Pointer(in.FailureDomain)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) return nil } @@ -1205,42 +1257,60 @@ func autoConvert_v1beta2_MachineSpec_To_v1alpha3_MachineSpec(in *v1beta2.Machine out.ProviderID = (*string)(unsafe.Pointer(in.ProviderID)) out.FailureDomain = (*string)(unsafe.Pointer(in.FailureDomain)) // WARNING: in.ReadinessGates requires manual conversion: does not exist in peer-type - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) // WARNING: in.NodeVolumeDetachTimeout requires manual conversion: does not exist in peer-type // WARNING: in.NodeDeletionTimeout requires manual conversion: does not exist in peer-type return nil } func autoConvert_v1alpha3_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, out *v1beta2.MachineStatus, s conversion.Scope) error { - out.NodeRef = (*v1.ObjectReference)(unsafe.Pointer(in.NodeRef)) - out.LastUpdated = (*metav1.Time)(unsafe.Pointer(in.LastUpdated)) + out.NodeRef = (*corev1.ObjectReference)(unsafe.Pointer(in.NodeRef)) + out.LastUpdated = (*v1.Time)(unsafe.Pointer(in.LastUpdated)) // WARNING: in.Version requires manual conversion: does not exist in peer-type - out.FailureReason = (*errors.MachineStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.Addresses = *(*v1beta2.MachineAddresses)(unsafe.Pointer(&in.Addresses)) out.Phase = in.Phase out.BootstrapReady = in.BootstrapReady out.InfrastructureReady = in.InfrastructureReady out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha3_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } func autoConvert_v1beta2_MachineStatus_To_v1alpha3_MachineStatus(in *v1beta2.MachineStatus, out *MachineStatus, s conversion.Scope) error { - out.NodeRef = (*v1.ObjectReference)(unsafe.Pointer(in.NodeRef)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha3_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + out.NodeRef = (*corev1.ObjectReference)(unsafe.Pointer(in.NodeRef)) // WARNING: in.NodeInfo requires manual conversion: does not exist in peer-type - out.LastUpdated = (*metav1.Time)(unsafe.Pointer(in.LastUpdated)) - out.FailureReason = (*errors.MachineStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + out.LastUpdated = (*v1.Time)(unsafe.Pointer(in.LastUpdated)) out.Addresses = *(*MachineAddresses)(unsafe.Pointer(&in.Addresses)) out.Phase = in.Phase // WARNING: in.CertificatesExpiryDate requires manual conversion: does not exist in peer-type out.BootstrapReady = in.BootstrapReady out.InfrastructureReady = in.InfrastructureReady out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) // WARNING: in.Deletion requires manual conversion: does not exist in peer-type - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } @@ -1316,8 +1386,8 @@ func Convert_v1beta2_ObjectMeta_To_v1alpha3_ObjectMeta(in *v1beta2.ObjectMeta, o } func autoConvert_v1alpha3_UnhealthyCondition_To_v1beta2_UnhealthyCondition(in *UnhealthyCondition, out *v1beta2.UnhealthyCondition, s conversion.Scope) error { - out.Type = v1.NodeConditionType(in.Type) - out.Status = v1.ConditionStatus(in.Status) + out.Type = corev1.NodeConditionType(in.Type) + out.Status = corev1.ConditionStatus(in.Status) out.Timeout = in.Timeout return nil } @@ -1328,8 +1398,8 @@ func Convert_v1alpha3_UnhealthyCondition_To_v1beta2_UnhealthyCondition(in *Unhea } func autoConvert_v1beta2_UnhealthyCondition_To_v1alpha3_UnhealthyCondition(in *v1beta2.UnhealthyCondition, out *UnhealthyCondition, s conversion.Scope) error { - out.Type = v1.NodeConditionType(in.Type) - out.Status = v1.ConditionStatus(in.Status) + out.Type = corev1.NodeConditionType(in.Type) + out.Status = corev1.ConditionStatus(in.Status) out.Timeout = in.Timeout return nil } diff --git a/internal/apis/core/v1alpha4/conversion.go b/internal/apis/core/v1alpha4/conversion.go index bdb091832b2b..2750c4028971 100644 --- a/internal/apis/core/v1alpha4/conversion.go +++ b/internal/apis/core/v1alpha4/conversion.go @@ -17,7 +17,10 @@ limitations under the License. package v1alpha4 import ( - apiconversion "k8s.io/apimachinery/pkg/conversion" + "unsafe" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2" @@ -31,6 +34,17 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha4), failureReason and failureMessage to the deprecated field. + if src.Status.Conditions != nil || src.Status.FailureReason != nil || src.Status.FailureMessage != nil { + dst.Status.Deprecated = &clusterv1.ClusterDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &clusterv1.ClusterV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason + dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage + } + // Manually restore data. restored := &clusterv1.Cluster{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -82,7 +96,9 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Topology.Workers.MachinePools = restored.Spec.Topology.Workers.MachinePools } } - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions + dst.Status.ControlPlane = restored.Status.ControlPlane + dst.Status.Workers = restored.Status.Workers return nil } @@ -94,6 +110,21 @@ func (dst *Cluster) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha4). + dst.Status.Conditions = nil + + // Retrieve legacy conditions (v1alpha4), failureReason and failureMessage from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason + dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage + } + } + // Preserve Hub data on down-conversion except for metadata if err := utilconversion.MarshalData(src, dst); err != nil { return err @@ -165,6 +196,17 @@ func (src *Machine) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha4), failureReason and failureMessage to the deprecated field. + if src.Status.Conditions != nil || src.Status.FailureReason != nil || src.Status.FailureMessage != nil { + dst.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason + dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage + } + // Manually restore data. restored := &clusterv1.Machine{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -176,7 +218,7 @@ func (src *Machine) ConvertTo(dstRaw conversion.Hub) error { dst.Status.CertificatesExpiryDate = restored.Status.CertificatesExpiryDate dst.Spec.NodeVolumeDetachTimeout = restored.Spec.NodeVolumeDetachTimeout dst.Status.Deletion = restored.Status.Deletion - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions return nil } @@ -188,6 +230,21 @@ func (dst *Machine) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha4). + dst.Status.Conditions = nil + + // Retrieve legacy conditions (v1alpha4), failureReason and failureMessage from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason + dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage + } + } + // Preserve Hub data on down-conversion except for metadata if err := utilconversion.MarshalData(src, dst); err != nil { return err @@ -203,6 +260,18 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha4), failureReason, failureMessage and replica counters to the deprecated field. + dst.Status.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason + dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage + dst.Status.Deprecated.V1Beta1.ReadyReplicas = src.Status.ReadyReplicas + dst.Status.Deprecated.V1Beta1.AvailableReplicas = src.Status.AvailableReplicas + dst.Status.Deprecated.V1Beta1.FullyLabeledReplicas = src.Status.FullyLabeledReplicas + // Manually restore data. restored := &clusterv1.MachineSet{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -212,7 +281,10 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Template.Spec.ReadinessGates = restored.Spec.Template.Spec.ReadinessGates dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions + dst.Status.AvailableReplicas = restored.Status.AvailableReplicas + dst.Status.ReadyReplicas = restored.Status.ReadyReplicas + dst.Status.UpToDateReplicas = restored.Status.UpToDateReplicas if restored.Spec.MachineNamingStrategy != nil { dst.Spec.MachineNamingStrategy = restored.Spec.MachineNamingStrategy @@ -228,6 +300,29 @@ func (dst *MachineSet) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha4). + dst.Status.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. + dst.Status.AvailableReplicas = 0 + dst.Status.ReadyReplicas = 0 + + // Retrieve legacy conditions (v1alpha4), failureReason, failureMessage and replica counters from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason + dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage + dst.Status.ReadyReplicas = src.Status.Deprecated.V1Beta1.ReadyReplicas + dst.Status.AvailableReplicas = src.Status.Deprecated.V1Beta1.AvailableReplicas + dst.Status.FullyLabeledReplicas = src.Status.Deprecated.V1Beta1.FullyLabeledReplicas + } + } + // Preserve Hub data on down-conversion except for metadata return utilconversion.MarshalData(src, dst) } @@ -239,6 +334,17 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha4) and replica counters to the deprecated field. + dst.Status.Deprecated = &clusterv1.MachineDeploymentDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + dst.Status.Deprecated.V1Beta1.ReadyReplicas = src.Status.ReadyReplicas + dst.Status.Deprecated.V1Beta1.AvailableReplicas = src.Status.AvailableReplicas + dst.Status.Deprecated.V1Beta1.UpdatedReplicas = src.Status.UpdatedReplicas + dst.Status.Deprecated.V1Beta1.UnavailableReplicas = src.Status.UnavailableReplicas + // Manually restore data. restored := &clusterv1.MachineDeployment{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -260,8 +366,10 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error { if restored.Spec.MachineNamingStrategy != nil { dst.Spec.MachineNamingStrategy = restored.Spec.MachineNamingStrategy } - - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions + dst.Status.AvailableReplicas = restored.Status.AvailableReplicas + dst.Status.ReadyReplicas = restored.Status.ReadyReplicas + dst.Status.UpToDateReplicas = restored.Status.UpToDateReplicas return nil } @@ -273,6 +381,28 @@ func (dst *MachineDeployment) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha4). + dst.Status.Conditions = nil + + // Reset replica counters from autogenerated conversions + // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. + dst.Status.AvailableReplicas = 0 + dst.Status.ReadyReplicas = 0 + + // Retrieve legacy conditions (v1alpha4), failureReason, failureMessage and replica counters from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + dst.Status.ReadyReplicas = src.Status.Deprecated.V1Beta1.ReadyReplicas + dst.Status.AvailableReplicas = src.Status.Deprecated.V1Beta1.AvailableReplicas + dst.Status.UpdatedReplicas = src.Status.Deprecated.V1Beta1.UpdatedReplicas + dst.Status.UnavailableReplicas = src.Status.Deprecated.V1Beta1.UnavailableReplicas + } + } + // Preserve Hub data on down-conversion except for metadata return utilconversion.MarshalData(src, dst) } @@ -284,12 +414,21 @@ func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error { return err } + // Move legacy conditions (v1alpha4) to the deprecated field. + if src.Status.Conditions != nil { + dst.Status.Deprecated = &clusterv1.MachineHealthCheckDeprecatedStatus{} + dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{} + if src.Status.Conditions != nil { + Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + } + } + // Manually restore data. restored := &clusterv1.MachineHealthCheck{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { return err } - dst.Status.V1Beta2 = restored.Status.V1Beta2 + dst.Status.Conditions = restored.Status.Conditions return nil } @@ -301,106 +440,171 @@ func (dst *MachineHealthCheck) ConvertFrom(srcRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha4). + dst.Status.Conditions = nil + + // Retrieve legacy conditions (v1alpha4) from the deprecated field. + if src.Status.Deprecated != nil { + if src.Status.Deprecated.V1Beta1 != nil { + if src.Status.Deprecated.V1Beta1.Conditions != nil { + Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + } + } + } + // Preserve Hub data on down-conversion except for metadata return utilconversion.MarshalData(src, dst) } -func Convert_v1alpha4_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, out *clusterv1.MachineStatus, s apiconversion.Scope) error { +func Convert_v1alpha4_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, out *clusterv1.MachineStatus, s apimachineryconversion.Scope) error { // Status.version has been removed in v1beta1, thus requiring custom conversion function. the information will be dropped. return autoConvert_v1alpha4_MachineStatus_To_v1beta2_MachineStatus(in, out, s) + + // v1beta1 conditions, failureReason, failureMessage moved to deprecated. + if in.Conditions == nil && in.FailureReason == nil && in.FailureMessage == nil { + return nil + } + if out.Deprecated == nil { + out.Deprecated = &clusterv1.MachineDeprecatedStatus{} + } + if out.Deprecated.V1Beta1 == nil { + out.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + } + + out.Deprecated.V1Beta1.Conditions = *(*clusterv1.Conditions)(unsafe.Pointer(&in.Conditions)) + out.Deprecated.V1Beta1.FailureReason = in.FailureReason + out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage + return nil } -func Convert_v1beta2_ClusterClassSpec_To_v1alpha4_ClusterClassSpec(in *clusterv1.ClusterClassSpec, out *ClusterClassSpec, s apiconversion.Scope) error { +func Convert_v1beta2_ClusterClassSpec_To_v1alpha4_ClusterClassSpec(in *clusterv1.ClusterClassSpec, out *ClusterClassSpec, s apimachineryconversion.Scope) error { // spec.{variables,patches} has been added with v1beta1. return autoConvert_v1beta2_ClusterClassSpec_To_v1alpha4_ClusterClassSpec(in, out, s) } -func Convert_v1beta2_MachineSpec_To_v1alpha4_MachineSpec(in *clusterv1.MachineSpec, out *MachineSpec, s apiconversion.Scope) error { +func Convert_v1beta2_MachineSpec_To_v1alpha4_MachineSpec(in *clusterv1.MachineSpec, out *MachineSpec, s apimachineryconversion.Scope) error { // spec.nodeDeletionTimeout was added in v1beta1. // ReadinessGates was added in v1beta1. return autoConvert_v1beta2_MachineSpec_To_v1alpha4_MachineSpec(in, out, s) } -func Convert_v1beta2_MachineDeploymentSpec_To_v1alpha4_MachineDeploymentSpec(in *clusterv1.MachineDeploymentSpec, out *MachineDeploymentSpec, s apiconversion.Scope) error { +func Convert_v1beta2_MachineDeploymentSpec_To_v1alpha4_MachineDeploymentSpec(in *clusterv1.MachineDeploymentSpec, out *MachineDeploymentSpec, s apimachineryconversion.Scope) error { return autoConvert_v1beta2_MachineDeploymentSpec_To_v1alpha4_MachineDeploymentSpec(in, out, s) } -func Convert_v1beta2_ClusterSpec_To_v1alpha4_ClusterSpec(in *clusterv1.ClusterSpec, out *ClusterSpec, s apiconversion.Scope) error { +func Convert_v1beta2_ClusterSpec_To_v1alpha4_ClusterSpec(in *clusterv1.ClusterSpec, out *ClusterSpec, s apimachineryconversion.Scope) error { // AvailabilityGates was added in v1beta1. return autoConvert_v1beta2_ClusterSpec_To_v1alpha4_ClusterSpec(in, out, s) } -func Convert_v1beta2_ClusterStatus_To_v1alpha4_ClusterStatus(in *clusterv1.ClusterStatus, out *ClusterStatus, s apiconversion.Scope) error { +func Convert_v1beta2_ClusterStatus_To_v1alpha4_ClusterStatus(in *clusterv1.ClusterStatus, out *ClusterStatus, s apimachineryconversion.Scope) error { // V1Beta2 was added in v1beta1. return autoConvert_v1beta2_ClusterStatus_To_v1alpha4_ClusterStatus(in, out, s) } -func Convert_v1beta2_Topology_To_v1alpha4_Topology(in *clusterv1.Topology, out *Topology, s apiconversion.Scope) error { +func Convert_v1beta2_Topology_To_v1alpha4_Topology(in *clusterv1.Topology, out *Topology, s apimachineryconversion.Scope) error { // spec.topology.variables has been added with v1beta1. return autoConvert_v1beta2_Topology_To_v1alpha4_Topology(in, out, s) } // Convert_v1beta2_MachineDeploymentTopology_To_v1alpha4_MachineDeploymentTopology is an autogenerated conversion function. -func Convert_v1beta2_MachineDeploymentTopology_To_v1alpha4_MachineDeploymentTopology(in *clusterv1.MachineDeploymentTopology, out *MachineDeploymentTopology, s apiconversion.Scope) error { +func Convert_v1beta2_MachineDeploymentTopology_To_v1alpha4_MachineDeploymentTopology(in *clusterv1.MachineDeploymentTopology, out *MachineDeploymentTopology, s apimachineryconversion.Scope) error { // MachineDeploymentTopology.FailureDomain has been added with v1beta1. return autoConvert_v1beta2_MachineDeploymentTopology_To_v1alpha4_MachineDeploymentTopology(in, out, s) } -func Convert_v1beta2_MachineDeploymentClass_To_v1alpha4_MachineDeploymentClass(in *clusterv1.MachineDeploymentClass, out *MachineDeploymentClass, s apiconversion.Scope) error { +func Convert_v1beta2_MachineDeploymentClass_To_v1alpha4_MachineDeploymentClass(in *clusterv1.MachineDeploymentClass, out *MachineDeploymentClass, s apimachineryconversion.Scope) error { // machineDeploymentClass.machineHealthCheck has been added with v1beta1. return autoConvert_v1beta2_MachineDeploymentClass_To_v1alpha4_MachineDeploymentClass(in, out, s) } -func Convert_v1beta2_ControlPlaneClass_To_v1alpha4_ControlPlaneClass(in *clusterv1.ControlPlaneClass, out *ControlPlaneClass, s apiconversion.Scope) error { +func Convert_v1beta2_ControlPlaneClass_To_v1alpha4_ControlPlaneClass(in *clusterv1.ControlPlaneClass, out *ControlPlaneClass, s apimachineryconversion.Scope) error { // controlPlaneClass.machineHealthCheck has been added with v1beta1. return autoConvert_v1beta2_ControlPlaneClass_To_v1alpha4_ControlPlaneClass(in, out, s) } -func Convert_v1beta2_ControlPlaneTopology_To_v1alpha4_ControlPlaneTopology(in *clusterv1.ControlPlaneTopology, out *ControlPlaneTopology, s apiconversion.Scope) error { +func Convert_v1beta2_ControlPlaneTopology_To_v1alpha4_ControlPlaneTopology(in *clusterv1.ControlPlaneTopology, out *ControlPlaneTopology, s apimachineryconversion.Scope) error { // controlPlaneTopology.nodeDrainTimeout has been added with v1beta1. return autoConvert_v1beta2_ControlPlaneTopology_To_v1alpha4_ControlPlaneTopology(in, out, s) } -func Convert_v1beta2_MachineStatus_To_v1alpha4_MachineStatus(in *clusterv1.MachineStatus, out *MachineStatus, s apiconversion.Scope) error { +func Convert_v1beta2_MachineStatus_To_v1alpha4_MachineStatus(in *clusterv1.MachineStatus, out *MachineStatus, s apimachineryconversion.Scope) error { // MachineStatus.CertificatesExpiryDate has been added in v1beta1. // V1Beta2 was added in v1beta1. return autoConvert_v1beta2_MachineStatus_To_v1alpha4_MachineStatus(in, out, s) } -func Convert_v1beta2_ClusterClass_To_v1alpha4_ClusterClass(in *clusterv1.ClusterClass, out *ClusterClass, s apiconversion.Scope) error { +func Convert_v1beta2_ClusterClass_To_v1alpha4_ClusterClass(in *clusterv1.ClusterClass, out *ClusterClass, s apimachineryconversion.Scope) error { // ClusterClass.Status has been added in v1beta1. return autoConvert_v1beta2_ClusterClass_To_v1alpha4_ClusterClass(in, out, s) } -func Convert_v1beta2_WorkersClass_To_v1alpha4_WorkersClass(in *clusterv1.WorkersClass, out *WorkersClass, s apiconversion.Scope) error { +func Convert_v1beta2_WorkersClass_To_v1alpha4_WorkersClass(in *clusterv1.WorkersClass, out *WorkersClass, s apimachineryconversion.Scope) error { // WorkersClass.MachinePools has been added in v1beta1. return autoConvert_v1beta2_WorkersClass_To_v1alpha4_WorkersClass(in, out, s) } -func Convert_v1beta2_WorkersTopology_To_v1alpha4_WorkersTopology(in *clusterv1.WorkersTopology, out *WorkersTopology, s apiconversion.Scope) error { +func Convert_v1beta2_WorkersTopology_To_v1alpha4_WorkersTopology(in *clusterv1.WorkersTopology, out *WorkersTopology, s apimachineryconversion.Scope) error { // WorkersTopology.MachinePools has been added in v1beta1. return autoConvert_v1beta2_WorkersTopology_To_v1alpha4_WorkersTopology(in, out, s) } -func Convert_v1beta2_MachineDeploymentStrategy_To_v1alpha4_MachineDeploymentStrategy(in *clusterv1.MachineDeploymentStrategy, out *MachineDeploymentStrategy, s apiconversion.Scope) error { +func Convert_v1beta2_MachineDeploymentStrategy_To_v1alpha4_MachineDeploymentStrategy(in *clusterv1.MachineDeploymentStrategy, out *MachineDeploymentStrategy, s apimachineryconversion.Scope) error { return autoConvert_v1beta2_MachineDeploymentStrategy_To_v1alpha4_MachineDeploymentStrategy(in, out, s) } -func Convert_v1beta2_MachineSetSpec_To_v1alpha4_MachineSetSpec(in *clusterv1.MachineSetSpec, out *MachineSetSpec, s apiconversion.Scope) error { +func Convert_v1beta2_MachineSetSpec_To_v1alpha4_MachineSetSpec(in *clusterv1.MachineSetSpec, out *MachineSetSpec, s apimachineryconversion.Scope) error { return autoConvert_v1beta2_MachineSetSpec_To_v1alpha4_MachineSetSpec(in, out, s) } -func Convert_v1beta2_MachineDeploymentStatus_To_v1alpha4_MachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, out *MachineDeploymentStatus, s apiconversion.Scope) error { +func Convert_v1beta2_MachineDeploymentStatus_To_v1alpha4_MachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, out *MachineDeploymentStatus, s apimachineryconversion.Scope) error { // V1Beta2 was added in v1beta1. return autoConvert_v1beta2_MachineDeploymentStatus_To_v1alpha4_MachineDeploymentStatus(in, out, s) } -func Convert_v1beta2_MachineSetStatus_To_v1alpha4_MachineSetStatus(in *clusterv1.MachineSetStatus, out *MachineSetStatus, s apiconversion.Scope) error { +func Convert_v1beta2_MachineSetStatus_To_v1alpha4_MachineSetStatus(in *clusterv1.MachineSetStatus, out *MachineSetStatus, s apimachineryconversion.Scope) error { // V1Beta2 was added in v1beta1. return autoConvert_v1beta2_MachineSetStatus_To_v1alpha4_MachineSetStatus(in, out, s) } -func Convert_v1beta2_MachineHealthCheckStatus_To_v1alpha4_MachineHealthCheckStatus(in *clusterv1.MachineHealthCheckStatus, out *MachineHealthCheckStatus, s apiconversion.Scope) error { +func Convert_v1beta2_MachineHealthCheckStatus_To_v1alpha4_MachineHealthCheckStatus(in *clusterv1.MachineHealthCheckStatus, out *MachineHealthCheckStatus, s apimachineryconversion.Scope) error { // V1Beta2 was added in v1beta1. return autoConvert_v1beta2_MachineHealthCheckStatus_To_v1alpha4_MachineHealthCheckStatus(in, out, s) } + +func Convert_v1alpha4_ClusterStatus_To_v1beta2_ClusterStatus(in *ClusterStatus, out *clusterv1.ClusterStatus, s apimachineryconversion.Scope) error { + return autoConvert_v1alpha4_ClusterStatus_To_v1beta2_ClusterStatus(in, out, s) +} + +func Convert_v1alpha4_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(in *MachineDeploymentStatus, out *clusterv1.MachineDeploymentStatus, s apimachineryconversion.Scope) error { + return autoConvert_v1alpha4_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(in, out, s) +} + +func Convert_v1alpha4_MachineSetStatus_To_v1beta2_MachineSetStatus(in *MachineSetStatus, out *clusterv1.MachineSetStatus, s apimachineryconversion.Scope) error { + return autoConvert_v1alpha4_MachineSetStatus_To_v1beta2_MachineSetStatus(in, out, s) +} + +func Convert_v1_Condition_To_v1alpha4_Condition(_ *metav1.Condition, _ *Condition, _ apimachineryconversion.Scope) error { + // NOTE: v1beta2 conditions should not be automatically converted into legacy (v1alpha4) conditions. + return nil +} + +func Convert_v1alpha4_Condition_To_v1_Condition(_ *Condition, _ *metav1.Condition, _ apimachineryconversion.Scope) error { + // NOTE: legacy (v1alpha4) conditions should not be automatically converted into v1beta2 conditions. + return nil +} + +func Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(in *clusterv1.Conditions, out *Conditions) { + *out = make(Conditions, len(*in)) + for i := range *in { + (*out)[i] = *(*Condition)(unsafe.Pointer(&(*in)[i])) + } +} + +func Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(in *Conditions, out *clusterv1.Conditions) { + *out = make(clusterv1.Conditions, len(*in)) + for i := range *in { + (*out)[i] = *(*clusterv1.Condition)(unsafe.Pointer(&(*in)[i])) + } +} diff --git a/internal/apis/core/v1alpha4/conversion_test.go b/internal/apis/core/v1alpha4/conversion_test.go index e68812c19ab7..39854b8e112c 100644 --- a/internal/apis/core/v1alpha4/conversion_test.go +++ b/internal/apis/core/v1alpha4/conversion_test.go @@ -38,45 +38,53 @@ func TestFuzzyConversion(t *testing.T) { t.Run("for Cluster", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.Cluster{}, Spoke: &Cluster{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{ClusterJSONFuzzFuncs}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{ClusterFuzzFuncs}, })) t.Run("for ClusterClass", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.ClusterClass{}, Spoke: &ClusterClass{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{ClusterClassJSONFuzzFuncs}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{ClusterClassFuzzFuncs}, })) - t.Run("for Machine", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.Machine{}, Spoke: &Machine{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineStatusFuzzFunc}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineFuzzFunc}, })) - t.Run("for MachineSet", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.MachineSet{}, Spoke: &MachineSet{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineSetFuzzFuncs}, })) - t.Run("for MachineDeployment", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ Hub: &clusterv1.MachineDeployment{}, Spoke: &MachineDeployment{}, - FuzzerFuncs: []fuzzer.FuzzerFuncs{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineDeploymentFuzzFuncs}, })) - t.Run("for MachineHealthCheck", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{ - Hub: &clusterv1.MachineHealthCheck{}, - Spoke: &MachineHealthCheck{}, + Hub: &clusterv1.MachineHealthCheck{}, + Spoke: &MachineHealthCheck{}, + FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineHealthCheckFuzzFunc}, })) } -func MachineStatusFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { +func MachineFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - MachineStatusFuzzer, + hubMachineStatus, + spokeMachineStatus, } } -func MachineStatusFuzzer(in *MachineStatus, c fuzz.Continue) { +func hubMachineStatus(in *clusterv1.MachineStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + in.Deprecated = nil + } + } +} + +func spokeMachineStatus(in *MachineStatus, c fuzz.Continue) { c.FuzzNoCustom(in) // These fields have been removed in v1beta1 @@ -84,34 +92,45 @@ func MachineStatusFuzzer(in *MachineStatus, c fuzz.Continue) { in.Version = nil } -func ClusterJSONFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { +func ClusterFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - ClusterVariableFuzzer, + hubClusterVariable, + hubClusterStatus, } } -func ClusterVariableFuzzer(in *clusterv1.ClusterVariable, c fuzz.Continue) { +func hubClusterStatus(in *clusterv1.ClusterStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + in.Deprecated = nil + } + } +} + +func hubClusterVariable(in *clusterv1.ClusterVariable, c fuzz.Continue) { c.FuzzNoCustom(in) // Not every random byte array is valid JSON, e.g. a string without `""`,so we're setting a valid value. in.Value = apiextensionsv1.JSON{Raw: []byte("\"test-string\"")} } -func ClusterClassJSONFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { +func ClusterClassFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { return []interface{}{ - JSONPatchFuzzer, - JSONSchemaPropsFuzzer, + hubJSONPatch, + hubJSONSchemaProps, } } -func JSONPatchFuzzer(in *clusterv1.JSONPatch, c fuzz.Continue) { +func hubJSONPatch(in *clusterv1.JSONPatch, c fuzz.Continue) { c.FuzzNoCustom(in) // Not every random byte array is valid JSON, e.g. a string without `""`,so we're setting a valid value. in.Value = &apiextensionsv1.JSON{Raw: []byte("5")} } -func JSONSchemaPropsFuzzer(in *clusterv1.JSONSchemaProps, c fuzz.Continue) { +func hubJSONSchemaProps(in *clusterv1.JSONSchemaProps, c fuzz.Continue) { // NOTE: We have to fuzz the individual fields manually, // because we cannot call `FuzzNoCustom` as it would lead // to an infinite recursion. @@ -153,3 +172,53 @@ func JSONSchemaPropsFuzzer(in *clusterv1.JSONSchemaProps, c fuzz.Continue) { } in.Items = in2 } + +func MachineSetFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubMachineSetStatus, + } +} + +func hubMachineSetStatus(in *clusterv1.MachineSetStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} + } +} + +func MachineDeploymentFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubMachineDeploymentStatus, + } +} + +func hubMachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, c fuzz.Continue) { + c.Fuzz(in) + // Always create struct with at least one mandatory fields. + if in.Deprecated == nil { + in.Deprecated = &clusterv1.MachineDeploymentDeprecatedStatus{} + } + if in.Deprecated.V1Beta1 == nil { + in.Deprecated.V1Beta1 = &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{} + } +} + +func MachineHealthCheckFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { + return []interface{}{ + hubMachineHealthCheckStatus, + } +} + +func hubMachineHealthCheckStatus(in *clusterv1.MachineHealthCheckStatus, c fuzz.Continue) { + c.Fuzz(in) + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + in.Deprecated = nil + } + } +} diff --git a/internal/apis/core/v1alpha4/zz_generated.conversion.go b/internal/apis/core/v1alpha4/zz_generated.conversion.go index 4e0a7cdee2f0..8816ca925e9a 100644 --- a/internal/apis/core/v1alpha4/zz_generated.conversion.go +++ b/internal/apis/core/v1alpha4/zz_generated.conversion.go @@ -24,13 +24,12 @@ package v1alpha4 import ( unsafe "unsafe" - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + corev1 "k8s.io/api/core/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" intstr "k8s.io/apimachinery/pkg/util/intstr" v1beta2 "sigs.k8s.io/cluster-api/api/v1beta2" - errors "sigs.k8s.io/cluster-api/errors" ) func init() { @@ -115,11 +114,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*ClusterStatus)(nil), (*v1beta2.ClusterStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha4_ClusterStatus_To_v1beta2_ClusterStatus(a.(*ClusterStatus), b.(*v1beta2.ClusterStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*Condition)(nil), (*v1beta2.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_Condition_To_v1beta2_Condition(a.(*Condition), b.(*v1beta2.Condition), scope) }); err != nil { @@ -220,11 +214,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachineDeploymentStatus)(nil), (*v1beta2.MachineDeploymentStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha4_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(a.(*MachineDeploymentStatus), b.(*v1beta2.MachineDeploymentStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*MachineDeploymentStrategy)(nil), (*v1beta2.MachineDeploymentStrategy)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_MachineDeploymentStrategy_To_v1beta2_MachineDeploymentStrategy(a.(*MachineDeploymentStrategy), b.(*v1beta2.MachineDeploymentStrategy), scope) }); err != nil { @@ -315,11 +304,6 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddGeneratedConversionFunc((*MachineSetStatus)(nil), (*v1beta2.MachineSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha4_MachineSetStatus_To_v1beta2_MachineSetStatus(a.(*MachineSetStatus), b.(*v1beta2.MachineSetStatus), scope) - }); err != nil { - return err - } if err := s.AddGeneratedConversionFunc((*MachineSpec)(nil), (*v1beta2.MachineSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_MachineSpec_To_v1beta2_MachineSpec(a.(*MachineSpec), b.(*v1beta2.MachineSpec), scope) }); err != nil { @@ -380,6 +364,31 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*v1.Condition)(nil), (*Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_Condition_To_v1alpha4_Condition(a.(*v1.Condition), b.(*Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*ClusterStatus)(nil), (*v1beta2.ClusterStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_ClusterStatus_To_v1beta2_ClusterStatus(a.(*ClusterStatus), b.(*v1beta2.ClusterStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*Condition)(nil), (*v1.Condition)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_Condition_To_v1_Condition(a.(*Condition), b.(*v1.Condition), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*MachineDeploymentStatus)(nil), (*v1beta2.MachineDeploymentStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(a.(*MachineDeploymentStatus), b.(*v1beta2.MachineDeploymentStatus), scope) + }); err != nil { + return err + } + if err := s.AddConversionFunc((*MachineSetStatus)(nil), (*v1beta2.MachineSetStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_MachineSetStatus_To_v1beta2_MachineSetStatus(a.(*MachineSetStatus), b.(*v1beta2.MachineSetStatus), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*MachineStatus)(nil), (*v1beta2.MachineStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha4_MachineStatus_To_v1beta2_MachineStatus(a.(*MachineStatus), b.(*v1beta2.MachineStatus), scope) }); err != nil { @@ -506,7 +515,7 @@ func Convert_v1beta2_APIEndpoint_To_v1alpha4_APIEndpoint(in *v1beta2.APIEndpoint } func autoConvert_v1alpha4_Bootstrap_To_v1beta2_Bootstrap(in *Bootstrap, out *v1beta2.Bootstrap, s conversion.Scope) error { - out.ConfigRef = (*v1.ObjectReference)(unsafe.Pointer(in.ConfigRef)) + out.ConfigRef = (*corev1.ObjectReference)(unsafe.Pointer(in.ConfigRef)) out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) return nil } @@ -517,7 +526,7 @@ func Convert_v1alpha4_Bootstrap_To_v1beta2_Bootstrap(in *Bootstrap, out *v1beta2 } func autoConvert_v1beta2_Bootstrap_To_v1alpha4_Bootstrap(in *v1beta2.Bootstrap, out *Bootstrap, s conversion.Scope) error { - out.ConfigRef = (*v1.ObjectReference)(unsafe.Pointer(in.ConfigRef)) + out.ConfigRef = (*corev1.ObjectReference)(unsafe.Pointer(in.ConfigRef)) out.DataSecretName = (*string)(unsafe.Pointer(in.DataSecretName)) return nil } @@ -732,8 +741,8 @@ func autoConvert_v1alpha4_ClusterSpec_To_v1beta2_ClusterSpec(in *ClusterSpec, ou if err := Convert_v1alpha4_APIEndpoint_To_v1beta2_APIEndpoint(&in.ControlPlaneEndpoint, &out.ControlPlaneEndpoint, s); err != nil { return err } - out.ControlPlaneRef = (*v1.ObjectReference)(unsafe.Pointer(in.ControlPlaneRef)) - out.InfrastructureRef = (*v1.ObjectReference)(unsafe.Pointer(in.InfrastructureRef)) + out.ControlPlaneRef = (*corev1.ObjectReference)(unsafe.Pointer(in.ControlPlaneRef)) + out.InfrastructureRef = (*corev1.ObjectReference)(unsafe.Pointer(in.InfrastructureRef)) if in.Topology != nil { in, out := &in.Topology, &out.Topology *out = new(v1beta2.Topology) @@ -757,8 +766,8 @@ func autoConvert_v1beta2_ClusterSpec_To_v1alpha4_ClusterSpec(in *v1beta2.Cluster if err := Convert_v1beta2_APIEndpoint_To_v1alpha4_APIEndpoint(&in.ControlPlaneEndpoint, &out.ControlPlaneEndpoint, s); err != nil { return err } - out.ControlPlaneRef = (*v1.ObjectReference)(unsafe.Pointer(in.ControlPlaneRef)) - out.InfrastructureRef = (*v1.ObjectReference)(unsafe.Pointer(in.InfrastructureRef)) + out.ControlPlaneRef = (*corev1.ObjectReference)(unsafe.Pointer(in.ControlPlaneRef)) + out.InfrastructureRef = (*corev1.ObjectReference)(unsafe.Pointer(in.InfrastructureRef)) if in.Topology != nil { in, out := &in.Topology, &out.Topology *out = new(Topology) @@ -774,37 +783,52 @@ func autoConvert_v1beta2_ClusterSpec_To_v1alpha4_ClusterSpec(in *v1beta2.Cluster func autoConvert_v1alpha4_ClusterStatus_To_v1beta2_ClusterStatus(in *ClusterStatus, out *v1beta2.ClusterStatus, s conversion.Scope) error { out.FailureDomains = *(*v1beta2.FailureDomains)(unsafe.Pointer(&in.FailureDomains)) - out.FailureReason = (*errors.ClusterStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.Phase = in.Phase out.InfrastructureReady = in.InfrastructureReady out.ControlPlaneReady = in.ControlPlaneReady - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha4_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.ObservedGeneration = in.ObservedGeneration return nil } -// Convert_v1alpha4_ClusterStatus_To_v1beta2_ClusterStatus is an autogenerated conversion function. -func Convert_v1alpha4_ClusterStatus_To_v1beta2_ClusterStatus(in *ClusterStatus, out *v1beta2.ClusterStatus, s conversion.Scope) error { - return autoConvert_v1alpha4_ClusterStatus_To_v1beta2_ClusterStatus(in, out, s) -} - func autoConvert_v1beta2_ClusterStatus_To_v1alpha4_ClusterStatus(in *v1beta2.ClusterStatus, out *ClusterStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha4_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + // WARNING: in.ControlPlane requires manual conversion: does not exist in peer-type + // WARNING: in.Workers requires manual conversion: does not exist in peer-type out.FailureDomains = *(*FailureDomains)(unsafe.Pointer(&in.FailureDomains)) - out.FailureReason = (*errors.ClusterStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) out.Phase = in.Phase out.InfrastructureReady = in.InfrastructureReady out.ControlPlaneReady = in.ControlPlaneReady - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) out.ObservedGeneration = in.ObservedGeneration - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } func autoConvert_v1alpha4_Condition_To_v1beta2_Condition(in *Condition, out *v1beta2.Condition, s conversion.Scope) error { out.Type = v1beta2.ConditionType(in.Type) - out.Status = v1.ConditionStatus(in.Status) + out.Status = corev1.ConditionStatus(in.Status) out.Severity = v1beta2.ConditionSeverity(in.Severity) out.LastTransitionTime = in.LastTransitionTime out.Reason = in.Reason @@ -819,7 +843,7 @@ func Convert_v1alpha4_Condition_To_v1beta2_Condition(in *Condition, out *v1beta2 func autoConvert_v1beta2_Condition_To_v1alpha4_Condition(in *v1beta2.Condition, out *Condition, s conversion.Scope) error { out.Type = ConditionType(in.Type) - out.Status = v1.ConditionStatus(in.Status) + out.Status = corev1.ConditionStatus(in.Status) out.Severity = ConditionSeverity(in.Severity) out.LastTransitionTime = in.LastTransitionTime out.Reason = in.Reason @@ -915,7 +939,7 @@ func Convert_v1beta2_FailureDomainSpec_To_v1alpha4_FailureDomainSpec(in *v1beta2 } func autoConvert_v1alpha4_LocalObjectTemplate_To_v1beta2_LocalObjectTemplate(in *LocalObjectTemplate, out *v1beta2.LocalObjectTemplate, s conversion.Scope) error { - out.Ref = (*v1.ObjectReference)(unsafe.Pointer(in.Ref)) + out.Ref = (*corev1.ObjectReference)(unsafe.Pointer(in.Ref)) return nil } @@ -925,7 +949,7 @@ func Convert_v1alpha4_LocalObjectTemplate_To_v1beta2_LocalObjectTemplate(in *Loc } func autoConvert_v1beta2_LocalObjectTemplate_To_v1alpha4_LocalObjectTemplate(in *v1beta2.LocalObjectTemplate, out *LocalObjectTemplate, s conversion.Scope) error { - out.Ref = (*v1.ObjectReference)(unsafe.Pointer(in.Ref)) + out.Ref = (*corev1.ObjectReference)(unsafe.Pointer(in.Ref)) return nil } @@ -1185,31 +1209,53 @@ func autoConvert_v1alpha4_MachineDeploymentStatus_To_v1beta2_MachineDeploymentSt out.ObservedGeneration = in.ObservedGeneration out.Selector = in.Selector out.Replicas = in.Replicas - out.UpdatedReplicas = in.UpdatedReplicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas - out.UnavailableReplicas = in.UnavailableReplicas + // WARNING: in.UpdatedReplicas requires manual conversion: does not exist in peer-type + if err := v1.Convert_int32_To_Pointer_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_int32_To_Pointer_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UnavailableReplicas requires manual conversion: does not exist in peer-type out.Phase = in.Phase - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha4_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } -// Convert_v1alpha4_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus is an autogenerated conversion function. -func Convert_v1alpha4_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(in *MachineDeploymentStatus, out *v1beta2.MachineDeploymentStatus, s conversion.Scope) error { - return autoConvert_v1alpha4_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus(in, out, s) -} - func autoConvert_v1beta2_MachineDeploymentStatus_To_v1alpha4_MachineDeploymentStatus(in *v1beta2.MachineDeploymentStatus, out *MachineDeploymentStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha4_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.ObservedGeneration = in.ObservedGeneration out.Selector = in.Selector out.Replicas = in.Replicas - out.UpdatedReplicas = in.UpdatedReplicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas - out.UnavailableReplicas = in.UnavailableReplicas + if err := v1.Convert_Pointer_int32_To_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int32_To_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UpToDateReplicas requires manual conversion: does not exist in peer-type out.Phase = in.Phase - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } @@ -1345,8 +1391,8 @@ func autoConvert_v1alpha4_MachineHealthCheckSpec_To_v1beta2_MachineHealthCheckSp out.UnhealthyConditions = *(*[]v1beta2.UnhealthyCondition)(unsafe.Pointer(&in.UnhealthyConditions)) out.MaxUnhealthy = (*intstr.IntOrString)(unsafe.Pointer(in.MaxUnhealthy)) out.UnhealthyRange = (*string)(unsafe.Pointer(in.UnhealthyRange)) - out.NodeStartupTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) - out.RemediationTemplate = (*v1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) + out.NodeStartupTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) + out.RemediationTemplate = (*corev1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) return nil } @@ -1361,8 +1407,8 @@ func autoConvert_v1beta2_MachineHealthCheckSpec_To_v1alpha4_MachineHealthCheckSp out.UnhealthyConditions = *(*[]UnhealthyCondition)(unsafe.Pointer(&in.UnhealthyConditions)) out.MaxUnhealthy = (*intstr.IntOrString)(unsafe.Pointer(in.MaxUnhealthy)) out.UnhealthyRange = (*string)(unsafe.Pointer(in.UnhealthyRange)) - out.NodeStartupTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) - out.RemediationTemplate = (*v1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) + out.NodeStartupTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeStartupTimeout)) + out.RemediationTemplate = (*corev1.ObjectReference)(unsafe.Pointer(in.RemediationTemplate)) return nil } @@ -1377,7 +1423,17 @@ func autoConvert_v1alpha4_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheck out.RemediationsAllowed = in.RemediationsAllowed out.ObservedGeneration = in.ObservedGeneration out.Targets = *(*[]string)(unsafe.Pointer(&in.Targets)) - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha4_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } @@ -1387,13 +1443,23 @@ func Convert_v1alpha4_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheckStat } func autoConvert_v1beta2_MachineHealthCheckStatus_To_v1alpha4_MachineHealthCheckStatus(in *v1beta2.MachineHealthCheckStatus, out *MachineHealthCheckStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha4_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.ExpectedMachines = in.ExpectedMachines out.CurrentHealthy = in.CurrentHealthy out.RemediationsAllowed = in.RemediationsAllowed out.ObservedGeneration = in.ObservedGeneration out.Targets = *(*[]string)(unsafe.Pointer(&in.Targets)) - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } @@ -1570,32 +1636,53 @@ func autoConvert_v1beta2_MachineSetSpec_To_v1alpha4_MachineSetSpec(in *v1beta2.M func autoConvert_v1alpha4_MachineSetStatus_To_v1beta2_MachineSetStatus(in *MachineSetStatus, out *v1beta2.MachineSetStatus, s conversion.Scope) error { out.Selector = in.Selector out.Replicas = in.Replicas - out.FullyLabeledReplicas = in.FullyLabeledReplicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas + // WARNING: in.FullyLabeledReplicas requires manual conversion: does not exist in peer-type + if err := v1.Convert_int32_To_Pointer_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_int32_To_Pointer_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } out.ObservedGeneration = in.ObservedGeneration - out.FailureReason = (*errors.MachineSetStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha4_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } -// Convert_v1alpha4_MachineSetStatus_To_v1beta2_MachineSetStatus is an autogenerated conversion function. -func Convert_v1alpha4_MachineSetStatus_To_v1beta2_MachineSetStatus(in *MachineSetStatus, out *v1beta2.MachineSetStatus, s conversion.Scope) error { - return autoConvert_v1alpha4_MachineSetStatus_To_v1beta2_MachineSetStatus(in, out, s) -} - func autoConvert_v1beta2_MachineSetStatus_To_v1alpha4_MachineSetStatus(in *v1beta2.MachineSetStatus, out *MachineSetStatus, s conversion.Scope) error { + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha4_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } out.Selector = in.Selector out.Replicas = in.Replicas - out.FullyLabeledReplicas = in.FullyLabeledReplicas - out.ReadyReplicas = in.ReadyReplicas - out.AvailableReplicas = in.AvailableReplicas + if err := v1.Convert_Pointer_int32_To_int32(&in.ReadyReplicas, &out.ReadyReplicas, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int32_To_int32(&in.AvailableReplicas, &out.AvailableReplicas, s); err != nil { + return err + } + // WARNING: in.UpToDateReplicas requires manual conversion: does not exist in peer-type out.ObservedGeneration = in.ObservedGeneration - out.FailureReason = (*errors.MachineSetStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } @@ -1608,7 +1695,7 @@ func autoConvert_v1alpha4_MachineSpec_To_v1beta2_MachineSpec(in *MachineSpec, ou out.Version = (*string)(unsafe.Pointer(in.Version)) out.ProviderID = (*string)(unsafe.Pointer(in.ProviderID)) out.FailureDomain = (*string)(unsafe.Pointer(in.FailureDomain)) - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) return nil } @@ -1627,43 +1714,61 @@ func autoConvert_v1beta2_MachineSpec_To_v1alpha4_MachineSpec(in *v1beta2.Machine out.ProviderID = (*string)(unsafe.Pointer(in.ProviderID)) out.FailureDomain = (*string)(unsafe.Pointer(in.FailureDomain)) // WARNING: in.ReadinessGates requires manual conversion: does not exist in peer-type - out.NodeDrainTimeout = (*metav1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) + out.NodeDrainTimeout = (*v1.Duration)(unsafe.Pointer(in.NodeDrainTimeout)) // WARNING: in.NodeVolumeDetachTimeout requires manual conversion: does not exist in peer-type // WARNING: in.NodeDeletionTimeout requires manual conversion: does not exist in peer-type return nil } func autoConvert_v1alpha4_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, out *v1beta2.MachineStatus, s conversion.Scope) error { - out.NodeRef = (*v1.ObjectReference)(unsafe.Pointer(in.NodeRef)) - out.NodeInfo = (*v1.NodeSystemInfo)(unsafe.Pointer(in.NodeInfo)) - out.LastUpdated = (*metav1.Time)(unsafe.Pointer(in.LastUpdated)) + out.NodeRef = (*corev1.ObjectReference)(unsafe.Pointer(in.NodeRef)) + out.NodeInfo = (*corev1.NodeSystemInfo)(unsafe.Pointer(in.NodeInfo)) + out.LastUpdated = (*v1.Time)(unsafe.Pointer(in.LastUpdated)) // WARNING: in.Version requires manual conversion: does not exist in peer-type - out.FailureReason = (*errors.MachineStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + // WARNING: in.FailureReason requires manual conversion: does not exist in peer-type + // WARNING: in.FailureMessage requires manual conversion: does not exist in peer-type out.Addresses = *(*v1beta2.MachineAddresses)(unsafe.Pointer(&in.Addresses)) out.Phase = in.Phase out.BootstrapReady = in.BootstrapReady out.InfrastructureReady = in.InfrastructureReady out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*v1beta2.Conditions)(unsafe.Pointer(&in.Conditions)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + if err := Convert_v1alpha4_Condition_To_v1_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } return nil } func autoConvert_v1beta2_MachineStatus_To_v1alpha4_MachineStatus(in *v1beta2.MachineStatus, out *MachineStatus, s conversion.Scope) error { - out.NodeRef = (*v1.ObjectReference)(unsafe.Pointer(in.NodeRef)) - out.NodeInfo = (*v1.NodeSystemInfo)(unsafe.Pointer(in.NodeInfo)) - out.LastUpdated = (*metav1.Time)(unsafe.Pointer(in.LastUpdated)) - out.FailureReason = (*errors.MachineStatusError)(unsafe.Pointer(in.FailureReason)) - out.FailureMessage = (*string)(unsafe.Pointer(in.FailureMessage)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + if err := Convert_v1_Condition_To_v1alpha4_Condition(&(*in)[i], &(*out)[i], s); err != nil { + return err + } + } + } else { + out.Conditions = nil + } + out.NodeRef = (*corev1.ObjectReference)(unsafe.Pointer(in.NodeRef)) + out.NodeInfo = (*corev1.NodeSystemInfo)(unsafe.Pointer(in.NodeInfo)) + out.LastUpdated = (*v1.Time)(unsafe.Pointer(in.LastUpdated)) out.Addresses = *(*MachineAddresses)(unsafe.Pointer(&in.Addresses)) out.Phase = in.Phase // WARNING: in.CertificatesExpiryDate requires manual conversion: does not exist in peer-type out.BootstrapReady = in.BootstrapReady out.InfrastructureReady = in.InfrastructureReady out.ObservedGeneration = in.ObservedGeneration - out.Conditions = *(*Conditions)(unsafe.Pointer(&in.Conditions)) // WARNING: in.Deletion requires manual conversion: does not exist in peer-type - // WARNING: in.V1Beta2 requires manual conversion: does not exist in peer-type + // WARNING: in.Deprecated requires manual conversion: does not exist in peer-type return nil } @@ -1742,7 +1847,7 @@ func Convert_v1beta2_ObjectMeta_To_v1alpha4_ObjectMeta(in *v1beta2.ObjectMeta, o func autoConvert_v1alpha4_Topology_To_v1beta2_Topology(in *Topology, out *v1beta2.Topology, s conversion.Scope) error { out.Class = in.Class out.Version = in.Version - out.RolloutAfter = (*metav1.Time)(unsafe.Pointer(in.RolloutAfter)) + out.RolloutAfter = (*v1.Time)(unsafe.Pointer(in.RolloutAfter)) if err := Convert_v1alpha4_ControlPlaneTopology_To_v1beta2_ControlPlaneTopology(&in.ControlPlane, &out.ControlPlane, s); err != nil { return err } @@ -1767,7 +1872,7 @@ func autoConvert_v1beta2_Topology_To_v1alpha4_Topology(in *v1beta2.Topology, out out.Class = in.Class // WARNING: in.ClassNamespace requires manual conversion: does not exist in peer-type out.Version = in.Version - out.RolloutAfter = (*metav1.Time)(unsafe.Pointer(in.RolloutAfter)) + out.RolloutAfter = (*v1.Time)(unsafe.Pointer(in.RolloutAfter)) if err := Convert_v1beta2_ControlPlaneTopology_To_v1alpha4_ControlPlaneTopology(&in.ControlPlane, &out.ControlPlane, s); err != nil { return err } @@ -1785,8 +1890,8 @@ func autoConvert_v1beta2_Topology_To_v1alpha4_Topology(in *v1beta2.Topology, out } func autoConvert_v1alpha4_UnhealthyCondition_To_v1beta2_UnhealthyCondition(in *UnhealthyCondition, out *v1beta2.UnhealthyCondition, s conversion.Scope) error { - out.Type = v1.NodeConditionType(in.Type) - out.Status = v1.ConditionStatus(in.Status) + out.Type = corev1.NodeConditionType(in.Type) + out.Status = corev1.ConditionStatus(in.Status) out.Timeout = in.Timeout return nil } @@ -1797,8 +1902,8 @@ func Convert_v1alpha4_UnhealthyCondition_To_v1beta2_UnhealthyCondition(in *Unhea } func autoConvert_v1beta2_UnhealthyCondition_To_v1alpha4_UnhealthyCondition(in *v1beta2.UnhealthyCondition, out *UnhealthyCondition, s conversion.Scope) error { - out.Type = v1.NodeConditionType(in.Type) - out.Status = v1.ConditionStatus(in.Status) + out.Type = corev1.NodeConditionType(in.Type) + out.Status = corev1.ConditionStatus(in.Status) out.Timeout = in.Timeout return nil } From a189190747b688e083882802b206ed6fa89b2215 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Mon, 7 Apr 2025 15:03:54 +0200 Subject: [PATCH 03/11] Run generators --- api/v1beta1/zz_generated.openapi.go | 16 +- api/v1beta2/zz_generated.openapi.go | 840 ++++++++++-------- ...strap.cluster.x-k8s.io_kubeadmconfigs.yaml | 228 ++--- ....cluster.x-k8s.io_clusterresourcesets.yaml | 196 ++-- .../cluster.x-k8s.io_clusterclasses.yaml | 196 ++-- .../crd/bases/cluster.x-k8s.io_clusters.yaml | 368 ++++---- .../cluster.x-k8s.io_machinedeployments.yaml | 280 +++--- .../cluster.x-k8s.io_machinehealthchecks.yaml | 196 ++-- .../bases/cluster.x-k8s.io_machinepools.yaml | 292 +++--- .../crd/bases/cluster.x-k8s.io_machines.yaml | 286 +++--- .../bases/cluster.x-k8s.io_machinesets.yaml | 323 +++---- ...ipam.cluster.x-k8s.io_ipaddressclaims.yaml | 190 ++-- ...cluster.x-k8s.io_kubeadmcontrolplanes.yaml | 308 ++++--- 13 files changed, 1977 insertions(+), 1742 deletions(-) diff --git a/api/v1beta1/zz_generated.openapi.go b/api/v1beta1/zz_generated.openapi.go index 7793d65eb87e..cd5dbf15c3e5 100644 --- a/api/v1beta1/zz_generated.openapi.go +++ b/api/v1beta1/zz_generated.openapi.go @@ -1028,14 +1028,14 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_ClusterStatus(ref common.Reference }, "failureReason": { SchemaProps: spec.SchemaProps{ - Description: "failureReason indicates that there is a fatal problem reconciling the state, and will be set to a token value suitable for programmatic interpretation.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", + Description: "failureReason indicates that there is a fatal problem reconciling the state, and will be set to a token value suitable for programmatic interpretation.\n\nDeprecated: This field 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.", Type: []string{"string"}, Format: "", }, }, "failureMessage": { SchemaProps: spec.SchemaProps{ - Description: "failureMessage indicates that there is a fatal problem reconciling the state, and will be set to a descriptive error message.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", + Description: "failureMessage indicates that there is a fatal problem reconciling the state, and will be set to a descriptive error message.\n\nDeprecated: This field 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.", Type: []string{"string"}, Format: "", }, @@ -2458,7 +2458,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_MachineDeploymentStatus(ref common }, "unavailableReplicas": { SchemaProps: spec.SchemaProps{ - Description: "unavailableReplicas is the total number of unavailable machines targeted by this deployment. This is the total number of machines that are still required for the deployment to have 100% available capacity. They may either be machines that are running but not yet available or machines that still have not been created.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", + Description: "unavailableReplicas is the total number of unavailable machines targeted by this deployment. This is the total number of machines that are still required for the deployment to have 100% available capacity. They may either be machines that are running but not yet available or machines that still have not been created.\n\nDeprecated: This field 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.", Default: 0, Type: []string{"integer"}, Format: "int32", @@ -3976,7 +3976,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_MachineSetStatus(ref common.Refere }, "fullyLabeledReplicas": { SchemaProps: spec.SchemaProps{ - Description: "fullyLabeledReplicas is the number of replicas that have labels matching the labels of the machine template of the MachineSet.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", + Description: "fullyLabeledReplicas is the number of replicas that have labels matching the labels of the machine template of the MachineSet.\n\nDeprecated: This field 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.", Default: 0, Type: []string{"integer"}, Format: "int32", @@ -4007,14 +4007,14 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_MachineSetStatus(ref common.Refere }, "failureReason": { SchemaProps: spec.SchemaProps{ - Description: "failureReason will be set in the event that there is a terminal problem reconciling the Machine and will contain a succinct value suitable for machine interpretation.\n\nIn the event that there is a terminal problem reconciling the replicas, both FailureReason and FailureMessage will be set. FailureReason will be populated with a succinct value suitable for machine interpretation, while FailureMessage will contain a more verbose string suitable for logging and human consumption.\n\nThese fields should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the MachineTemplate's spec or the configuration of the machine controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the machine controller, or the responsible machine controller itself being critically misconfigured.\n\nAny transient errors that occur during the reconciliation of Machines can be added as events to the MachineSet object and/or logged in the controller's output.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", + Description: "failureReason will be set in the event that there is a terminal problem reconciling the Machine and will contain a succinct value suitable for machine interpretation.\n\nIn the event that there is a terminal problem reconciling the replicas, both FailureReason and FailureMessage will be set. FailureReason will be populated with a succinct value suitable for machine interpretation, while FailureMessage will contain a more verbose string suitable for logging and human consumption.\n\nThese fields should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the MachineTemplate's spec or the configuration of the machine controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the machine controller, or the responsible machine controller itself being critically misconfigured.\n\nAny transient errors that occur during the reconciliation of Machines can be added as events to the MachineSet object and/or logged in the controller's output.\n\nDeprecated: This field 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.", Type: []string{"string"}, Format: "", }, }, "failureMessage": { SchemaProps: spec.SchemaProps{ - Description: "failureMessage will be set in the event that there is a terminal problem reconciling the Machine and will contain a more verbose string suitable for logging and human consumption.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", + Description: "failureMessage will be set in the event that there is a terminal problem reconciling the Machine and will contain a more verbose string suitable for logging and human consumption.\n\nDeprecated: This field 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.", Type: []string{"string"}, Format: "", }, @@ -4231,14 +4231,14 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_MachineStatus(ref common.Reference }, "failureReason": { SchemaProps: spec.SchemaProps{ - Description: "failureReason will be set in the event that there is a terminal problem reconciling the Machine and will contain a succinct value suitable for machine interpretation.\n\nThis field should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the Machine's spec or the configuration of the controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the controller, or the responsible controller itself being critically misconfigured.\n\nAny transient errors that occur during the reconciliation of Machines can be added as events to the Machine object and/or logged in the controller's output.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", + Description: "failureReason will be set in the event that there is a terminal problem reconciling the Machine and will contain a succinct value suitable for machine interpretation.\n\nThis field should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the Machine's spec or the configuration of the controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the controller, or the responsible controller itself being critically misconfigured.\n\nAny transient errors that occur during the reconciliation of Machines can be added as events to the Machine object and/or logged in the controller's output.\n\nDeprecated: This field 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.", Type: []string{"string"}, Format: "", }, }, "failureMessage": { SchemaProps: spec.SchemaProps{ - Description: "failureMessage will be set in the event that there is a terminal problem reconciling the Machine and will contain a more verbose string suitable for logging and human consumption.\n\nThis field should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the Machine's spec or the configuration of the controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the controller, or the responsible controller itself being critically misconfigured.\n\nAny transient errors that occur during the reconciliation of Machines can be added as events to the Machine object and/or logged in the controller's output.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", + Description: "failureMessage will be set in the event that there is a terminal problem reconciling the Machine and will contain a more verbose string suitable for logging and human consumption.\n\nThis field should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the Machine's spec or the configuration of the controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the controller, or the responsible controller itself being critically misconfigured.\n\nAny transient errors that occur during the reconciliation of Machines can be added as events to the Machine object and/or logged in the controller's output.\n\nDeprecated: This field 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.", Type: []string{"string"}, Format: "", }, diff --git a/api/v1beta2/zz_generated.openapi.go b/api/v1beta2/zz_generated.openapi.go index 378c5868c3aa..970ea956ca75 100644 --- a/api/v1beta2/zz_generated.openapi.go +++ b/api/v1beta2/zz_generated.openapi.go @@ -28,100 +28,106 @@ import ( func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { return map[string]common.OpenAPIDefinition{ - "sigs.k8s.io/cluster-api/api/v1beta2.APIEndpoint": schema_sigsk8sio_cluster_api_api_v1beta2_APIEndpoint(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.Bootstrap": schema_sigsk8sio_cluster_api_api_v1beta2_Bootstrap(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.Cluster": schema_sigsk8sio_cluster_api_api_v1beta2_Cluster(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterAvailabilityGate": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterAvailabilityGate(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClass": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClass(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassList": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassList(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassPatch": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassPatch(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassSpec": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassSpec(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassStatus": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassStatus(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassStatusVariable": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassStatusVariable(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassStatusVariableDefinition": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassStatusVariableDefinition(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassV1Beta2Status": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassV1Beta2Status(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassVariable": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassVariable(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassVariableMetadata": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassVariableMetadata(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterControlPlaneStatus": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterControlPlaneStatus(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterList": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterList(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterNetwork": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterNetwork(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterSpec": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterSpec(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterStatus": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterStatus(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterV1Beta2Status": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterV1Beta2Status(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterVariable": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterVariable(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.Condition": schema_sigsk8sio_cluster_api_api_v1beta2_Condition(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ControlPlaneClass": schema_sigsk8sio_cluster_api_api_v1beta2_ControlPlaneClass(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ControlPlaneClassNamingStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_ControlPlaneClassNamingStrategy(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ControlPlaneTopology": schema_sigsk8sio_cluster_api_api_v1beta2_ControlPlaneTopology(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ControlPlaneVariables": schema_sigsk8sio_cluster_api_api_v1beta2_ControlPlaneVariables(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ExternalPatchDefinition": schema_sigsk8sio_cluster_api_api_v1beta2_ExternalPatchDefinition(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.FailureDomainSpec": schema_sigsk8sio_cluster_api_api_v1beta2_FailureDomainSpec(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.InfrastructureNamingStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_InfrastructureNamingStrategy(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.JSONPatch": schema_sigsk8sio_cluster_api_api_v1beta2_JSONPatch(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.JSONPatchValue": schema_sigsk8sio_cluster_api_api_v1beta2_JSONPatchValue(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.JSONSchemaProps": schema_sigsk8sio_cluster_api_api_v1beta2_JSONSchemaProps(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.LocalObjectTemplate": schema_sigsk8sio_cluster_api_api_v1beta2_LocalObjectTemplate(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.Machine": schema_sigsk8sio_cluster_api_api_v1beta2_Machine(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineAddress": schema_sigsk8sio_cluster_api_api_v1beta2_MachineAddress(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeletionStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeletionStatus(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeployment": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeployment(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentClass": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentClass(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentClassNamingStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentClassNamingStrategy(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentClassTemplate": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentClassTemplate(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentList": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentList(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentSpec": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentSpec(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentStatus(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentStrategy(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentTopology": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentTopology(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentV1Beta2Status": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentV1Beta2Status(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentVariables": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentVariables(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDrainRule": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRule(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDrainRuleDrainConfig": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRuleDrainConfig(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDrainRuleList": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRuleList(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDrainRuleMachineSelector": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRuleMachineSelector(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDrainRulePodSelector": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRulePodSelector(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineDrainRuleSpec": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRuleSpec(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheck": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheck(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckClass": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckClass(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckList": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckList(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckSpec": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckSpec(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckStatus(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckTopology": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckTopology(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckV1Beta2Status": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckV1Beta2Status(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineList": schema_sigsk8sio_cluster_api_api_v1beta2_MachineList(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineNamingStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_MachineNamingStrategy(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachinePoolClass": schema_sigsk8sio_cluster_api_api_v1beta2_MachinePoolClass(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachinePoolClassNamingStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_MachinePoolClassNamingStrategy(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachinePoolClassTemplate": schema_sigsk8sio_cluster_api_api_v1beta2_MachinePoolClassTemplate(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachinePoolTopology": schema_sigsk8sio_cluster_api_api_v1beta2_MachinePoolTopology(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachinePoolVariables": schema_sigsk8sio_cluster_api_api_v1beta2_MachinePoolVariables(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineReadinessGate": schema_sigsk8sio_cluster_api_api_v1beta2_MachineReadinessGate(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineRollingUpdateDeployment": schema_sigsk8sio_cluster_api_api_v1beta2_MachineRollingUpdateDeployment(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineSet": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSet(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineSetList": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetList(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineSetSpec": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetSpec(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineSetStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetStatus(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineSetV1Beta2Status": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetV1Beta2Status(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineSpec": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSpec(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineStatus(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineTemplateSpec": schema_sigsk8sio_cluster_api_api_v1beta2_MachineTemplateSpec(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.MachineV1Beta2Status": schema_sigsk8sio_cluster_api_api_v1beta2_MachineV1Beta2Status(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.NetworkRanges": schema_sigsk8sio_cluster_api_api_v1beta2_NetworkRanges(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ObjectMeta": schema_sigsk8sio_cluster_api_api_v1beta2_ObjectMeta(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.PatchDefinition": schema_sigsk8sio_cluster_api_api_v1beta2_PatchDefinition(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.PatchSelector": schema_sigsk8sio_cluster_api_api_v1beta2_PatchSelector(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.PatchSelectorMatch": schema_sigsk8sio_cluster_api_api_v1beta2_PatchSelectorMatch(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.PatchSelectorMatchMachineDeploymentClass": schema_sigsk8sio_cluster_api_api_v1beta2_PatchSelectorMatchMachineDeploymentClass(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.PatchSelectorMatchMachinePoolClass": schema_sigsk8sio_cluster_api_api_v1beta2_PatchSelectorMatchMachinePoolClass(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.RemediationStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_RemediationStrategy(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.Topology": schema_sigsk8sio_cluster_api_api_v1beta2_Topology(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.UnhealthyCondition": schema_sigsk8sio_cluster_api_api_v1beta2_UnhealthyCondition(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.ValidationRule": schema_sigsk8sio_cluster_api_api_v1beta2_ValidationRule(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.VariableSchema": schema_sigsk8sio_cluster_api_api_v1beta2_VariableSchema(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.VariableSchemaMetadata": schema_sigsk8sio_cluster_api_api_v1beta2_VariableSchemaMetadata(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.WorkersClass": schema_sigsk8sio_cluster_api_api_v1beta2_WorkersClass(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.WorkersStatus": schema_sigsk8sio_cluster_api_api_v1beta2_WorkersStatus(ref), - "sigs.k8s.io/cluster-api/api/v1beta2.WorkersTopology": schema_sigsk8sio_cluster_api_api_v1beta2_WorkersTopology(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.APIEndpoint": schema_sigsk8sio_cluster_api_api_v1beta2_APIEndpoint(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.Bootstrap": schema_sigsk8sio_cluster_api_api_v1beta2_Bootstrap(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.Cluster": schema_sigsk8sio_cluster_api_api_v1beta2_Cluster(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterAvailabilityGate": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterAvailabilityGate(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClass": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClass(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassDeprecatedStatus": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassDeprecatedStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassList": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassList(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassPatch": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassPatch(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassSpec": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassSpec(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassStatus": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassStatusVariable": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassStatusVariable(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassStatusVariableDefinition": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassStatusVariableDefinition(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassV1Beta1DeprecatedStatus": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassV1Beta1DeprecatedStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassVariable": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassVariable(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassVariableMetadata": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassVariableMetadata(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterControlPlaneStatus": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterControlPlaneStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterDeprecatedStatus": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterDeprecatedStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterList": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterList(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterNetwork": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterNetwork(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterSpec": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterSpec(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterStatus": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterV1Beta1DeprecatedStatus": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterV1Beta1DeprecatedStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterVariable": schema_sigsk8sio_cluster_api_api_v1beta2_ClusterVariable(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.Condition": schema_sigsk8sio_cluster_api_api_v1beta2_Condition(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ControlPlaneClass": schema_sigsk8sio_cluster_api_api_v1beta2_ControlPlaneClass(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ControlPlaneClassNamingStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_ControlPlaneClassNamingStrategy(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ControlPlaneTopology": schema_sigsk8sio_cluster_api_api_v1beta2_ControlPlaneTopology(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ControlPlaneVariables": schema_sigsk8sio_cluster_api_api_v1beta2_ControlPlaneVariables(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ExternalPatchDefinition": schema_sigsk8sio_cluster_api_api_v1beta2_ExternalPatchDefinition(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.FailureDomainSpec": schema_sigsk8sio_cluster_api_api_v1beta2_FailureDomainSpec(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.InfrastructureNamingStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_InfrastructureNamingStrategy(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.JSONPatch": schema_sigsk8sio_cluster_api_api_v1beta2_JSONPatch(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.JSONPatchValue": schema_sigsk8sio_cluster_api_api_v1beta2_JSONPatchValue(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.JSONSchemaProps": schema_sigsk8sio_cluster_api_api_v1beta2_JSONSchemaProps(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.LocalObjectTemplate": schema_sigsk8sio_cluster_api_api_v1beta2_LocalObjectTemplate(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.Machine": schema_sigsk8sio_cluster_api_api_v1beta2_Machine(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineAddress": schema_sigsk8sio_cluster_api_api_v1beta2_MachineAddress(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeletionStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeletionStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeployment": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeployment(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentClass": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentClass(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentClassNamingStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentClassNamingStrategy(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentClassTemplate": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentClassTemplate(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentDeprecatedStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentDeprecatedStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentList": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentList(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentSpec": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentSpec(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentStrategy(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentTopology": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentTopology(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentV1Beta1DeprecatedStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentV1Beta1DeprecatedStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentVariables": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentVariables(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeprecatedStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeprecatedStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDrainRule": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRule(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDrainRuleDrainConfig": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRuleDrainConfig(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDrainRuleList": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRuleList(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDrainRuleMachineSelector": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRuleMachineSelector(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDrainRulePodSelector": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRulePodSelector(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDrainRuleSpec": schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRuleSpec(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheck": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheck(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckClass": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckClass(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckDeprecatedStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckDeprecatedStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckList": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckList(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckSpec": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckSpec(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckTopology": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckTopology(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckV1Beta1DeprecatedStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckV1Beta1DeprecatedStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineList": schema_sigsk8sio_cluster_api_api_v1beta2_MachineList(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineNamingStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_MachineNamingStrategy(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachinePoolClass": schema_sigsk8sio_cluster_api_api_v1beta2_MachinePoolClass(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachinePoolClassNamingStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_MachinePoolClassNamingStrategy(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachinePoolClassTemplate": schema_sigsk8sio_cluster_api_api_v1beta2_MachinePoolClassTemplate(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachinePoolTopology": schema_sigsk8sio_cluster_api_api_v1beta2_MachinePoolTopology(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachinePoolVariables": schema_sigsk8sio_cluster_api_api_v1beta2_MachinePoolVariables(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineReadinessGate": schema_sigsk8sio_cluster_api_api_v1beta2_MachineReadinessGate(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineRollingUpdateDeployment": schema_sigsk8sio_cluster_api_api_v1beta2_MachineRollingUpdateDeployment(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineSet": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSet(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineSetDeprecatedStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetDeprecatedStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineSetList": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetList(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineSetSpec": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetSpec(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineSetStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineSetV1Beta1DeprecatedStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetV1Beta1DeprecatedStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineSpec": schema_sigsk8sio_cluster_api_api_v1beta2_MachineSpec(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineTemplateSpec": schema_sigsk8sio_cluster_api_api_v1beta2_MachineTemplateSpec(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.MachineV1Beta1DeprecatedStatus": schema_sigsk8sio_cluster_api_api_v1beta2_MachineV1Beta1DeprecatedStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.NetworkRanges": schema_sigsk8sio_cluster_api_api_v1beta2_NetworkRanges(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ObjectMeta": schema_sigsk8sio_cluster_api_api_v1beta2_ObjectMeta(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.PatchDefinition": schema_sigsk8sio_cluster_api_api_v1beta2_PatchDefinition(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.PatchSelector": schema_sigsk8sio_cluster_api_api_v1beta2_PatchSelector(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.PatchSelectorMatch": schema_sigsk8sio_cluster_api_api_v1beta2_PatchSelectorMatch(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.PatchSelectorMatchMachineDeploymentClass": schema_sigsk8sio_cluster_api_api_v1beta2_PatchSelectorMatchMachineDeploymentClass(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.PatchSelectorMatchMachinePoolClass": schema_sigsk8sio_cluster_api_api_v1beta2_PatchSelectorMatchMachinePoolClass(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.RemediationStrategy": schema_sigsk8sio_cluster_api_api_v1beta2_RemediationStrategy(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.Topology": schema_sigsk8sio_cluster_api_api_v1beta2_Topology(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.UnhealthyCondition": schema_sigsk8sio_cluster_api_api_v1beta2_UnhealthyCondition(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.ValidationRule": schema_sigsk8sio_cluster_api_api_v1beta2_ValidationRule(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.VariableSchema": schema_sigsk8sio_cluster_api_api_v1beta2_VariableSchema(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.VariableSchemaMetadata": schema_sigsk8sio_cluster_api_api_v1beta2_VariableSchemaMetadata(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.WorkersClass": schema_sigsk8sio_cluster_api_api_v1beta2_WorkersClass(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.WorkersStatus": schema_sigsk8sio_cluster_api_api_v1beta2_WorkersStatus(ref), + "sigs.k8s.io/cluster-api/api/v1beta2.WorkersTopology": schema_sigsk8sio_cluster_api_api_v1beta2_WorkersTopology(ref), } } @@ -312,6 +318,27 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClass(ref common.ReferenceC } } +func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassDeprecatedStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ClusterClassDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "v1beta1": { + SchemaProps: spec.SchemaProps{ + Description: "v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassV1Beta1DeprecatedStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassV1Beta1DeprecatedStatus"}, + } +} + func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -520,29 +547,37 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassStatus(ref common.Refe Description: "ClusterClassStatus defines the observed state of the ClusterClass.", Type: []string{"object"}, Properties: map[string]spec.Schema{ - "variables": { + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "type", + }, + "x-kubernetes-list-type": "map", + }, + }, SchemaProps: spec.SchemaProps{ - Description: "variables is a list of ClusterClassStatusVariable that are defined for the ClusterClass.", + Description: "conditions represents the observations of a ClusterClass's current state. Known condition types are VariablesReady, RefVersionsUpToDate, Paused.", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassStatusVariable"), + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), }, }, }, }, }, - "conditions": { + "variables": { SchemaProps: spec.SchemaProps{ - Description: "conditions defines current observed state of the ClusterClass.", + Description: "variables is a list of ClusterClassStatusVariable that are defined for the ClusterClass.", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.Condition"), + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassStatusVariable"), }, }, }, @@ -555,17 +590,17 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassStatus(ref common.Refe Format: "int64", }, }, - "v1beta2": { + "deprecated": { SchemaProps: spec.SchemaProps{ - Description: "v1beta2 groups all the fields that will be added or modified in ClusterClass's status with the V1Beta2 version.", - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassV1Beta2Status"), + Description: "deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassDeprecatedStatus"), }, }, }, }, }, Dependencies: []string{ - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassStatusVariable", "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassV1Beta2Status", "sigs.k8s.io/cluster-api/api/v1beta2.Condition"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassDeprecatedStatus", "sigs.k8s.io/cluster-api/api/v1beta2.ClusterClassStatusVariable"}, } } @@ -661,30 +696,22 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassStatusVariableDefiniti } } -func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassV1Beta2Status(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassV1Beta1DeprecatedStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "ClusterClassV1Beta2Status groups all the fields that will be added or modified in ClusterClass with the V1Beta2 version. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", + Description: "ClusterClassV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "conditions": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-map-keys": []interface{}{ - "type", - }, - "x-kubernetes-list-type": "map", - }, - }, SchemaProps: spec.SchemaProps{ - Description: "conditions represents the observations of a ClusterClass's current state. Known condition types are VariablesReady, RefVersionsUpToDate, Paused.", + Description: "conditions defines current observed state of the ClusterClass.\n\nDeprecated: This field 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.", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.Condition"), }, }, }, @@ -694,7 +721,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterClassV1Beta2Status(ref comm }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/apis/meta/v1.Condition"}, + "sigs.k8s.io/cluster-api/api/v1beta2.Condition"}, } } @@ -837,6 +864,27 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterControlPlaneStatus(ref comm } } +func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterDeprecatedStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ClusterDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "v1beta1": { + SchemaProps: spec.SchemaProps{ + Description: "v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.ClusterV1Beta1DeprecatedStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "sigs.k8s.io/cluster-api/api/v1beta2.ClusterV1Beta1DeprecatedStatus"}, + } +} + func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -1011,33 +1059,53 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterStatus(ref common.Reference Description: "ClusterStatus defines the observed state of Cluster.", Type: []string{"object"}, Properties: map[string]spec.Schema{ - "failureDomains": { + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "type", + }, + "x-kubernetes-list-type": "map", + }, + }, SchemaProps: spec.SchemaProps{ - Description: "failureDomains is a slice of failure domain objects synced from the infrastructure provider.", - Type: []string{"object"}, - AdditionalProperties: &spec.SchemaOrBool{ - Allows: true, + Description: "conditions represents the observations of a Cluster's current state. Known condition types are Available, InfrastructureReady, ControlPlaneInitialized, ControlPlaneAvailable, WorkersAvailable, MachinesReady MachinesUpToDate, RemoteConnectionProbe, ScalingUp, ScalingDown, Remediating, Deleting, Paused. Additionally, a TopologyReconciled condition will be added in case the Cluster is referencing a ClusterClass / defining a managed Topology.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.FailureDomainSpec"), + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), }, }, }, }, }, - "failureReason": { + "controlPlane": { SchemaProps: spec.SchemaProps{ - Description: "failureReason indicates that there is a fatal problem reconciling the state, and will be set to a token value suitable for programmatic interpretation.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", - Type: []string{"string"}, - Format: "", + Description: "controlPlane groups all the observations about Cluster's ControlPlane current state.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.ClusterControlPlaneStatus"), }, }, - "failureMessage": { + "workers": { SchemaProps: spec.SchemaProps{ - Description: "failureMessage indicates that there is a fatal problem reconciling the state, and will be set to a descriptive error message.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", - Type: []string{"string"}, - Format: "", + Description: "workers groups all the observations about Cluster's Workers current state.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.WorkersStatus"), + }, + }, + "failureDomains": { + SchemaProps: spec.SchemaProps{ + Description: "failureDomains is a slice of failure domain objects synced from the infrastructure provider.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.FailureDomainSpec"), + }, + }, + }, }, }, "phase": { @@ -1063,20 +1131,6 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterStatus(ref common.Reference Format: "", }, }, - "conditions": { - SchemaProps: spec.SchemaProps{ - Description: "conditions defines current service state of the cluster.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.Condition"), - }, - }, - }, - }, - }, "observedGeneration": { SchemaProps: spec.SchemaProps{ Description: "observedGeneration is the latest generation observed by the controller.", @@ -1084,66 +1138,60 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterStatus(ref common.Reference Format: "int64", }, }, - "v1beta2": { + "deprecated": { SchemaProps: spec.SchemaProps{ - Description: "v1beta2 groups all the fields that will be added or modified in Cluster's status with the V1Beta2 version.", - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.ClusterV1Beta2Status"), + Description: "deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.ClusterDeprecatedStatus"), }, }, }, }, }, Dependencies: []string{ - "sigs.k8s.io/cluster-api/api/v1beta2.ClusterV1Beta2Status", "sigs.k8s.io/cluster-api/api/v1beta2.Condition", "sigs.k8s.io/cluster-api/api/v1beta2.FailureDomainSpec"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "sigs.k8s.io/cluster-api/api/v1beta2.ClusterControlPlaneStatus", "sigs.k8s.io/cluster-api/api/v1beta2.ClusterDeprecatedStatus", "sigs.k8s.io/cluster-api/api/v1beta2.FailureDomainSpec", "sigs.k8s.io/cluster-api/api/v1beta2.WorkersStatus"}, } } -func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterV1Beta2Status(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_sigsk8sio_cluster_api_api_v1beta2_ClusterV1Beta1DeprecatedStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "ClusterV1Beta2Status groups all the fields that will be added or modified in Cluster with the V1Beta2 version. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", + Description: "ClusterV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "conditions": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-map-keys": []interface{}{ - "type", - }, - "x-kubernetes-list-type": "map", - }, - }, SchemaProps: spec.SchemaProps{ - Description: "conditions represents the observations of a Cluster's current state. Known condition types are Available, InfrastructureReady, ControlPlaneInitialized, ControlPlaneAvailable, WorkersAvailable, MachinesReady MachinesUpToDate, RemoteConnectionProbe, ScalingUp, ScalingDown, Remediating, Deleting, Paused. Additionally, a TopologyReconciled condition will be added in case the Cluster is referencing a ClusterClass / defining a managed Topology.", + Description: "conditions defines current service state of the cluster.\n\nDeprecated: This field 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.", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.Condition"), }, }, }, }, }, - "controlPlane": { + "failureReason": { SchemaProps: spec.SchemaProps{ - Description: "controlPlane groups all the observations about Cluster's ControlPlane current state.", - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.ClusterControlPlaneStatus"), + Description: "failureReason indicates that there is a fatal problem reconciling the state, and will be set to a token value suitable for programmatic interpretation.\n\nDeprecated: This field 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.", + Type: []string{"string"}, + Format: "", }, }, - "workers": { + "failureMessage": { SchemaProps: spec.SchemaProps{ - Description: "workers groups all the observations about Cluster's Workers current state.", - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.WorkersStatus"), + Description: "failureMessage indicates that there is a fatal problem reconciling the state, and will be set to a descriptive error message.\n\nDeprecated: This field 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.", + Type: []string{"string"}, + Format: "", }, }, }, }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "sigs.k8s.io/cluster-api/api/v1beta2.ClusterControlPlaneStatus", "sigs.k8s.io/cluster-api/api/v1beta2.WorkersStatus"}, + "sigs.k8s.io/cluster-api/api/v1beta2.Condition"}, } } @@ -2261,6 +2309,27 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentClassTemplate(ref } } +func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentDeprecatedStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "MachineDeploymentDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "v1beta1": { + SchemaProps: spec.SchemaProps{ + Description: "v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentV1Beta1DeprecatedStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentV1Beta1DeprecatedStatus"}, + } +} + func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -2410,6 +2479,28 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentStatus(ref common Description: "MachineDeploymentStatus defines the observed state of MachineDeployment.", Type: []string{"object"}, Properties: map[string]spec.Schema{ + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "type", + }, + "x-kubernetes-list-type": "map", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "conditions represents the observations of a MachineDeployment's current state. Known condition types are Available, MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + }, + }, + }, + }, + }, "observedGeneration": { SchemaProps: spec.SchemaProps{ Description: "observedGeneration is the generation observed by the deployment controller.", @@ -2432,34 +2523,23 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentStatus(ref common Format: "int32", }, }, - "updatedReplicas": { - SchemaProps: spec.SchemaProps{ - Description: "updatedReplicas is the total number of non-terminated machines targeted by this deployment that have the desired template spec.", - Default: 0, - Type: []string{"integer"}, - Format: "int32", - }, - }, "readyReplicas": { SchemaProps: spec.SchemaProps{ - Description: "readyReplicas is the total number of ready machines targeted by this deployment.", - Default: 0, + Description: "readyReplicas is the number of ready replicas for this MachineDeployment. A machine is considered ready when Machine's Ready condition is true.", Type: []string{"integer"}, Format: "int32", }, }, "availableReplicas": { SchemaProps: spec.SchemaProps{ - Description: "availableReplicas is the total number of available machines (ready for at least minReadySeconds) targeted by this deployment.", - Default: 0, + Description: "availableReplicas is the number of available replicas for this MachineDeployment. A machine is considered available when Machine's Available condition is true.", Type: []string{"integer"}, Format: "int32", }, }, - "unavailableReplicas": { + "upToDateReplicas": { SchemaProps: spec.SchemaProps{ - Description: "unavailableReplicas is the total number of unavailable machines targeted by this deployment. This is the total number of machines that are still required for the deployment to have 100% available capacity. They may either be machines that are running but not yet available or machines that still have not been created.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", - Default: 0, + Description: "upToDateReplicas is the number of up-to-date replicas targeted by this deployment. A machine is considered up-to-date when Machine's UpToDate condition is true.", Type: []string{"integer"}, Format: "int32", }, @@ -2471,31 +2551,17 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentStatus(ref common Format: "", }, }, - "conditions": { + "deprecated": { SchemaProps: spec.SchemaProps{ - Description: "conditions defines current service state of the MachineDeployment.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.Condition"), - }, - }, - }, - }, - }, - "v1beta2": { - SchemaProps: spec.SchemaProps{ - Description: "v1beta2 groups all the fields that will be added or modified in MachineDeployment's status with the V1Beta2 version.", - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentV1Beta2Status"), + Description: "deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentDeprecatedStatus"), }, }, }, }, }, Dependencies: []string{ - "sigs.k8s.io/cluster-api/api/v1beta2.Condition", "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentV1Beta2Status"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeploymentDeprecatedStatus"}, } } @@ -2651,52 +2717,55 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentTopology(ref comm } } -func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentV1Beta2Status(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentV1Beta1DeprecatedStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "MachineDeploymentV1Beta2Status groups all the fields that will be added or modified in MachineDeployment with the V1Beta2 version. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", + Description: "MachineDeploymentV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "conditions": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-map-keys": []interface{}{ - "type", - }, - "x-kubernetes-list-type": "map", - }, - }, SchemaProps: spec.SchemaProps{ - Description: "conditions represents the observations of a MachineDeployment's current state. Known condition types are Available, MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused.", + Description: "conditions defines current service state of the MachineDeployment.\n\nDeprecated: This field 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.", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.Condition"), }, }, }, }, }, + "updatedReplicas": { + SchemaProps: spec.SchemaProps{ + Description: "updatedReplicas is the total number of non-terminated machines targeted by this deployment that have the desired template spec.\n\nDeprecated: This field 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.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, "readyReplicas": { SchemaProps: spec.SchemaProps{ - Description: "readyReplicas is the number of ready replicas for this MachineDeployment. A machine is considered ready when Machine's Ready condition is true.", + Description: "readyReplicas is the total number of ready machines targeted by this deployment.\n\nDeprecated: This field 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.", + Default: 0, Type: []string{"integer"}, Format: "int32", }, }, "availableReplicas": { SchemaProps: spec.SchemaProps{ - Description: "availableReplicas is the number of available replicas for this MachineDeployment. A machine is considered available when Machine's Available condition is true.", + Description: "availableReplicas is the total number of available machines (ready for at least minReadySeconds) targeted by this deployment.\n\nDeprecated: This field 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.", + Default: 0, Type: []string{"integer"}, Format: "int32", }, }, - "upToDateReplicas": { + "unavailableReplicas": { SchemaProps: spec.SchemaProps{ - Description: "upToDateReplicas is the number of up-to-date replicas targeted by this deployment. A machine is considered up-to-date when Machine's UpToDate condition is true.", + Description: "unavailableReplicas is the total number of unavailable machines targeted by this deployment. This is the total number of machines that are still required for the deployment to have 100% available capacity. They may either be machines that are running but not yet available or machines that still have not been created.\n\nDeprecated: This field 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.", + Default: 0, Type: []string{"integer"}, Format: "int32", }, @@ -2705,7 +2774,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentV1Beta2Status(ref }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/apis/meta/v1.Condition"}, + "sigs.k8s.io/cluster-api/api/v1beta2.Condition"}, } } @@ -2746,6 +2815,27 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeploymentVariables(ref com } } +func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDeprecatedStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "MachineDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "v1beta1": { + SchemaProps: spec.SchemaProps{ + Description: "v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.\n\nDeprecated: This field 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.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineV1Beta1DeprecatedStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "sigs.k8s.io/cluster-api/api/v1beta2.MachineV1Beta1DeprecatedStatus"}, + } +} + func schema_sigsk8sio_cluster_api_api_v1beta2_MachineDrainRule(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -3089,6 +3179,27 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckClass(ref common } } +func schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckDeprecatedStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "MachineHealthCheckDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "v1beta1": { + SchemaProps: spec.SchemaProps{ + Description: "v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckV1Beta1DeprecatedStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckV1Beta1DeprecatedStatus"}, + } +} + func schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -3217,6 +3328,28 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckStatus(ref commo Description: "MachineHealthCheckStatus defines the observed state of MachineHealthCheck.", Type: []string{"object"}, Properties: map[string]spec.Schema{ + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "type", + }, + "x-kubernetes-list-type": "map", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "conditions represents the observations of a MachineHealthCheck's current state. Known condition types are RemediationAllowed, Paused.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + }, + }, + }, + }, + }, "expectedMachines": { SchemaProps: spec.SchemaProps{ Description: "expectedMachines is the total number of machines counted by this machine health check", @@ -3263,31 +3396,17 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckStatus(ref commo }, }, }, - "conditions": { - SchemaProps: spec.SchemaProps{ - Description: "conditions defines current service state of the MachineHealthCheck.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.Condition"), - }, - }, - }, - }, - }, - "v1beta2": { + "deprecated": { SchemaProps: spec.SchemaProps{ - Description: "v1beta2 groups all the fields that will be added or modified in MachineHealthCheck's status with the V1Beta2 version.", - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckV1Beta2Status"), + Description: "deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckDeprecatedStatus"), }, }, }, }, }, Dependencies: []string{ - "sigs.k8s.io/cluster-api/api/v1beta2.Condition", "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckV1Beta2Status"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "sigs.k8s.io/cluster-api/api/v1beta2.MachineHealthCheckDeprecatedStatus"}, } } @@ -3352,30 +3471,22 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckTopology(ref com } } -func schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckV1Beta2Status(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckV1Beta1DeprecatedStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "MachineHealthCheckV1Beta2Status groups all the fields that will be added or modified in MachineHealthCheck with the V1Beta2 version. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", + Description: "MachineHealthCheckV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "conditions": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-map-keys": []interface{}{ - "type", - }, - "x-kubernetes-list-type": "map", - }, - }, SchemaProps: spec.SchemaProps{ - Description: "conditions represents the observations of a MachineHealthCheck's current state. Known condition types are RemediationAllowed, Paused.", + Description: "conditions defines current service state of the MachineHealthCheck.\n\nDeprecated: This field 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.", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.Condition"), }, }, }, @@ -3385,7 +3496,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineHealthCheckV1Beta2Status(re }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/apis/meta/v1.Condition"}, + "sigs.k8s.io/cluster-api/api/v1beta2.Condition"}, } } @@ -3836,6 +3947,27 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineSet(ref common.ReferenceCal } } +func schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetDeprecatedStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "MachineSetDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "v1beta1": { + SchemaProps: spec.SchemaProps{ + Description: "v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineSetV1Beta1DeprecatedStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "sigs.k8s.io/cluster-api/api/v1beta2.MachineSetV1Beta1DeprecatedStatus"}, + } +} + func schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -3959,6 +4091,28 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetStatus(ref common.Refere Description: "MachineSetStatus defines the observed state of MachineSet.", Type: []string{"object"}, Properties: map[string]spec.Schema{ + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "type", + }, + "x-kubernetes-list-type": "map", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "conditions represents the observations of a MachineSet's current state. Known condition types are MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + }, + }, + }, + }, + }, "selector": { SchemaProps: spec.SchemaProps{ Description: "selector is the same as the label selector but in the string format to avoid introspection by clients. The string will be in the same format as the query-param syntax. More info about label selectors: http://kubernetes.io/docs/user-guide/labels#label-selectors", @@ -3974,26 +4128,23 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetStatus(ref common.Refere Format: "int32", }, }, - "fullyLabeledReplicas": { + "readyReplicas": { SchemaProps: spec.SchemaProps{ - Description: "fullyLabeledReplicas is the number of replicas that have labels matching the labels of the machine template of the MachineSet.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", - Default: 0, + Description: "readyReplicas is the number of ready replicas for this MachineSet. A machine is considered ready when Machine's Ready condition is true.", Type: []string{"integer"}, Format: "int32", }, }, - "readyReplicas": { + "availableReplicas": { SchemaProps: spec.SchemaProps{ - Description: "readyReplicas is the number of ready replicas for this MachineSet. A machine is considered ready when the node has been created and is \"Ready\".", - Default: 0, + Description: "availableReplicas is the number of available replicas for this MachineSet. A machine is considered available when Machine's Available condition is true.", Type: []string{"integer"}, Format: "int32", }, }, - "availableReplicas": { + "upToDateReplicas": { SchemaProps: spec.SchemaProps{ - Description: "availableReplicas is the number of available replicas (ready for at least minReadySeconds) for this MachineSet.", - Default: 0, + Description: "upToDateReplicas is the number of up-to-date replicas for this MachineSet. A machine is considered up-to-date when Machine's UpToDate condition is true.", Type: []string{"integer"}, Format: "int32", }, @@ -4005,94 +4156,75 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetStatus(ref common.Refere Format: "int64", }, }, - "failureReason": { - SchemaProps: spec.SchemaProps{ - Description: "failureReason will be set in the event that there is a terminal problem reconciling the Machine and will contain a succinct value suitable for machine interpretation.\n\nIn the event that there is a terminal problem reconciling the replicas, both FailureReason and FailureMessage will be set. FailureReason will be populated with a succinct value suitable for machine interpretation, while FailureMessage will contain a more verbose string suitable for logging and human consumption.\n\nThese fields should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the MachineTemplate's spec or the configuration of the machine controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the machine controller, or the responsible machine controller itself being critically misconfigured.\n\nAny transient errors that occur during the reconciliation of Machines can be added as events to the MachineSet object and/or logged in the controller's output.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", - Type: []string{"string"}, - Format: "", - }, - }, - "failureMessage": { - SchemaProps: spec.SchemaProps{ - Description: "failureMessage will be set in the event that there is a terminal problem reconciling the Machine and will contain a more verbose string suitable for logging and human consumption.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", - Type: []string{"string"}, - Format: "", - }, - }, - "conditions": { + "deprecated": { SchemaProps: spec.SchemaProps{ - Description: "conditions defines current service state of the MachineSet.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.Condition"), - }, - }, - }, - }, - }, - "v1beta2": { - SchemaProps: spec.SchemaProps{ - Description: "v1beta2 groups all the fields that will be added or modified in MachineSet's status with the V1Beta2 version.", - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineSetV1Beta2Status"), + Description: "deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineSetDeprecatedStatus"), }, }, }, }, }, Dependencies: []string{ - "sigs.k8s.io/cluster-api/api/v1beta2.Condition", "sigs.k8s.io/cluster-api/api/v1beta2.MachineSetV1Beta2Status"}, + "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "sigs.k8s.io/cluster-api/api/v1beta2.MachineSetDeprecatedStatus"}, } } -func schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetV1Beta2Status(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetV1Beta1DeprecatedStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "MachineSetV1Beta2Status groups all the fields that will be added or modified in MachineSetStatus with the V1Beta2 version. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", + Description: "MachineSetV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "conditions": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-map-keys": []interface{}{ - "type", - }, - "x-kubernetes-list-type": "map", - }, - }, SchemaProps: spec.SchemaProps{ - Description: "conditions represents the observations of a MachineSet's current state. Known condition types are MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused.", + Description: "conditions defines current service state of the MachineSet.\n\nDeprecated: This field 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.", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.Condition"), }, }, }, }, }, - "readyReplicas": { + "failureReason": { SchemaProps: spec.SchemaProps{ - Description: "readyReplicas is the number of ready replicas for this MachineSet. A machine is considered ready when Machine's Ready condition is true.", + Description: "failureReason will be set in the event that there is a terminal problem reconciling the Machine and will contain a succinct value suitable for machine interpretation.\n\nIn the event that there is a terminal problem reconciling the replicas, both FailureReason and FailureMessage will be set. FailureReason will be populated with a succinct value suitable for machine interpretation, while FailureMessage will contain a more verbose string suitable for logging and human consumption.\n\nThese fields should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the MachineTemplate's spec or the configuration of the machine controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the machine controller, or the responsible machine controller itself being critically misconfigured.\n\nAny transient errors that occur during the reconciliation of Machines can be added as events to the MachineSet object and/or logged in the controller's output.\n\nDeprecated: This field 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.", + Type: []string{"string"}, + Format: "", + }, + }, + "failureMessage": { + SchemaProps: spec.SchemaProps{ + Description: "failureMessage will be set in the event that there is a terminal problem reconciling the Machine and will contain a more verbose string suitable for logging and human consumption.\n\nDeprecated: This field 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.", + Type: []string{"string"}, + Format: "", + }, + }, + "fullyLabeledReplicas": { + SchemaProps: spec.SchemaProps{ + Description: "fullyLabeledReplicas is the number of replicas that have labels matching the labels of the machine template of the MachineSet.\n\nDeprecated: This field 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.", + Default: 0, Type: []string{"integer"}, Format: "int32", }, }, - "availableReplicas": { + "readyReplicas": { SchemaProps: spec.SchemaProps{ - Description: "availableReplicas is the number of available replicas for this MachineSet. A machine is considered available when Machine's Available condition is true.", + Description: "readyReplicas is the number of ready replicas for this MachineSet. A machine is considered ready when the node has been created and is \"Ready\".\n\nDeprecated: This field 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.", + Default: 0, Type: []string{"integer"}, Format: "int32", }, }, - "upToDateReplicas": { + "availableReplicas": { SchemaProps: spec.SchemaProps{ - Description: "upToDateReplicas is the number of up-to-date replicas for this MachineSet. A machine is considered up-to-date when Machine's UpToDate condition is true.", + Description: "availableReplicas is the number of available replicas (ready for at least minReadySeconds) for this MachineSet.\n\nDeprecated: This field 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.", + Default: 0, Type: []string{"integer"}, Format: "int32", }, @@ -4101,7 +4233,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineSetV1Beta2Status(ref common }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/apis/meta/v1.Condition"}, + "sigs.k8s.io/cluster-api/api/v1beta2.Condition"}, } } @@ -4211,6 +4343,28 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineStatus(ref common.Reference Description: "MachineStatus defines the observed state of Machine.", Type: []string{"object"}, Properties: map[string]spec.Schema{ + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "type", + }, + "x-kubernetes-list-type": "map", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "conditions represents the observations of a Machine's current state. Known condition types are Available, Ready, UpToDate, BootstrapConfigReady, InfrastructureReady, NodeReady, NodeHealthy, Deleting, Paused. If a MachineHealthCheck is targeting this machine, also HealthCheckSucceeded, OwnerRemediated conditions are added. Additionally control plane Machines controlled by KubeadmControlPlane will have following additional conditions: APIServerPodHealthy, ControllerManagerPodHealthy, SchedulerPodHealthy, EtcdPodHealthy, EtcdMemberHealthy.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + }, + }, + }, + }, + }, "nodeRef": { SchemaProps: spec.SchemaProps{ Description: "nodeRef will point to the corresponding Node if it exists.", @@ -4229,20 +4383,6 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineStatus(ref common.Reference Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), }, }, - "failureReason": { - SchemaProps: spec.SchemaProps{ - Description: "failureReason will be set in the event that there is a terminal problem reconciling the Machine and will contain a succinct value suitable for machine interpretation.\n\nThis field should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the Machine's spec or the configuration of the controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the controller, or the responsible controller itself being critically misconfigured.\n\nAny transient errors that occur during the reconciliation of Machines can be added as events to the Machine object and/or logged in the controller's output.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", - Type: []string{"string"}, - Format: "", - }, - }, - "failureMessage": { - SchemaProps: spec.SchemaProps{ - Description: "failureMessage will be set in the event that there is a terminal problem reconciling the Machine and will contain a more verbose string suitable for logging and human consumption.\n\nThis field should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the Machine's spec or the configuration of the controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the controller, or the responsible controller itself being critically misconfigured.\n\nAny transient errors that occur during the reconciliation of Machines can be added as events to the Machine object and/or logged in the controller's output.\n\nDeprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.", - Type: []string{"string"}, - Format: "", - }, - }, "addresses": { SchemaProps: spec.SchemaProps{ Description: "addresses is a list of addresses assigned to the machine. This field is copied from the infrastructure provider reference.", @@ -4293,37 +4433,23 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineStatus(ref common.Reference Format: "int64", }, }, - "conditions": { - SchemaProps: spec.SchemaProps{ - Description: "conditions defines current service state of the Machine.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.Condition"), - }, - }, - }, - }, - }, "deletion": { SchemaProps: spec.SchemaProps{ Description: "deletion contains information relating to removal of the Machine. Only present when the Machine has a deletionTimestamp and drain or wait for volume detach started.", Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineDeletionStatus"), }, }, - "v1beta2": { + "deprecated": { SchemaProps: spec.SchemaProps{ - Description: "v1beta2 groups all the fields that will be added or modified in Machine's status with the V1Beta2 version.", - Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineV1Beta2Status"), + Description: "deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.", + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.MachineDeprecatedStatus"), }, }, }, }, }, Dependencies: []string{ - "k8s.io/api/core/v1.NodeSystemInfo", "k8s.io/api/core/v1.ObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.Time", "sigs.k8s.io/cluster-api/api/v1beta2.Condition", "sigs.k8s.io/cluster-api/api/v1beta2.MachineAddress", "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeletionStatus", "sigs.k8s.io/cluster-api/api/v1beta2.MachineV1Beta2Status"}, + "k8s.io/api/core/v1.NodeSystemInfo", "k8s.io/api/core/v1.ObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "k8s.io/apimachinery/pkg/apis/meta/v1.Time", "sigs.k8s.io/cluster-api/api/v1beta2.MachineAddress", "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeletionStatus", "sigs.k8s.io/cluster-api/api/v1beta2.MachineDeprecatedStatus"}, } } @@ -4356,40 +4482,46 @@ func schema_sigsk8sio_cluster_api_api_v1beta2_MachineTemplateSpec(ref common.Ref } } -func schema_sigsk8sio_cluster_api_api_v1beta2_MachineV1Beta2Status(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_sigsk8sio_cluster_api_api_v1beta2_MachineV1Beta1DeprecatedStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "MachineV1Beta2Status groups all the fields that will be added or modified in MachineStatus with the V1Beta2 version. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", + Description: "MachineV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "conditions": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-map-keys": []interface{}{ - "type", - }, - "x-kubernetes-list-type": "map", - }, - }, SchemaProps: spec.SchemaProps{ - Description: "conditions represents the observations of a Machine's current state. Known condition types are Available, Ready, UpToDate, BootstrapConfigReady, InfrastructureReady, NodeReady, NodeHealthy, Deleting, Paused. If a MachineHealthCheck is targeting this machine, also HealthCheckSucceeded, OwnerRemediated conditions are added. Additionally control plane Machines controlled by KubeadmControlPlane will have following additional conditions: APIServerPodHealthy, ControllerManagerPodHealthy, SchedulerPodHealthy, EtcdPodHealthy, EtcdMemberHealthy.", + Description: "conditions defines current service state of the Machine.\n\nDeprecated: This field 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.", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Condition"), + Ref: ref("sigs.k8s.io/cluster-api/api/v1beta2.Condition"), }, }, }, }, }, + "failureReason": { + SchemaProps: spec.SchemaProps{ + Description: "failureReason will be set in the event that there is a terminal problem reconciling the Machine and will contain a succinct value suitable for machine interpretation.\n\nThis field should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the Machine's spec or the configuration of the controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the controller, or the responsible controller itself being critically misconfigured.\n\nAny transient errors that occur during the reconciliation of Machines can be added as events to the Machine object and/or logged in the controller's output.\n\nDeprecated: This field 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.", + Type: []string{"string"}, + Format: "", + }, + }, + "failureMessage": { + SchemaProps: spec.SchemaProps{ + Description: "failureMessage will be set in the event that there is a terminal problem reconciling the Machine and will contain a more verbose string suitable for logging and human consumption.\n\nThis field should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the Machine's spec or the configuration of the controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the controller, or the responsible controller itself being critically misconfigured.\n\nAny transient errors that occur during the reconciliation of Machines can be added as events to the Machine object and/or logged in the controller's output.\n\nDeprecated: This field 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.", + Type: []string{"string"}, + Format: "", + }, + }, }, }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/apis/meta/v1.Condition"}, + "sigs.k8s.io/cluster-api/api/v1beta2.Condition"}, } } diff --git a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml index d98ab1b53dbd..6833f6e01b16 100644 --- a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml +++ b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml @@ -3990,7 +3990,7 @@ spec: description: |- failureMessage will be set on non-retryable errors - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. maxLength: 10240 minLength: 1 type: string @@ -3998,7 +3998,7 @@ spec: description: |- failureReason will be set on non-retryable errors - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. maxLength: 256 minLength: 1 type: string @@ -6009,79 +6009,156 @@ spec: description: status is the observed state of KubeadmConfig. properties: conditions: - description: conditions defines current service state of the KubeadmConfig. + description: |- + conditions represents the observations of a KubeadmConfig's current state. + Known condition types are Ready, DataSecretAvailable, CertificatesAvailable. items: - description: Condition defines an observation of a Cluster API resource - operational state. + description: Condition contains details for one aspect of the current + state of this API Resource. properties: lastTransitionTime: description: |- lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when - the API field changed is acceptable. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. format: date-time type: string message: description: |- message is a human readable message indicating details about the transition. - This field may be empty. - maxLength: 10240 - minLength: 1 + This may be an empty string. + maxLength: 32768 type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer reason: description: |- - reason is the reason for the condition's last transition in CamelCase. - The specific API may choose whether or not this field is considered a guaranteed API. - This field may be empty. - maxLength: 256 + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 minLength: 1 - type: string - severity: - description: |- - severity provides an explicit classification of Reason code, so the users or machines can immediately - understand the current situation and act accordingly. - The Severity field MUST be set only when Status=False. - maxLength: 32 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ type: string status: description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown type: string type: - description: |- - type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources like Available, but because arbitrary conditions - can be useful (see .node.status.conditions), the ability to deconflict is important. - maxLength: 256 - minLength: 1 + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ type: string required: - lastTransitionTime + - message + - reason - status - type type: object + maxItems: 32 type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map dataSecretName: description: dataSecretName is the name of the secret that stores the bootstrap data script. maxLength: 253 minLength: 1 type: string - failureMessage: - description: |- - failureMessage will be set on non-retryable errors + deprecated: + description: deprecated groups all the status fields that are deprecated + and will be removed when all the nested field are removed. + properties: + v1beta1: + description: v1beta1 groups all the status fields that are deprecated + and will be removed when support for v1beta1 will be dropped. + properties: + conditions: + description: |- + conditions defines current service state of the KubeadmConfig. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - maxLength: 10240 - minLength: 1 - type: string - failureReason: - description: |- - failureReason will be set on non-retryable errors + Deprecated: This field 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. + items: + description: Condition defines an observation of a Cluster + API resource operational state. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This field may be empty. + maxLength: 10240 + minLength: 1 + type: string + reason: + description: |- + reason is the reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may be empty. + maxLength: 256 + minLength: 1 + type: string + severity: + description: |- + severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + maxLength: 32 + type: string + status: + description: status of the condition, one of True, False, + Unknown. + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + maxLength: 256 + minLength: 1 + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + failureMessage: + description: |- + failureMessage will be set on non-retryable errors - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - maxLength: 256 - minLength: 1 - type: string + Deprecated: This field 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. + maxLength: 10240 + minLength: 1 + type: string + failureReason: + description: |- + failureReason will be set on non-retryable errors + + Deprecated: This field 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. + maxLength: 256 + minLength: 1 + type: string + type: object + type: object observedGeneration: description: observedGeneration is the latest generation observed by the controller. @@ -6091,75 +6168,6 @@ spec: description: ready indicates the BootstrapData field is ready to be consumed type: boolean - v1beta2: - description: v1beta2 groups all the fields that will be added or modified - in KubeadmConfig's status with the V1Beta2 version. - properties: - conditions: - description: |- - conditions represents the observations of a KubeadmConfig's current state. - Known condition types are Ready, DataSecretAvailable, CertificatesAvailable. - items: - description: Condition contains details for one aspect of the - current state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, - Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - maxItems: 32 - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - type: object type: object type: object served: true diff --git a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml index 83ba811968b7..beb3ca783aa0 100644 --- a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml +++ b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml @@ -732,131 +732,139 @@ spec: description: status is the observed state of ClusterResourceSet. properties: conditions: - description: conditions defines current state of the ClusterResourceSet. + description: |- + conditions represents the observations of a ClusterResourceSet's current state. + Known condition types are ResourceSetApplied, Deleting. items: - description: Condition defines an observation of a Cluster API resource - operational state. + description: Condition contains details for one aspect of the current + state of this API Resource. properties: lastTransitionTime: description: |- lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when - the API field changed is acceptable. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. format: date-time type: string message: description: |- message is a human readable message indicating details about the transition. - This field may be empty. - maxLength: 10240 - minLength: 1 + This may be an empty string. + maxLength: 32768 type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer reason: description: |- - reason is the reason for the condition's last transition in CamelCase. - The specific API may choose whether or not this field is considered a guaranteed API. - This field may be empty. - maxLength: 256 + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 minLength: 1 - type: string - severity: - description: |- - severity provides an explicit classification of Reason code, so the users or machines can immediately - understand the current situation and act accordingly. - The Severity field MUST be set only when Status=False. - maxLength: 32 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ type: string status: description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown type: string type: - description: |- - type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources like Available, but because arbitrary conditions - can be useful (see .node.status.conditions), the ability to deconflict is important. - maxLength: 256 - minLength: 1 + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ type: string required: - lastTransitionTime + - message + - reason - status - type type: object + maxItems: 32 type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + deprecated: + description: deprecated groups all the status fields that are deprecated + and will be removed when all the nested field are removed. + properties: + v1beta1: + description: v1beta1 groups all the status fields that are deprecated + and will be removed when support for v1beta1 will be dropped. + properties: + conditions: + description: |- + conditions defines current state of the ClusterResourceSet. + + Deprecated: This field 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. + items: + description: Condition defines an observation of a Cluster + API resource operational state. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This field may be empty. + maxLength: 10240 + minLength: 1 + type: string + reason: + description: |- + reason is the reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may be empty. + maxLength: 256 + minLength: 1 + type: string + severity: + description: |- + severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + maxLength: 32 + type: string + status: + description: status of the condition, one of True, False, + Unknown. + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + maxLength: 256 + minLength: 1 + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + type: object + type: object observedGeneration: description: observedGeneration reflects the generation of the most recently observed ClusterResourceSet. format: int64 type: integer - v1beta2: - description: v1beta2 groups all the fields that will be added or modified - in ClusterResourceSet's status with the V1Beta2 version. - properties: - conditions: - description: |- - conditions represents the observations of a ClusterResourceSet's current state. - Known condition types are ResourceSetApplied, Deleting. - items: - description: Condition contains details for one aspect of the - current state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, - Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - maxItems: 32 - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - type: object type: object type: object served: true diff --git a/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml b/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml index 0c654c7778cc..53f7d4551ebc 100644 --- a/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml +++ b/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml @@ -4642,131 +4642,139 @@ spec: description: status is the observed state of ClusterClass. properties: conditions: - description: conditions defines current observed state of the ClusterClass. + description: |- + conditions represents the observations of a ClusterClass's current state. + Known condition types are VariablesReady, RefVersionsUpToDate, Paused. items: - description: Condition defines an observation of a Cluster API resource - operational state. + description: Condition contains details for one aspect of the current + state of this API Resource. properties: lastTransitionTime: description: |- lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when - the API field changed is acceptable. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. format: date-time type: string message: description: |- message is a human readable message indicating details about the transition. - This field may be empty. - maxLength: 10240 - minLength: 1 + This may be an empty string. + maxLength: 32768 type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer reason: description: |- - reason is the reason for the condition's last transition in CamelCase. - The specific API may choose whether or not this field is considered a guaranteed API. - This field may be empty. - maxLength: 256 + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 minLength: 1 - type: string - severity: - description: |- - severity provides an explicit classification of Reason code, so the users or machines can immediately - understand the current situation and act accordingly. - The Severity field MUST be set only when Status=False. - maxLength: 32 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ type: string status: description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown type: string type: - description: |- - type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources like Available, but because arbitrary conditions - can be useful (see .node.status.conditions), the ability to deconflict is important. - maxLength: 256 - minLength: 1 + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ type: string required: - lastTransitionTime + - message + - reason - status - type type: object + maxItems: 32 type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + deprecated: + description: deprecated groups all the status fields that are deprecated + and will be removed when all the nested field are removed. + properties: + v1beta1: + description: v1beta1 groups all the status fields that are deprecated + and will be removed when support for v1beta1 will be dropped. + properties: + conditions: + description: |- + conditions defines current observed state of the ClusterClass. + + Deprecated: This field 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. + items: + description: Condition defines an observation of a Cluster + API resource operational state. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This field may be empty. + maxLength: 10240 + minLength: 1 + type: string + reason: + description: |- + reason is the reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may be empty. + maxLength: 256 + minLength: 1 + type: string + severity: + description: |- + severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + maxLength: 32 + type: string + status: + description: status of the condition, one of True, False, + Unknown. + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + maxLength: 256 + minLength: 1 + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + type: object + type: object observedGeneration: description: observedGeneration is the latest generation observed by the controller. format: int64 type: integer - v1beta2: - description: v1beta2 groups all the fields that will be added or modified - in ClusterClass's status with the V1Beta2 version. - properties: - conditions: - description: |- - conditions represents the observations of a ClusterClass's current state. - Known condition types are VariablesReady, RefVersionsUpToDate, Paused. - items: - description: Condition contains details for one aspect of the - current state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, - Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - maxItems: 32 - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - type: object variables: description: variables is a list of ClusterClassStatusVariable that are defined for the ClusterClass. diff --git a/config/crd/bases/cluster.x-k8s.io_clusters.yaml b/config/crd/bases/cluster.x-k8s.io_clusters.yaml index 8ab3276abdfe..af9efc315266 100644 --- a/config/crd/bases/cluster.x-k8s.io_clusters.yaml +++ b/config/crd/bases/cluster.x-k8s.io_clusters.yaml @@ -1968,7 +1968,7 @@ spec: failureMessage indicates that there is a fatal problem reconciling the state, and will be set to a descriptive error message. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. maxLength: 10240 minLength: 1 type: string @@ -1978,7 +1978,7 @@ spec: state, and will be set to a token value suitable for programmatic interpretation. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. type: string infrastructureReady: description: infrastructureReady is the state of the infrastructure @@ -3313,57 +3313,104 @@ spec: description: status is the observed state of Cluster. properties: conditions: - description: conditions defines current service state of the cluster. + description: |- + conditions represents the observations of a Cluster's current state. + Known condition types are Available, InfrastructureReady, ControlPlaneInitialized, ControlPlaneAvailable, WorkersAvailable, MachinesReady + MachinesUpToDate, RemoteConnectionProbe, ScalingUp, ScalingDown, Remediating, Deleting, Paused. + Additionally, a TopologyReconciled condition will be added in case the Cluster is referencing a ClusterClass / defining a managed Topology. items: - description: Condition defines an observation of a Cluster API resource - operational state. + description: Condition contains details for one aspect of the current + state of this API Resource. properties: lastTransitionTime: description: |- lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when - the API field changed is acceptable. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. format: date-time type: string message: description: |- message is a human readable message indicating details about the transition. - This field may be empty. - maxLength: 10240 - minLength: 1 + This may be an empty string. + maxLength: 32768 type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer reason: description: |- - reason is the reason for the condition's last transition in CamelCase. - The specific API may choose whether or not this field is considered a guaranteed API. - This field may be empty. - maxLength: 256 + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 minLength: 1 - type: string - severity: - description: |- - severity provides an explicit classification of Reason code, so the users or machines can immediately - understand the current situation and act accordingly. - The Severity field MUST be set only when Status=False. - maxLength: 32 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ type: string status: description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown type: string type: - description: |- - type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources like Available, but because arbitrary conditions - can be useful (see .node.status.conditions), the ability to deconflict is important. - maxLength: 256 - minLength: 1 + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ type: string required: - lastTransitionTime + - message + - reason - status - type type: object + maxItems: 32 type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + controlPlane: + description: controlPlane groups all the observations about Cluster's + ControlPlane current state. + properties: + availableReplicas: + description: availableReplicas is the total number of available + control plane machines in this cluster. A machine is considered + available when Machine's Available condition is true. + format: int32 + type: integer + desiredReplicas: + description: desiredReplicas is the total number of desired control + plane machines in this cluster. + format: int32 + type: integer + readyReplicas: + description: readyReplicas is the total number of ready control + plane machines in this cluster. A machine is considered ready + when Machine's Ready condition is true. + format: int32 + type: integer + replicas: + description: |- + replicas is the total number of control plane machines in this cluster. + NOTE: replicas also includes machines still being provisioned or being deleted. + format: int32 + type: integer + upToDateReplicas: + description: upToDateReplicas is the number of up-to-date control + plane machines in this cluster. A machine is considered up-to-date + when Machine's UpToDate condition is true. + format: int32 + type: integer + type: object controlPlaneReady: description: |- controlPlaneReady denotes if the control plane became ready during initial provisioning @@ -3372,6 +3419,89 @@ spec: The value of this field is never updated after provisioning is completed. Please use conditions to check the operational state of the control plane. type: boolean + deprecated: + description: deprecated groups all the status fields that are deprecated + and will be removed when all the nested field are removed. + properties: + v1beta1: + description: v1beta1 groups all the status fields that are deprecated + and will be removed when support for v1beta1 will be dropped. + properties: + conditions: + description: |- + conditions defines current service state of the cluster. + + Deprecated: This field 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. + items: + description: Condition defines an observation of a Cluster + API resource operational state. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This field may be empty. + maxLength: 10240 + minLength: 1 + type: string + reason: + description: |- + reason is the reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may be empty. + maxLength: 256 + minLength: 1 + type: string + severity: + description: |- + severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + maxLength: 32 + type: string + status: + description: status of the condition, one of True, False, + Unknown. + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + maxLength: 256 + minLength: 1 + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + failureMessage: + description: |- + failureMessage indicates that there is a fatal problem reconciling the + state, and will be set to a descriptive error message. + + Deprecated: This field 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. + maxLength: 10240 + minLength: 1 + type: string + failureReason: + description: |- + failureReason indicates that there is a fatal problem reconciling the + state, and will be set to a token value suitable for + programmatic interpretation. + + Deprecated: This field 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. + type: string + type: object + type: object failureDomains: additionalProperties: description: |- @@ -3392,23 +3522,6 @@ spec: description: failureDomains is a slice of failure domain objects synced from the infrastructure provider. type: object - failureMessage: - description: |- - failureMessage indicates that there is a fatal problem reconciling the - state, and will be set to a descriptive error message. - - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - maxLength: 10240 - minLength: 1 - type: string - failureReason: - description: |- - failureReason indicates that there is a fatal problem reconciling the - state, and will be set to a token value suitable for - programmatic interpretation. - - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - type: string infrastructureReady: description: infrastructureReady is the state of the infrastructure provider. @@ -3428,144 +3541,39 @@ spec: - Failed - Unknown type: string - v1beta2: - description: v1beta2 groups all the fields that will be added or modified - in Cluster's status with the V1Beta2 version. + workers: + description: workers groups all the observations about Cluster's Workers + current state. properties: - conditions: + availableReplicas: + description: availableReplicas is the total number of available + worker machines in this cluster. A machine is considered available + when Machine's Available condition is true. + format: int32 + type: integer + desiredReplicas: + description: desiredReplicas is the total number of desired worker + machines in this cluster. + format: int32 + type: integer + readyReplicas: + description: readyReplicas is the total number of ready worker + machines in this cluster. A machine is considered ready when + Machine's Ready condition is true. + format: int32 + type: integer + replicas: description: |- - conditions represents the observations of a Cluster's current state. - Known condition types are Available, InfrastructureReady, ControlPlaneInitialized, ControlPlaneAvailable, WorkersAvailable, MachinesReady - MachinesUpToDate, RemoteConnectionProbe, ScalingUp, ScalingDown, Remediating, Deleting, Paused. - Additionally, a TopologyReconciled condition will be added in case the Cluster is referencing a ClusterClass / defining a managed Topology. - items: - description: Condition contains details for one aspect of the - current state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, - Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - maxItems: 32 - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - controlPlane: - description: controlPlane groups all the observations about Cluster's - ControlPlane current state. - properties: - availableReplicas: - description: availableReplicas is the total number of available - control plane machines in this cluster. A machine is considered - available when Machine's Available condition is true. - format: int32 - type: integer - desiredReplicas: - description: desiredReplicas is the total number of desired - control plane machines in this cluster. - format: int32 - type: integer - readyReplicas: - description: readyReplicas is the total number of ready control - plane machines in this cluster. A machine is considered - ready when Machine's Ready condition is true. - format: int32 - type: integer - replicas: - description: |- - replicas is the total number of control plane machines in this cluster. - NOTE: replicas also includes machines still being provisioned or being deleted. - format: int32 - type: integer - upToDateReplicas: - description: upToDateReplicas is the number of up-to-date - control plane machines in this cluster. A machine is considered - up-to-date when Machine's UpToDate condition is true. - format: int32 - type: integer - type: object - workers: - description: workers groups all the observations about Cluster's - Workers current state. - properties: - availableReplicas: - description: availableReplicas is the total number of available - worker machines in this cluster. A machine is considered - available when Machine's Available condition is true. - format: int32 - type: integer - desiredReplicas: - description: desiredReplicas is the total number of desired - worker machines in this cluster. - format: int32 - type: integer - readyReplicas: - description: readyReplicas is the total number of ready worker - machines in this cluster. A machine is considered ready - when Machine's Ready condition is true. - format: int32 - type: integer - replicas: - description: |- - replicas is the total number of worker machines in this cluster. - NOTE: replicas also includes machines still being provisioned or being deleted. - format: int32 - type: integer - upToDateReplicas: - description: upToDateReplicas is the number of up-to-date - worker machines in this cluster. A machine is considered - up-to-date when Machine's UpToDate condition is true. - format: int32 - type: integer - type: object + replicas is the total number of worker machines in this cluster. + NOTE: replicas also includes machines still being provisioned or being deleted. + format: int32 + type: integer + upToDateReplicas: + description: upToDateReplicas is the number of up-to-date worker + machines in this cluster. A machine is considered up-to-date + when Machine's UpToDate condition is true. + format: int32 + type: integer type: object type: object type: object diff --git a/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml b/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml index fb22404b5d0e..6f54d7a1be17 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml @@ -1706,7 +1706,7 @@ spec: be machines that are running but not yet available or machines that still have not been created. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. format: int32 type: integer updatedReplicas: @@ -2363,63 +2363,174 @@ spec: description: status is the observed state of MachineDeployment. properties: availableReplicas: - description: |- - availableReplicas is the total number of available machines (ready for at least minReadySeconds) - targeted by this deployment. + description: availableReplicas is the number of available replicas + for this MachineDeployment. A machine is considered available when + Machine's Available condition is true. format: int32 type: integer conditions: - description: conditions defines current service state of the MachineDeployment. + description: |- + conditions represents the observations of a MachineDeployment's current state. + Known condition types are Available, MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused. items: - description: Condition defines an observation of a Cluster API resource - operational state. + description: Condition contains details for one aspect of the current + state of this API Resource. properties: lastTransitionTime: description: |- lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when - the API field changed is acceptable. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. format: date-time type: string message: description: |- message is a human readable message indicating details about the transition. - This field may be empty. - maxLength: 10240 - minLength: 1 + This may be an empty string. + maxLength: 32768 type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer reason: description: |- - reason is the reason for the condition's last transition in CamelCase. - The specific API may choose whether or not this field is considered a guaranteed API. - This field may be empty. - maxLength: 256 + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 minLength: 1 - type: string - severity: - description: |- - severity provides an explicit classification of Reason code, so the users or machines can immediately - understand the current situation and act accordingly. - The Severity field MUST be set only when Status=False. - maxLength: 32 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ type: string status: description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown type: string type: - description: |- - type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources like Available, but because arbitrary conditions - can be useful (see .node.status.conditions), the ability to deconflict is important. - maxLength: 256 - minLength: 1 + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ type: string required: - lastTransitionTime + - message + - reason - status - type type: object + maxItems: 32 type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + deprecated: + description: deprecated groups all the status fields that are deprecated + and will be removed when all the nested field are removed. + properties: + v1beta1: + description: v1beta1 groups all the status fields that are deprecated + and will be removed when support for v1beta1 will be dropped. + properties: + availableReplicas: + description: |- + availableReplicas is the total number of available machines (ready for at least minReadySeconds) + targeted by this deployment. + + Deprecated: This field 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. + format: int32 + type: integer + conditions: + description: |- + conditions defines current service state of the MachineDeployment. + + Deprecated: This field 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. + items: + description: Condition defines an observation of a Cluster + API resource operational state. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This field may be empty. + maxLength: 10240 + minLength: 1 + type: string + reason: + description: |- + reason is the reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may be empty. + maxLength: 256 + minLength: 1 + type: string + severity: + description: |- + severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + maxLength: 32 + type: string + status: + description: status of the condition, one of True, False, + Unknown. + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + maxLength: 256 + minLength: 1 + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + readyReplicas: + description: |- + readyReplicas is the total number of ready machines targeted by this deployment. + + Deprecated: This field 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. + format: int32 + type: integer + unavailableReplicas: + description: |- + unavailableReplicas is the total number of unavailable machines targeted by this deployment. + This is the total number of machines that are still required for + the deployment to have 100% available capacity. They may either + be machines that are running but not yet available or machines + that still have not been created. + + Deprecated: This field 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. + format: int32 + type: integer + updatedReplicas: + description: |- + updatedReplicas is the total number of non-terminated machines targeted by this deployment + that have the desired template spec. + + Deprecated: This field 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. + format: int32 + type: integer + type: object + type: object observedGeneration: description: observedGeneration is the generation observed by the deployment controller. @@ -2436,8 +2547,9 @@ spec: - Unknown type: string readyReplicas: - description: readyReplicas is the total number of ready machines targeted - by this deployment. + description: readyReplicas is the number of ready replicas for this + MachineDeployment. A machine is considered ready when Machine's + Ready condition is true. format: int32 type: integer replicas: @@ -2454,110 +2566,12 @@ spec: maxLength: 4096 minLength: 1 type: string - unavailableReplicas: - description: |- - unavailableReplicas is the total number of unavailable machines targeted by this deployment. - This is the total number of machines that are still required for - the deployment to have 100% available capacity. They may either - be machines that are running but not yet available or machines - that still have not been created. - - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + upToDateReplicas: + description: upToDateReplicas is the number of up-to-date replicas + targeted by this deployment. A machine is considered up-to-date + when Machine's UpToDate condition is true. format: int32 type: integer - updatedReplicas: - description: |- - updatedReplicas is the total number of non-terminated machines targeted by this deployment - that have the desired template spec. - format: int32 - type: integer - v1beta2: - description: v1beta2 groups all the fields that will be added or modified - in MachineDeployment's status with the V1Beta2 version. - properties: - availableReplicas: - description: availableReplicas is the number of available replicas - for this MachineDeployment. A machine is considered available - when Machine's Available condition is true. - format: int32 - type: integer - conditions: - description: |- - conditions represents the observations of a MachineDeployment's current state. - Known condition types are Available, MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused. - items: - description: Condition contains details for one aspect of the - current state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, - Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - maxItems: 32 - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - readyReplicas: - description: readyReplicas is the number of ready replicas for - this MachineDeployment. A machine is considered ready when Machine's - Ready condition is true. - format: int32 - type: integer - upToDateReplicas: - description: upToDateReplicas is the number of up-to-date replicas - targeted by this deployment. A machine is considered up-to-date - when Machine's UpToDate condition is true. - format: int32 - type: integer - type: object type: object type: object served: true diff --git a/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml b/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml index f6ee4c23a071..bbe02edd49fd 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml @@ -1219,63 +1219,140 @@ spec: resource properties: conditions: - description: conditions defines current service state of the MachineHealthCheck. + description: |- + conditions represents the observations of a MachineHealthCheck's current state. + Known condition types are RemediationAllowed, Paused. items: - description: Condition defines an observation of a Cluster API resource - operational state. + description: Condition contains details for one aspect of the current + state of this API Resource. properties: lastTransitionTime: description: |- lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when - the API field changed is acceptable. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. format: date-time type: string message: description: |- message is a human readable message indicating details about the transition. - This field may be empty. - maxLength: 10240 - minLength: 1 + This may be an empty string. + maxLength: 32768 type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer reason: description: |- - reason is the reason for the condition's last transition in CamelCase. - The specific API may choose whether or not this field is considered a guaranteed API. - This field may be empty. - maxLength: 256 + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 minLength: 1 - type: string - severity: - description: |- - severity provides an explicit classification of Reason code, so the users or machines can immediately - understand the current situation and act accordingly. - The Severity field MUST be set only when Status=False. - maxLength: 32 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ type: string status: description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown type: string type: - description: |- - type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources like Available, but because arbitrary conditions - can be useful (see .node.status.conditions), the ability to deconflict is important. - maxLength: 256 - minLength: 1 + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ type: string required: - lastTransitionTime + - message + - reason - status - type type: object + maxItems: 32 type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map currentHealthy: description: currentHealthy is the total number of healthy machines counted by this machine health check format: int32 minimum: 0 type: integer + deprecated: + description: deprecated groups all the status fields that are deprecated + and will be removed when all the nested field are removed. + properties: + v1beta1: + description: v1beta1 groups all the status fields that are deprecated + and will be removed when support for v1beta1 will be dropped. + properties: + conditions: + description: |- + conditions defines current service state of the MachineHealthCheck. + + Deprecated: This field 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. + items: + description: Condition defines an observation of a Cluster + API resource operational state. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This field may be empty. + maxLength: 10240 + minLength: 1 + type: string + reason: + description: |- + reason is the reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may be empty. + maxLength: 256 + minLength: 1 + type: string + severity: + description: |- + severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + maxLength: 32 + type: string + status: + description: status of the condition, one of True, False, + Unknown. + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + maxLength: 256 + minLength: 1 + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + type: object + type: object expectedMachines: description: expectedMachines is the total number of machines counted by this machine health check @@ -1303,75 +1380,6 @@ spec: type: string maxItems: 10000 type: array - v1beta2: - description: v1beta2 groups all the fields that will be added or modified - in MachineHealthCheck's status with the V1Beta2 version. - properties: - conditions: - description: |- - conditions represents the observations of a MachineHealthCheck's current state. - Known condition types are RemediationAllowed, Paused. - items: - description: Condition contains details for one aspect of the - current state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, - Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - maxItems: 32 - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - type: object type: object type: object served: true diff --git a/config/crd/bases/cluster.x-k8s.io_machinepools.yaml b/config/crd/bases/cluster.x-k8s.io_machinepools.yaml index 5edb07dafd44..ae0a00bd843c 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinepools.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinepools.yaml @@ -1408,7 +1408,7 @@ spec: failureMessage indicates that there is a problem reconciling the state, and will be set to a descriptive error message. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. maxLength: 10240 minLength: 1 type: string @@ -1417,7 +1417,7 @@ spec: failureReason indicates that there is a problem reconciling the state, and will be set to a token value suitable for programmatic interpretation. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. type: string infrastructureReady: description: infrastructureReady is the state of the infrastructure @@ -1509,7 +1509,7 @@ spec: be machine instances that are running but not yet available or machine instances that still have not been created. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. format: int32 type: integer v1beta2: @@ -1952,80 +1952,181 @@ spec: properties: availableReplicas: description: availableReplicas is the number of available replicas - (ready for at least minReadySeconds) for this MachinePool. + for this MachinePool. A machine is considered available when Machine's + Available condition is true. format: int32 type: integer bootstrapReady: description: bootstrapReady is the state of the bootstrap provider. type: boolean conditions: - description: conditions define the current service state of the MachinePool. + description: |- + conditions represents the observations of a MachinePool's current state. + Known condition types are Available, BootstrapConfigReady, InfrastructureReady, MachinesReady, MachinesUpToDate, + ScalingUp, ScalingDown, Remediating, Deleting, Paused. items: - description: Condition defines an observation of a Cluster API resource - operational state. + description: Condition contains details for one aspect of the current + state of this API Resource. properties: lastTransitionTime: description: |- lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when - the API field changed is acceptable. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. format: date-time type: string message: description: |- message is a human readable message indicating details about the transition. - This field may be empty. - maxLength: 10240 - minLength: 1 + This may be an empty string. + maxLength: 32768 type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer reason: description: |- - reason is the reason for the condition's last transition in CamelCase. - The specific API may choose whether or not this field is considered a guaranteed API. - This field may be empty. - maxLength: 256 + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 minLength: 1 - type: string - severity: - description: |- - severity provides an explicit classification of Reason code, so the users or machines can immediately - understand the current situation and act accordingly. - The Severity field MUST be set only when Status=False. - maxLength: 32 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ type: string status: description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown type: string type: - description: |- - type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources like Available, but because arbitrary conditions - can be useful (see .node.status.conditions), the ability to deconflict is important. - maxLength: 256 - minLength: 1 + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ type: string required: - lastTransitionTime + - message + - reason - status - type type: object + maxItems: 32 type: array - failureMessage: - description: |- - failureMessage indicates that there is a problem reconciling the state, - and will be set to a descriptive error message. + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + deprecated: + description: deprecated groups all the status fields that are deprecated + and will be removed when all the nested field are removed. + properties: + v1beta1: + description: v1beta1 groups all the status fields that are deprecated + and will be removed when support for v1beta1 will be dropped. + properties: + availableReplicas: + description: availableReplicas is the number of available + replicas (ready for at least minReadySeconds) for this MachinePool. + format: int32 + type: integer + conditions: + description: |- + conditions define the current service state of the MachinePool. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - maxLength: 10240 - minLength: 1 - type: string - failureReason: - description: |- - failureReason indicates that there is a problem reconciling the state, and - will be set to a token value suitable for programmatic interpretation. + Deprecated: This field 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. + items: + description: Condition defines an observation of a Cluster + API resource operational state. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This field may be empty. + maxLength: 10240 + minLength: 1 + type: string + reason: + description: |- + reason is the reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may be empty. + maxLength: 256 + minLength: 1 + type: string + severity: + description: |- + severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + maxLength: 32 + type: string + status: + description: status of the condition, one of True, False, + Unknown. + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + maxLength: 256 + minLength: 1 + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + failureMessage: + description: |- + failureMessage indicates that there is a problem reconciling the state, + and will be set to a descriptive error message. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - type: string + Deprecated: This field 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. + maxLength: 10240 + minLength: 1 + type: string + failureReason: + description: |- + failureReason indicates that there is a problem reconciling the state, and + will be set to a token value suitable for programmatic interpretation. + + Deprecated: This field 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. + type: string + readyReplicas: + description: readyReplicas is the number of ready replicas + for this MachinePool. A machine is considered ready when + the node has been created and is "Ready". + format: int32 + type: integer + unavailableReplicas: + description: |- + unavailableReplicas is the total number of unavailable machine instances targeted by this machine pool. + This is the total number of machine instances that are still required for + the machine pool to have 100% available capacity. They may either + be machine instances that are running but not yet available or machine instances + that still have not been created. + + Deprecated: This field 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. + format: int32 + type: integer + type: object + type: object infrastructureReady: description: infrastructureReady is the state of the infrastructure provider. @@ -2100,113 +2201,20 @@ spec: type: string readyReplicas: description: readyReplicas is the number of ready replicas for this - MachinePool. A machine is considered ready when the node has been - created and is "Ready". + MachinePool. A machine is considered ready when Machine's Ready + condition is true. format: int32 type: integer replicas: description: replicas is the most recently observed number of replicas. format: int32 type: integer - unavailableReplicas: - description: |- - unavailableReplicas is the total number of unavailable machine instances targeted by this machine pool. - This is the total number of machine instances that are still required for - the machine pool to have 100% available capacity. They may either - be machine instances that are running but not yet available or machine instances - that still have not been created. - - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + upToDateReplicas: + description: upToDateReplicas is the number of up-to-date replicas + targeted by this MachinePool. A machine is considered up-to-date + when Machine's UpToDate condition is true. format: int32 type: integer - v1beta2: - description: v1beta2 groups all the fields that will be added or modified - in MachinePool's status with the V1Beta2 version. - properties: - availableReplicas: - description: availableReplicas is the number of available replicas - for this MachinePool. A machine is considered available when - Machine's Available condition is true. - format: int32 - type: integer - conditions: - description: |- - conditions represents the observations of a MachinePool's current state. - Known condition types are Available, BootstrapConfigReady, InfrastructureReady, MachinesReady, MachinesUpToDate, - ScalingUp, ScalingDown, Remediating, Deleting, Paused. - items: - description: Condition contains details for one aspect of the - current state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, - Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - maxItems: 32 - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - readyReplicas: - description: readyReplicas is the number of ready replicas for - this MachinePool. A machine is considered ready when Machine's - Ready condition is true. - format: int32 - type: integer - upToDateReplicas: - description: upToDateReplicas is the number of up-to-date replicas - targeted by this MachinePool. A machine is considered up-to-date - when Machine's UpToDate condition is true. - format: int32 - type: integer - type: object type: object type: object served: true diff --git a/config/crd/bases/cluster.x-k8s.io_machines.yaml b/config/crd/bases/cluster.x-k8s.io_machines.yaml index abfe2780bd61..a0851a7253ef 100644 --- a/config/crd/bases/cluster.x-k8s.io_machines.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machines.yaml @@ -1227,7 +1227,7 @@ spec: can be added as events to the Machine object and/or logged in the controller's output. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. maxLength: 10240 minLength: 1 type: string @@ -1250,7 +1250,7 @@ spec: can be added as events to the Machine object and/or logged in the controller's output. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. type: string infrastructureReady: description: infrastructureReady is the state of the infrastructure @@ -1757,57 +1757,72 @@ spec: format: date-time type: string conditions: - description: conditions defines current service state of the Machine. + description: |- + conditions represents the observations of a Machine's current state. + Known condition types are Available, Ready, UpToDate, BootstrapConfigReady, InfrastructureReady, NodeReady, + NodeHealthy, Deleting, Paused. + If a MachineHealthCheck is targeting this machine, also HealthCheckSucceeded, OwnerRemediated conditions are added. + Additionally control plane Machines controlled by KubeadmControlPlane will have following additional conditions: + APIServerPodHealthy, ControllerManagerPodHealthy, SchedulerPodHealthy, EtcdPodHealthy, EtcdMemberHealthy. items: - description: Condition defines an observation of a Cluster API resource - operational state. + description: Condition contains details for one aspect of the current + state of this API Resource. properties: lastTransitionTime: description: |- lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when - the API field changed is acceptable. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. format: date-time type: string message: description: |- message is a human readable message indicating details about the transition. - This field may be empty. - maxLength: 10240 - minLength: 1 + This may be an empty string. + maxLength: 32768 type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer reason: description: |- - reason is the reason for the condition's last transition in CamelCase. - The specific API may choose whether or not this field is considered a guaranteed API. - This field may be empty. - maxLength: 256 + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 minLength: 1 - type: string - severity: - description: |- - severity provides an explicit classification of Reason code, so the users or machines can immediately - understand the current situation and act accordingly. - The Severity field MUST be set only when Status=False. - maxLength: 32 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ type: string status: description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown type: string type: - description: |- - type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources like Available, but because arbitrary conditions - can be useful (see .node.status.conditions), the ability to deconflict is important. - maxLength: 256 - minLength: 1 + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ type: string required: - lastTransitionTime + - message + - reason - status - type type: object + maxItems: 32 type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map deletion: description: |- deletion contains information relating to removal of the Machine. @@ -1830,50 +1845,118 @@ spec: format: date-time type: string type: object - failureMessage: - description: |- - failureMessage will be set in the event that there is a terminal problem - reconciling the Machine and will contain a more verbose string suitable - for logging and human consumption. + deprecated: + description: deprecated groups all the status fields that are deprecated + and will be removed when all the nested field are removed. + properties: + v1beta1: + description: |- + v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped. - This field should not be set for transitive errors that a controller - faces that are expected to be fixed automatically over - time (like service outages), but instead indicate that something is - fundamentally wrong with the Machine's spec or the configuration of - the controller, and that manual intervention is required. Examples - of terminal errors would be invalid combinations of settings in the - spec, values that are unsupported by the controller, or the - responsible controller itself being critically misconfigured. + Deprecated: This field 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. + properties: + conditions: + description: |- + conditions defines current service state of the Machine. - Any transient errors that occur during the reconciliation of Machines - can be added as events to the Machine object and/or logged in the - controller's output. + Deprecated: This field 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. + items: + description: Condition defines an observation of a Cluster + API resource operational state. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This field may be empty. + maxLength: 10240 + minLength: 1 + type: string + reason: + description: |- + reason is the reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may be empty. + maxLength: 256 + minLength: 1 + type: string + severity: + description: |- + severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + maxLength: 32 + type: string + status: + description: status of the condition, one of True, False, + Unknown. + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + maxLength: 256 + minLength: 1 + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + failureMessage: + description: |- + failureMessage will be set in the event that there is a terminal problem + reconciling the Machine and will contain a more verbose string suitable + for logging and human consumption. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - maxLength: 10240 - minLength: 1 - type: string - failureReason: - description: |- - failureReason will be set in the event that there is a terminal problem - reconciling the Machine and will contain a succinct value suitable - for machine interpretation. + This field should not be set for transitive errors that a controller + faces that are expected to be fixed automatically over + time (like service outages), but instead indicate that something is + fundamentally wrong with the Machine's spec or the configuration of + the controller, and that manual intervention is required. Examples + of terminal errors would be invalid combinations of settings in the + spec, values that are unsupported by the controller, or the + responsible controller itself being critically misconfigured. - This field should not be set for transitive errors that a controller - faces that are expected to be fixed automatically over - time (like service outages), but instead indicate that something is - fundamentally wrong with the Machine's spec or the configuration of - the controller, and that manual intervention is required. Examples - of terminal errors would be invalid combinations of settings in the - spec, values that are unsupported by the controller, or the - responsible controller itself being critically misconfigured. + Any transient errors that occur during the reconciliation of Machines + can be added as events to the Machine object and/or logged in the + controller's output. - Any transient errors that occur during the reconciliation of Machines - can be added as events to the Machine object and/or logged in the - controller's output. + Deprecated: This field 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. + maxLength: 10240 + minLength: 1 + type: string + failureReason: + description: |- + failureReason will be set in the event that there is a terminal problem + reconciling the Machine and will contain a succinct value suitable + for machine interpretation. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - type: string + This field should not be set for transitive errors that a controller + faces that are expected to be fixed automatically over + time (like service outages), but instead indicate that something is + fundamentally wrong with the Machine's spec or the configuration of + the controller, and that manual intervention is required. Examples + of terminal errors would be invalid combinations of settings in the + spec, values that are unsupported by the controller, or the + responsible controller itself being critically misconfigured. + + Any transient errors that occur during the reconciliation of Machines + can be added as events to the Machine object and/or logged in the + controller's output. + + Deprecated: This field 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. + type: string + type: object + type: object infrastructureReady: description: infrastructureReady is the state of the infrastructure provider. @@ -1999,79 +2082,6 @@ spec: - Failed - Unknown type: string - v1beta2: - description: v1beta2 groups all the fields that will be added or modified - in Machine's status with the V1Beta2 version. - properties: - conditions: - description: |- - conditions represents the observations of a Machine's current state. - Known condition types are Available, Ready, UpToDate, BootstrapConfigReady, InfrastructureReady, NodeReady, - NodeHealthy, Deleting, Paused. - If a MachineHealthCheck is targeting this machine, also HealthCheckSucceeded, OwnerRemediated conditions are added. - Additionally control plane Machines controlled by KubeadmControlPlane will have following additional conditions: - APIServerPodHealthy, ControllerManagerPodHealthy, SchedulerPodHealthy, EtcdPodHealthy, EtcdMemberHealthy. - items: - description: Condition contains details for one aspect of the - current state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, - Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - maxItems: 32 - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - type: object type: object type: object served: true diff --git a/config/crd/bases/cluster.x-k8s.io_machinesets.yaml b/config/crd/bases/cluster.x-k8s.io_machinesets.yaml index ebb0e447fbbd..b52b7e2a8faa 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinesets.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinesets.yaml @@ -1420,7 +1420,7 @@ spec: reconciling the Machine and will contain a more verbose string suitable for logging and human consumption. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. maxLength: 10240 minLength: 1 type: string @@ -1449,13 +1449,13 @@ spec: can be added as events to the MachineSet object and/or logged in the controller's output. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. type: string fullyLabeledReplicas: description: |- fullyLabeledReplicas is the number of replicas that have labels matching the labels of the machine template of the MachineSet. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. format: int32 type: integer observedGeneration: @@ -2007,105 +2007,197 @@ spec: properties: availableReplicas: description: availableReplicas is the number of available replicas - (ready for at least minReadySeconds) for this MachineSet. + for this MachineSet. A machine is considered available when Machine's + Available condition is true. format: int32 type: integer conditions: - description: conditions defines current service state of the MachineSet. + description: |- + conditions represents the observations of a MachineSet's current state. + Known condition types are MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused. items: - description: Condition defines an observation of a Cluster API resource - operational state. + description: Condition contains details for one aspect of the current + state of this API Resource. properties: lastTransitionTime: description: |- lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when - the API field changed is acceptable. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. format: date-time type: string message: description: |- message is a human readable message indicating details about the transition. - This field may be empty. - maxLength: 10240 - minLength: 1 + This may be an empty string. + maxLength: 32768 type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer reason: description: |- - reason is the reason for the condition's last transition in CamelCase. - The specific API may choose whether or not this field is considered a guaranteed API. - This field may be empty. - maxLength: 256 + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 minLength: 1 - type: string - severity: - description: |- - severity provides an explicit classification of Reason code, so the users or machines can immediately - understand the current situation and act accordingly. - The Severity field MUST be set only when Status=False. - maxLength: 32 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ type: string status: description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown type: string type: - description: |- - type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources like Available, but because arbitrary conditions - can be useful (see .node.status.conditions), the ability to deconflict is important. - maxLength: 256 - minLength: 1 + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ type: string required: - lastTransitionTime + - message + - reason - status - type type: object + maxItems: 32 type: array - failureMessage: - description: |- - failureMessage will be set in the event that there is a terminal problem - reconciling the Machine and will contain a more verbose string suitable - for logging and human consumption. + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + deprecated: + description: deprecated groups all the status fields that are deprecated + and will be removed when all the nested field are removed. + properties: + v1beta1: + description: v1beta1 groups all the status fields that are deprecated + and will be removed when support for v1beta1 will be dropped. + properties: + availableReplicas: + description: |- + availableReplicas is the number of available replicas (ready for at least minReadySeconds) for this MachineSet. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - maxLength: 10240 - minLength: 1 - type: string - failureReason: - description: |- - failureReason will be set in the event that there is a terminal problem - reconciling the Machine and will contain a succinct value suitable - for machine interpretation. + Deprecated: This field 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. + format: int32 + type: integer + conditions: + description: |- + conditions defines current service state of the MachineSet. - In the event that there is a terminal problem reconciling the - replicas, both FailureReason and FailureMessage will be set. FailureReason - will be populated with a succinct value suitable for machine - interpretation, while FailureMessage will contain a more verbose - string suitable for logging and human consumption. + Deprecated: This field 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. + items: + description: Condition defines an observation of a Cluster + API resource operational state. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This field may be empty. + maxLength: 10240 + minLength: 1 + type: string + reason: + description: |- + reason is the reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may be empty. + maxLength: 256 + minLength: 1 + type: string + severity: + description: |- + severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + maxLength: 32 + type: string + status: + description: status of the condition, one of True, False, + Unknown. + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + maxLength: 256 + minLength: 1 + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + failureMessage: + description: |- + failureMessage will be set in the event that there is a terminal problem + reconciling the Machine and will contain a more verbose string suitable + for logging and human consumption. - These fields should not be set for transitive errors that a - controller faces that are expected to be fixed automatically over - time (like service outages), but instead indicate that something is - fundamentally wrong with the MachineTemplate's spec or the configuration of - the machine controller, and that manual intervention is required. Examples - of terminal errors would be invalid combinations of settings in the - spec, values that are unsupported by the machine controller, or the - responsible machine controller itself being critically misconfigured. + Deprecated: This field 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. + maxLength: 10240 + minLength: 1 + type: string + failureReason: + description: |- + failureReason will be set in the event that there is a terminal problem + reconciling the Machine and will contain a succinct value suitable + for machine interpretation. - Any transient errors that occur during the reconciliation of Machines - can be added as events to the MachineSet object and/or logged in the - controller's output. + In the event that there is a terminal problem reconciling the + replicas, both FailureReason and FailureMessage will be set. FailureReason + will be populated with a succinct value suitable for machine + interpretation, while FailureMessage will contain a more verbose + string suitable for logging and human consumption. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - type: string - fullyLabeledReplicas: - description: |- - fullyLabeledReplicas is the number of replicas that have labels matching the labels of the machine template of the MachineSet. + These fields should not be set for transitive errors that a + controller faces that are expected to be fixed automatically over + time (like service outages), but instead indicate that something is + fundamentally wrong with the MachineTemplate's spec or the configuration of + the machine controller, and that manual intervention is required. Examples + of terminal errors would be invalid combinations of settings in the + spec, values that are unsupported by the machine controller, or the + responsible machine controller itself being critically misconfigured. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - format: int32 - type: integer + Any transient errors that occur during the reconciliation of Machines + can be added as events to the MachineSet object and/or logged in the + controller's output. + + Deprecated: This field 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. + type: string + fullyLabeledReplicas: + description: |- + fullyLabeledReplicas is the number of replicas that have labels matching the labels of the machine template of the MachineSet. + + Deprecated: This field 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. + format: int32 + type: integer + readyReplicas: + description: |- + readyReplicas is the number of ready replicas for this MachineSet. A machine is considered ready when the node has been created and is "Ready". + + Deprecated: This field 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. + format: int32 + type: integer + type: object + type: object observedGeneration: description: observedGeneration reflects the generation of the most recently observed MachineSet. @@ -2113,8 +2205,8 @@ spec: type: integer readyReplicas: description: readyReplicas is the number of ready replicas for this - MachineSet. A machine is considered ready when the node has been - created and is "Ready". + MachineSet. A machine is considered ready when Machine's Ready condition + is true. format: int32 type: integer replicas: @@ -2129,93 +2221,12 @@ spec: maxLength: 4096 minLength: 1 type: string - v1beta2: - description: v1beta2 groups all the fields that will be added or modified - in MachineSet's status with the V1Beta2 version. - properties: - availableReplicas: - description: availableReplicas is the number of available replicas - for this MachineSet. A machine is considered available when - Machine's Available condition is true. - format: int32 - type: integer - conditions: - description: |- - conditions represents the observations of a MachineSet's current state. - Known condition types are MachinesReady, MachinesUpToDate, ScalingUp, ScalingDown, Remediating, Deleting, Paused. - items: - description: Condition contains details for one aspect of the - current state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, - Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - maxItems: 32 - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - readyReplicas: - description: readyReplicas is the number of ready replicas for - this MachineSet. A machine is considered ready when Machine's - Ready condition is true. - format: int32 - type: integer - upToDateReplicas: - description: upToDateReplicas is the number of up-to-date replicas - for this MachineSet. A machine is considered up-to-date when - Machine's UpToDate condition is true. - format: int32 - type: integer - type: object + upToDateReplicas: + description: upToDateReplicas is the number of up-to-date replicas + for this MachineSet. A machine is considered up-to-date when Machine's + UpToDate condition is true. + format: int32 + type: integer type: object type: object served: true diff --git a/config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml b/config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml index 05eec3132b71..449cfd5b8a41 100644 --- a/config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml +++ b/config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml @@ -454,124 +454,132 @@ spec: type: object x-kubernetes-map-type: atomic conditions: - description: conditions summarises the current state of the IPAddressClaim + description: conditions represents the observations of a IPAddressClaim's + current state. items: - description: Condition defines an observation of a Cluster API resource - operational state. + description: Condition contains details for one aspect of the current + state of this API Resource. properties: lastTransitionTime: description: |- lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when - the API field changed is acceptable. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. format: date-time type: string message: description: |- message is a human readable message indicating details about the transition. - This field may be empty. - maxLength: 10240 - minLength: 1 + This may be an empty string. + maxLength: 32768 type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer reason: description: |- - reason is the reason for the condition's last transition in CamelCase. - The specific API may choose whether or not this field is considered a guaranteed API. - This field may be empty. - maxLength: 256 + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 minLength: 1 - type: string - severity: - description: |- - severity provides an explicit classification of Reason code, so the users or machines can immediately - understand the current situation and act accordingly. - The Severity field MUST be set only when Status=False. - maxLength: 32 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ type: string status: description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown type: string type: - description: |- - type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources like Available, but because arbitrary conditions - can be useful (see .node.status.conditions), the ability to deconflict is important. - maxLength: 256 - minLength: 1 + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ type: string required: - lastTransitionTime + - message + - reason - status - type type: object + maxItems: 32 type: array - v1beta2: - description: v1beta2 groups all the fields that will be added or modified - in IPAddressClaim's status with the V1Beta2 version. + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + deprecated: + description: deprecated groups all the status fields that are deprecated + and will be removed when all the nested field are removed. properties: - conditions: - description: conditions represents the observations of a IPAddressClaim's - current state. - items: - description: Condition contains details for one aspect of the - current state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, - Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - maxItems: 32 - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map + v1beta1: + description: v1beta1 groups all the status fields that are deprecated + and will be removed when support for v1beta1 will be dropped. + properties: + conditions: + description: |- + conditions summarises the current state of the IPAddressClaim + + Deprecated: This field 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. + items: + description: Condition defines an observation of a Cluster + API resource operational state. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This field may be empty. + maxLength: 10240 + minLength: 1 + type: string + reason: + description: |- + reason is the reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may be empty. + maxLength: 256 + minLength: 1 + type: string + severity: + description: |- + severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + maxLength: 32 + type: string + status: + description: status of the condition, one of True, False, + Unknown. + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + maxLength: 256 + minLength: 1 + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + type: object type: object type: object type: object diff --git a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml index 5413535c6f0b..41e0e6daee48 100644 --- a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml +++ b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml @@ -4765,7 +4765,7 @@ spec: failureMessage indicates that there is a terminal problem reconciling the state, and will be set to a descriptive error message. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. maxLength: 10240 minLength: 1 type: string @@ -4775,7 +4775,7 @@ spec: state, and will be set to a token value suitable for programmatic interpretation. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. type: string initialized: description: |- @@ -4852,7 +4852,7 @@ spec: be machines that are running but not yet ready or machines that still have not been created. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. + Deprecated: This field 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. format: int32 type: integer updatedReplicas: @@ -7239,75 +7239,185 @@ spec: status: description: status is the observed state of KubeadmControlPlane. properties: + availableReplicas: + description: availableReplicas is the number of available replicas + targeted by this KubeadmControlPlane. A machine is considered available + when Machine's Available condition is true. + format: int32 + type: integer conditions: - description: conditions defines current service state of the KubeadmControlPlane. + description: |- + conditions represents the observations of a KubeadmControlPlane's current state. + Known condition types are Available, CertificatesAvailable, EtcdClusterAvailable, MachinesReady, MachinesUpToDate, + ScalingUp, ScalingDown, Remediating, Deleting, Paused. items: - description: Condition defines an observation of a Cluster API resource - operational state. + description: Condition contains details for one aspect of the current + state of this API Resource. properties: lastTransitionTime: description: |- lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when - the API field changed is acceptable. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. format: date-time type: string message: description: |- message is a human readable message indicating details about the transition. - This field may be empty. - maxLength: 10240 - minLength: 1 + This may be an empty string. + maxLength: 32768 type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer reason: description: |- - reason is the reason for the condition's last transition in CamelCase. - The specific API may choose whether or not this field is considered a guaranteed API. - This field may be empty. - maxLength: 256 + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 minLength: 1 - type: string - severity: - description: |- - severity provides an explicit classification of Reason code, so the users or machines can immediately - understand the current situation and act accordingly. - The Severity field MUST be set only when Status=False. - maxLength: 32 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ type: string status: description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown type: string type: - description: |- - type of condition in CamelCase or in foo.example.com/CamelCase. - Many .condition.type values are consistent across resources like Available, but because arbitrary conditions - can be useful (see .node.status.conditions), the ability to deconflict is important. - maxLength: 256 - minLength: 1 + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ type: string required: - lastTransitionTime + - message + - reason - status - type type: object + maxItems: 32 type: array - failureMessage: - description: |- - failureMessage indicates that there is a terminal problem reconciling the - state, and will be set to a descriptive error message. + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + deprecated: + description: deprecated groups all the status fields that are deprecated + and will be removed when all the nested field are removed. + properties: + v1beta1: + description: v1beta1 groups all the status fields that are deprecated + and will be removed when support for v1beta1 will be dropped. + properties: + conditions: + description: |- + conditions defines current service state of the KubeadmControlPlane. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - maxLength: 10240 - minLength: 1 - type: string - failureReason: - description: |- - failureReason indicates that there is a terminal problem reconciling the - state, and will be set to a token value suitable for - programmatic interpretation. + Deprecated: This field 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. + items: + description: Condition defines an observation of a Cluster + API resource operational state. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This field may be empty. + maxLength: 10240 + minLength: 1 + type: string + reason: + description: |- + reason is the reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may be empty. + maxLength: 256 + minLength: 1 + type: string + severity: + description: |- + severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + maxLength: 32 + type: string + status: + description: status of the condition, one of True, False, + Unknown. + type: string + type: + description: |- + type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + maxLength: 256 + minLength: 1 + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + failureMessage: + description: |- + failureMessage indicates that there is a terminal problem reconciling the + state, and will be set to a descriptive error message. - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - type: string + Deprecated: This field 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. + maxLength: 10240 + minLength: 1 + type: string + failureReason: + description: |- + failureReason indicates that there is a terminal problem reconciling the + state, and will be set to a token value suitable for + programmatic interpretation. + + Deprecated: This field 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. + type: string + readyReplicas: + description: |- + readyReplicas is the total number of fully running and ready control plane machines. + + Deprecated: This field 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. + format: int32 + type: integer + unavailableReplicas: + description: |- + unavailableReplicas is the total number of unavailable machines targeted by this control plane. + This is the total number of machines that are still required for + the deployment to have 100% available capacity. They may either + be machines that are running but not yet ready or machines + that still have not been created. + + Deprecated: This field 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. + format: int32 + type: integer + updatedReplicas: + description: |- + updatedReplicas is the total number of non-terminated machines targeted by this control plane + that have the desired template spec. + + Deprecated: This field 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. + format: int32 + type: integer + type: object + type: object initialized: description: |- initialized denotes that the KubeadmControlPlane API Server is initialized and thus @@ -7355,8 +7465,9 @@ spec: to check the operational state of the control plane. type: boolean readyReplicas: - description: readyReplicas is the total number of fully running and - ready control plane machines. + description: readyReplicas is the number of ready replicas for this + KubeadmControlPlane. A machine is considered ready when Machine's + Ready condition is true. format: int32 type: integer replicas: @@ -7375,111 +7486,12 @@ spec: maxLength: 4096 minLength: 1 type: string - unavailableReplicas: - description: |- - unavailableReplicas is the total number of unavailable machines targeted by this control plane. - This is the total number of machines that are still required for - the deployment to have 100% available capacity. They may either - be machines that are running but not yet ready or machines - that still have not been created. - - Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. - format: int32 - type: integer - updatedReplicas: - description: |- - updatedReplicas is the total number of non-terminated machines targeted by this control plane - that have the desired template spec. + upToDateReplicas: + description: upToDateReplicas is the number of up-to-date replicas + targeted by this KubeadmControlPlane. A machine is considered up-to-date + when Machine's UpToDate condition is true. format: int32 type: integer - v1beta2: - description: v1beta2 groups all the fields that will be added or modified - in KubeadmControlPlane's status with the V1Beta2 version. - properties: - availableReplicas: - description: availableReplicas is the number of available replicas - targeted by this KubeadmControlPlane. A machine is considered - available when Machine's Available condition is true. - format: int32 - type: integer - conditions: - description: |- - conditions represents the observations of a KubeadmControlPlane's current state. - Known condition types are Available, CertificatesAvailable, EtcdClusterAvailable, MachinesReady, MachinesUpToDate, - ScalingUp, ScalingDown, Remediating, Deleting, Paused. - items: - description: Condition contains details for one aspect of the - current state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, - Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - maxItems: 32 - type: array - x-kubernetes-list-map-keys: - - type - x-kubernetes-list-type: map - readyReplicas: - description: readyReplicas is the number of ready replicas for - this KubeadmControlPlane. A machine is considered ready when - Machine's Ready condition is true. - format: int32 - type: integer - upToDateReplicas: - description: upToDateReplicas is the number of up-to-date replicas - targeted by this KubeadmControlPlane. A machine is considered - up-to-date when Machine's UpToDate condition is true. - format: int32 - type: integer - type: object version: description: |- version represents the minimum Kubernetes version for the control plane machines From 5800a4b552244b1a31bc4ee72795837b80ef66e6 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Mon, 7 Apr 2025 15:05:52 +0200 Subject: [PATCH 04/11] Fix controllers --- .golangci.yml | 7 +- api/v1beta1/conversion.go | 4 +- api/v1beta1/conversion_test.go | 142 ---- .../kubeadm/internal/builder/builders.go | 12 +- cmd/clusterctl/client/cluster/mover_test.go | 40 +- cmd/clusterctl/client/tree/tree_test.go | 50 +- .../kubeadm/internal/control_plane_test.go | 34 +- .../internal/controllers/controller_test.go | 52 +- .../internal/controllers/scale_test.go | 82 +- .../kubeadm/internal/controllers/status.go | 28 +- .../internal/controllers/status_test.go | 392 +++++----- .../workload_cluster_conditions_test.go | 13 +- .../machinepool_controller_noderef.go | 21 +- .../machinepool_controller_phases.go | 51 +- .../machinepool_controller_phases_test.go | 50 +- .../machinepool_controller_test.go | 52 +- .../desiredstate/desired_state_test.go | 18 +- .../cluster/cluster_controller_phases.go | 22 +- .../cluster/cluster_controller_phases_test.go | 12 +- .../cluster/cluster_controller_status.go | 92 +-- .../cluster/cluster_controller_status_test.go | 738 ++++++++---------- .../machine/machine_controller_phases.go | 26 +- .../machine/machine_controller_phases_test.go | 12 +- .../machine/machine_controller_status.go | 2 +- .../machine/machine_controller_status_test.go | 482 ++++++------ .../machine/machine_controller_test.go | 21 +- .../machinedeployment_rolling.go | 14 +- .../machinedeployment_rolling_test.go | 38 +- .../machinedeployment_status.go | 16 +- .../machinedeployment_status_test.go | 55 +- .../machinedeployment_sync.go | 45 +- .../machinedeployment_sync_test.go | 192 +++-- .../machinedeployment/mdutil/util.go | 45 +- .../machinedeployment/mdutil/util_test.go | 16 +- .../machinehealthcheck_controller_test.go | 560 +++++++------ .../machinehealthcheck_status_matcher_test.go | 10 +- .../machinehealthcheck_targets.go | 12 +- .../machinehealthcheck_targets_test.go | 12 +- .../machineset/machineset_controller.go | 43 +- .../machineset_controller_status.go | 10 +- .../machineset_controller_status_test.go | 82 +- .../machineset/machineset_controller_test.go | 472 +++++------ .../machineset/machineset_delete_policy.go | 2 +- .../machineset_delete_policy_test.go | 183 +++-- .../topology/cluster/cluster_controller.go | 8 - .../topology/cluster/conditions_test.go | 208 +++-- .../topology/cluster/reconcile_state_test.go | 48 +- internal/util/tree/tree.go | 76 +- test/framework/control_plane.go | 7 +- test/framework/controlplane_helpers.go | 12 +- test/framework/machinedeployment_helpers.go | 6 +- test/framework/machinepool_helpers.go | 7 +- util/collections/machine_filters_test.go | 87 ++- util/conditions/patch_test.go | 15 +- util/conditions/unstructured_test.go | 18 +- util/patch/patch_test.go | 12 +- util/test/builder/builders.go | 9 +- 57 files changed, 2561 insertions(+), 2214 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3e4c5d1f7837..ba99dc864290 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -273,13 +273,10 @@ issues: - linters: - staticcheck text: "SA1019: (mhc|m)(.Spec.MaxUnhealthy|.Spec.UnhealthyRange) is deprecated" - # Deprecations for FailureMessage, FailureReason, UnavailableReplicas and FullyLabeledReplicas + # v1Beta1 deprecated fields - linters: - staticcheck - text: "SA1019: .*\\.Status\\.(FailureMessage|FailureReason|UnavailableReplicas|FullyLabeledReplicas) is deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details." - - linters: - - staticcheck - text: "SA1019: newStatus.FullyLabeledReplicas is deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details." + text: "SA1019: .*\\.Deprecated\\.V1Beta1.* is deprecated" # Specific exclude rules for deprecated packages that are still part of the codebase. These # should be removed as the referenced deprecated packages are removed from the project. - linters: diff --git a/api/v1beta1/conversion.go b/api/v1beta1/conversion.go index da3d60f0c82f..d3c4b5584708 100644 --- a/api/v1beta1/conversion.go +++ b/api/v1beta1/conversion.go @@ -519,14 +519,14 @@ func Convert_v1beta1_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, o func Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(in *clusterv1.Conditions, out *Conditions) { *out = make(Conditions, len(*in)) for i := range *in { - (*out)[i] = *(*Condition)(unsafe.Pointer(&(*in)[i])) + (*out)[i] = *(*Condition)(unsafe.Pointer(&(*in)[i])) //nolint:gosec } } func Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(in *Conditions, out *clusterv1.Conditions) { *out = make(clusterv1.Conditions, len(*in)) for i := range *in { - (*out)[i] = *(*clusterv1.Condition)(unsafe.Pointer(&(*in)[i])) + (*out)[i] = *(*clusterv1.Condition)(unsafe.Pointer(&(*in)[i])) //nolint:gosec } } diff --git a/api/v1beta1/conversion_test.go b/api/v1beta1/conversion_test.go index 6693656ed1c6..d692e2c20f4b 100644 --- a/api/v1beta1/conversion_test.go +++ b/api/v1beta1/conversion_test.go @@ -22,11 +22,9 @@ import ( "strconv" "testing" - "github.com/google/go-cmp/cmp" fuzz "github.com/google/gofuzz" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/apitesting/fuzzer" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/utils/ptr" @@ -320,143 +318,3 @@ func spokeMachineHealthCheckStatus(in *MachineHealthCheckStatus, c fuzz.Continue } } } - -// FIXME: remove test below - -func TestHubSpokeHubCluster(t *testing.T) { - hubBefore := &clusterv1.Cluster{ - Status: clusterv1.ClusterStatus{ - Conditions: []metav1.Condition{ - { - Type: "v1beta2 Condition", - }, - }, - Deprecated: &clusterv1.ClusterDeprecatedStatus{ - V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ - Conditions: []clusterv1.Condition{ - { - Type: "v1beta1 Condition", - }, - }, - }, - }, - }, - } - - spoke := &Cluster{} - spoke.ConvertFrom(hubBefore) - hubAfter := &clusterv1.Cluster{} - spoke.ConvertTo(hubAfter) - - hubAfter.Annotations = nil - - if d := cmp.Diff(hubBefore, hubAfter); d != "" { - t.Errorf("-want, +got:\n%s", d) - } -} - -func TestSpokeHubSpokeCluster(t *testing.T) { - spokeBefore := &Cluster{ - Status: ClusterStatus{ - Conditions: []Condition{ - { - Type: "v1beta1 Condition", - }, - }, - V1Beta2: &ClusterV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: "v1beta2 Condition", - }, - }, - }, - }, - } - - hub := &clusterv1.Cluster{} - spokeBefore.ConvertTo(hub) - spokeAfter := &Cluster{} - spokeAfter.ConvertFrom(hub) - - spokeAfter.Annotations = nil - - if d := cmp.Diff(spokeBefore, spokeAfter); d != "" { - t.Errorf("-want, +got:\n%s", d) - } -} - -func TestHubSpokeHubMachineDeployment(t *testing.T) { - hubBefore := &clusterv1.MachineDeployment{ - Status: clusterv1.MachineDeploymentStatus{ - Conditions: []metav1.Condition{ - { - Type: "v1beta2 Condition", - }, - }, - ReadyReplicas: ptr.To[int32](11), - AvailableReplicas: ptr.To[int32](12), - UpToDateReplicas: ptr.To[int32](13), - Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ - V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ - Conditions: []clusterv1.Condition{ - { - Type: "v1beta1 Condition", - }, - }, - UpdatedReplicas: 1, - ReadyReplicas: 2, - AvailableReplicas: 3, - UnavailableReplicas: 4, - }, - }, - }, - } - - spoke := &MachineDeployment{} - spoke.ConvertFrom(hubBefore) - hubAfter := &clusterv1.MachineDeployment{} - spoke.ConvertTo(hubAfter) - - hubAfter.Annotations = nil - - if d := cmp.Diff(hubBefore, hubAfter); d != "" { - t.Errorf("-want, +got:\n%s", d) - } -} - -func TestSpokeHubSpokeMachineDeployment(t *testing.T) { - spokeBefore := &MachineDeployment{ - Status: MachineDeploymentStatus{ - Conditions: []Condition{ - { - Type: "v1beta1 Condition", - }, - }, - UpdatedReplicas: 1, - ReadyReplicas: 2, - AvailableReplicas: 3, - UnavailableReplicas: 4, - V1Beta2: &MachineDeploymentV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: "v1beta2 Condition", - }, - }, - ReadyReplicas: ptr.To[int32](11), - AvailableReplicas: ptr.To[int32](12), - UpToDateReplicas: ptr.To[int32](13), - }, - }, - } - - hub := &clusterv1.MachineDeployment{} - spokeBefore.ConvertTo(hub) - spokeAfter := &MachineDeployment{} - spokeAfter.ConvertFrom(hub) - - spokeAfter.Annotations = nil - - if d := cmp.Diff(spokeBefore, spokeAfter); d != "" { - t.Errorf("-want, +got:\n%s", d) - } -} diff --git a/bootstrap/kubeadm/internal/builder/builders.go b/bootstrap/kubeadm/internal/builder/builders.go index 3be42941cf8f..2fc40e903532 100644 --- a/bootstrap/kubeadm/internal/builder/builders.go +++ b/bootstrap/kubeadm/internal/builder/builders.go @@ -82,13 +82,11 @@ func (k *KubeadmConfigBuilder) Build() *bootstrapv1.KubeadmConfig { Name: k.name, }, Status: bootstrapv1.KubeadmConfigStatus{ - V1Beta2: &bootstrapv1.KubeadmConfigV1Beta2Status{ - Conditions: []metav1.Condition{{ - Type: clusterv1.PausedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.NotPausedV1Beta2Reason, - }}, - }, + Conditions: []metav1.Condition{{ + Type: clusterv1.PausedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.NotPausedV1Beta2Reason, + }}, }, } if k.initConfig != nil { diff --git a/cmd/clusterctl/client/cluster/mover_test.go b/cmd/clusterctl/client/cluster/mover_test.go index f778755afeed..5bcdf8ee8796 100644 --- a/cmd/clusterctl/client/cluster/mover_test.go +++ b/cmd/clusterctl/client/cluster/mover_test.go @@ -1483,8 +1483,12 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) { }, Status: clusterv1.ClusterStatus{ InfrastructureReady: false, - Conditions: clusterv1.Conditions{ - *conditions.TrueCondition(clusterv1.ControlPlaneInitializedCondition), + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(clusterv1.ControlPlaneInitializedCondition), + }, + }, }, }, }, @@ -1528,8 +1532,12 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) { }, Status: clusterv1.ClusterStatus{ InfrastructureReady: true, - Conditions: clusterv1.Conditions{ - *conditions.FalseCondition(clusterv1.ControlPlaneInitializedCondition, "", clusterv1.ConditionSeverityInfo, ""), + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.FalseCondition(clusterv1.ControlPlaneInitializedCondition, "", clusterv1.ConditionSeverityInfo, ""), + }, + }, }, }, }, @@ -1555,8 +1563,12 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) { }, Status: clusterv1.ClusterStatus{ InfrastructureReady: true, - Conditions: clusterv1.Conditions{ - *conditions.TrueCondition(clusterv1.ControlPlaneInitializedCondition), + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(clusterv1.ControlPlaneInitializedCondition), + }, + }, }, ControlPlaneReady: false, }, @@ -1581,8 +1593,12 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) { }, Status: clusterv1.ClusterStatus{ InfrastructureReady: true, - Conditions: clusterv1.Conditions{ - *conditions.TrueCondition(clusterv1.ControlPlaneInitializedCondition), + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(clusterv1.ControlPlaneInitializedCondition), + }, + }, }, }, }, @@ -1627,8 +1643,12 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) { }, Status: clusterv1.ClusterStatus{ InfrastructureReady: true, - Conditions: clusterv1.Conditions{ - *conditions.TrueCondition(clusterv1.ControlPlaneInitializedCondition), + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(clusterv1.ControlPlaneInitializedCondition), + }, + }, }, }, }, diff --git a/cmd/clusterctl/client/tree/tree_test.go b/cmd/clusterctl/client/tree/tree_test.go index fdfe5efca3ad..32af74333a38 100644 --- a/cmd/clusterctl/client/tree/tree_test.go +++ b/cmd/clusterctl/client/tree/tree_test.go @@ -514,12 +514,10 @@ func Test_createV1Beta2GroupNode(t *testing.T) { Name: "my-machine", }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - {Type: clusterv1.AvailableV1Beta2Condition, Status: metav1.ConditionTrue}, - {Type: clusterv1.ReadyV1Beta2Condition, Status: metav1.ConditionTrue, LastTransitionTime: now}, - {Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionFalse}, - }, + Conditions: []metav1.Condition{ + {Type: clusterv1.AvailableV1Beta2Condition, Status: metav1.ConditionTrue}, + {Type: clusterv1.ReadyV1Beta2Condition, Status: metav1.ConditionTrue, LastTransitionTime: now}, + {Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionFalse}, }, }, } @@ -533,10 +531,8 @@ func Test_createV1Beta2GroupNode(t *testing.T) { Name: "sibling-machine", }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - {Type: clusterv1.ReadyV1Beta2Condition, LastTransitionTime: beforeNow}, - }, + Conditions: []metav1.Condition{ + {Type: clusterv1.ReadyV1Beta2Condition, LastTransitionTime: beforeNow}, }, }, } @@ -599,8 +595,12 @@ func Test_createGroupNode(t *testing.T) { Name: "my-machine", }, Status: clusterv1.MachineStatus{ - Conditions: clusterv1.Conditions{ - clusterv1.Condition{Type: clusterv1.ReadyCondition, LastTransitionTime: now}, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + clusterv1.Condition{Type: clusterv1.ReadyCondition, LastTransitionTime: now}, + }, + }, }, }, } @@ -614,8 +614,12 @@ func Test_createGroupNode(t *testing.T) { Name: "sibling-machine", }, Status: clusterv1.MachineStatus{ - Conditions: clusterv1.Conditions{ - clusterv1.Condition{Type: clusterv1.ReadyCondition, LastTransitionTime: beforeNow}, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + clusterv1.Condition{Type: clusterv1.ReadyCondition, LastTransitionTime: beforeNow}, + }, + }, }, }, } @@ -698,12 +702,10 @@ func Test_updateV1Beta2GroupNode(t *testing.T) { Name: "another-machine", }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - {Type: clusterv1.AvailableV1Beta2Condition, Status: metav1.ConditionTrue}, - {Type: clusterv1.ReadyV1Beta2Condition, Status: metav1.ConditionTrue, LastTransitionTime: now}, - {Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionFalse}, - }, + Conditions: []metav1.Condition{ + {Type: clusterv1.AvailableV1Beta2Condition, Status: metav1.ConditionTrue}, + {Type: clusterv1.ReadyV1Beta2Condition, Status: metav1.ConditionTrue, LastTransitionTime: now}, + {Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionFalse}, }, }, } @@ -782,8 +784,12 @@ func Test_updateGroupNode(t *testing.T) { Name: "another-machine", }, Status: clusterv1.MachineStatus{ - Conditions: clusterv1.Conditions{ - clusterv1.Condition{Type: clusterv1.ReadyCondition, LastTransitionTime: now}, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + clusterv1.Condition{Type: clusterv1.ReadyCondition, LastTransitionTime: now}, + }, + }, }, }, } diff --git a/controlplane/kubeadm/internal/control_plane_test.go b/controlplane/kubeadm/internal/control_plane_test.go index 53f3a3b0d8e2..d255806b8111 100644 --- a/controlplane/kubeadm/internal/control_plane_test.go +++ b/controlplane/kubeadm/internal/control_plane_test.go @@ -260,12 +260,16 @@ func TestStatusToLogKeyAndValues(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "healthy"}, Status: clusterv1.MachineStatus{ NodeRef: &corev1.ObjectReference{Name: "healthy-node"}, - Conditions: []clusterv1.Condition{ - {Type: controlplanev1.MachineAPIServerPodHealthyCondition, Status: corev1.ConditionTrue}, - {Type: controlplanev1.MachineControllerManagerPodHealthyCondition, Status: corev1.ConditionTrue}, - {Type: controlplanev1.MachineSchedulerPodHealthyCondition, Status: corev1.ConditionTrue}, - {Type: controlplanev1.MachineEtcdPodHealthyCondition, Status: corev1.ConditionTrue}, - {Type: controlplanev1.MachineEtcdMemberHealthyCondition, Status: corev1.ConditionTrue}, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + {Type: controlplanev1.MachineAPIServerPodHealthyCondition, Status: corev1.ConditionTrue}, + {Type: controlplanev1.MachineControllerManagerPodHealthyCondition, Status: corev1.ConditionTrue}, + {Type: controlplanev1.MachineSchedulerPodHealthyCondition, Status: corev1.ConditionTrue}, + {Type: controlplanev1.MachineEtcdPodHealthyCondition, Status: corev1.ConditionTrue}, + {Type: controlplanev1.MachineEtcdMemberHealthyCondition, Status: corev1.ConditionTrue}, + }, + }, }, }, } @@ -274,12 +278,16 @@ func TestStatusToLogKeyAndValues(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "without-node"}, Status: clusterv1.MachineStatus{ NodeRef: nil, - Conditions: []clusterv1.Condition{ - {Type: controlplanev1.MachineAPIServerPodHealthyCondition, Status: corev1.ConditionUnknown}, - {Type: controlplanev1.MachineControllerManagerPodHealthyCondition, Status: corev1.ConditionUnknown}, - {Type: controlplanev1.MachineSchedulerPodHealthyCondition, Status: corev1.ConditionUnknown}, - {Type: controlplanev1.MachineEtcdPodHealthyCondition, Status: corev1.ConditionUnknown}, - {Type: controlplanev1.MachineEtcdMemberHealthyCondition, Status: corev1.ConditionFalse}, // not a real use case, but used to test a code branch. + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + {Type: controlplanev1.MachineAPIServerPodHealthyCondition, Status: corev1.ConditionUnknown}, + {Type: controlplanev1.MachineControllerManagerPodHealthyCondition, Status: corev1.ConditionUnknown}, + {Type: controlplanev1.MachineSchedulerPodHealthyCondition, Status: corev1.ConditionUnknown}, + {Type: controlplanev1.MachineEtcdPodHealthyCondition, Status: corev1.ConditionUnknown}, + {Type: controlplanev1.MachineEtcdMemberHealthyCondition, Status: corev1.ConditionFalse}, // not a real use case, but used to test a code branch. + }, + }, }, }, } @@ -294,7 +302,7 @@ func TestStatusToLogKeyAndValues(t *testing.T) { machineMarkedForRemediation := healthyMachine.DeepCopy() machineMarkedForRemediation.Name = "marked-for-remediation" - machineMarkedForRemediation.Status.Conditions = append(machineMarkedForRemediation.Status.Conditions, + machineMarkedForRemediation.Status.Deprecated.V1Beta1.Conditions = append(machineMarkedForRemediation.Status.Deprecated.V1Beta1.Conditions, clusterv1.Condition{Type: clusterv1.MachineHealthCheckSucceededCondition, Status: corev1.ConditionFalse}, clusterv1.Condition{Type: clusterv1.MachineOwnerRemediatedCondition, Status: corev1.ConditionFalse}, ) diff --git a/controlplane/kubeadm/internal/controllers/controller_test.go b/controlplane/kubeadm/internal/controllers/controller_test.go index 78268d10c6a2..5630aaf3757f 100644 --- a/controlplane/kubeadm/internal/controllers/controller_test.go +++ b/controlplane/kubeadm/internal/controllers/controller_test.go @@ -448,11 +448,11 @@ func TestReconcileClusterNoEndpoints(t *testing.T) { }, }, Status: controlplanev1.KubeadmControlPlaneStatus{ - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, } webhook := &controlplanev1webhooks.KubeadmControlPlane{} @@ -2126,20 +2126,22 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition }, Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - Conditions: clusterv1.Conditions{ - {Type: controlplanev1.AvailableCondition, Status: corev1.ConditionTrue, - LastTransitionTime: metav1.Time{Time: now.Add(-5 * time.Second)}}, - }, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: controlplanev1.KubeadmControlPlaneInitializedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: controlplanev1.KubeadmControlPlaneInitializedV1Beta2Reason, - LastTransitionTime: metav1.Time{Time: now.Add(-5 * time.Second)}, + Deprecated: &controlplanev1.KubeadmControlPlaneDeprecatedStatus{ + V1Beta1: &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + {Type: controlplanev1.AvailableCondition, Status: corev1.ConditionTrue, + LastTransitionTime: metav1.Time{Time: now.Add(-5 * time.Second)}}, }, }, }, + Conditions: []metav1.Condition{ + { + Type: controlplanev1.KubeadmControlPlaneInitializedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: controlplanev1.KubeadmControlPlaneInitializedV1Beta2Reason, + LastTransitionTime: metav1.Time{Time: now.Add(-5 * time.Second)}, + }, + }, }, } @@ -2388,14 +2390,14 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition Cluster: defaultCluster, KCP: func() *controlplanev1.KubeadmControlPlane { kcp := defaultKCP.DeepCopy() - for i, condition := range kcp.Status.Conditions { + for i, condition := range kcp.Status.Deprecated.V1Beta1.Conditions { if condition.Type == controlplanev1.AvailableCondition { - kcp.Status.Conditions[i].LastTransitionTime.Time = now.Add(-4 * time.Minute) + kcp.Status.Deprecated.V1Beta1.Conditions[i].LastTransitionTime.Time = now.Add(-4 * time.Minute) } } - for i, condition := range kcp.Status.V1Beta2.Conditions { + for i, condition := range kcp.Status.Conditions { if condition.Type == controlplanev1.KubeadmControlPlaneInitializedV1Beta2Condition { - kcp.Status.V1Beta2.Conditions[i].LastTransitionTime.Time = now.Add(-4 * time.Minute) + kcp.Status.Conditions[i].LastTransitionTime.Time = now.Add(-4 * time.Minute) } } v1beta2conditions.Set(kcp, metav1.Condition{ @@ -2476,14 +2478,14 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition Cluster: defaultCluster, KCP: func() *controlplanev1.KubeadmControlPlane { kcp := defaultKCP.DeepCopy() - for i, condition := range kcp.Status.Conditions { + for i, condition := range kcp.Status.Deprecated.V1Beta1.Conditions { if condition.Type == controlplanev1.AvailableCondition { - kcp.Status.Conditions[i].LastTransitionTime.Time = now.Add(-4 * time.Minute) + kcp.Status.Deprecated.V1Beta1.Conditions[i].LastTransitionTime.Time = now.Add(-4 * time.Minute) } } - for i, condition := range kcp.Status.V1Beta2.Conditions { + for i, condition := range kcp.Status.Conditions { if condition.Type == controlplanev1.KubeadmControlPlaneInitializedV1Beta2Condition { - kcp.Status.V1Beta2.Conditions[i].LastTransitionTime.Time = now.Add(-4 * time.Minute) + kcp.Status.Conditions[i].LastTransitionTime.Time = now.Add(-4 * time.Minute) } } return kcp @@ -2565,14 +2567,14 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition Cluster: defaultCluster, KCP: func() *controlplanev1.KubeadmControlPlane { kcp := defaultKCP.DeepCopy() - for i, condition := range kcp.Status.Conditions { + for i, condition := range kcp.Status.Deprecated.V1Beta1.Conditions { if condition.Type == controlplanev1.AvailableCondition { - kcp.Status.Conditions[i].LastTransitionTime.Time = now.Add(-7 * time.Minute) + kcp.Status.Deprecated.V1Beta1.Conditions[i].LastTransitionTime.Time = now.Add(-7 * time.Minute) } } - for i, condition := range kcp.Status.V1Beta2.Conditions { + for i, condition := range kcp.Status.Conditions { if condition.Type == controlplanev1.KubeadmControlPlaneInitializedV1Beta2Condition { - kcp.Status.V1Beta2.Conditions[i].LastTransitionTime.Time = now.Add(-7 * time.Minute) + kcp.Status.Conditions[i].LastTransitionTime.Time = now.Add(-7 * time.Minute) } } v1beta2conditions.Set(kcp, metav1.Condition{ diff --git a/controlplane/kubeadm/internal/controllers/scale_test.go b/controlplane/kubeadm/internal/controllers/scale_test.go index 1dde5934deaa..7cd15736ddec 100644 --- a/controlplane/kubeadm/internal/controllers/scale_test.go +++ b/controlplane/kubeadm/internal/controllers/scale_test.go @@ -611,13 +611,15 @@ func TestPreflightChecks(t *testing.T) { Kind: "Node", Name: "node-1", }, - Conditions: clusterv1.Conditions{ - *conditions.FalseCondition(controlplanev1.MachineAPIServerPodHealthyCondition, "fooReason", clusterv1.ConditionSeverityError, ""), - *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineEtcdPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineEtcdMemberHealthyCondition), - }, + Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.FalseCondition(controlplanev1.MachineAPIServerPodHealthyCondition, "fooReason", clusterv1.ConditionSeverityError, ""), + *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineEtcdPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineEtcdMemberHealthyCondition), + }, + }}, }, }, }, @@ -639,13 +641,15 @@ func TestPreflightChecks(t *testing.T) { Kind: "Node", Name: "node-1", }, - Conditions: clusterv1.Conditions{ - *conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineEtcdPodHealthyCondition), - *conditions.FalseCondition(controlplanev1.MachineEtcdMemberHealthyCondition, "fooReason", clusterv1.ConditionSeverityError, ""), - }, + Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineEtcdPodHealthyCondition), + *conditions.FalseCondition(controlplanev1.MachineEtcdMemberHealthyCondition, "fooReason", clusterv1.ConditionSeverityError, ""), + }, + }}, }, }, }, @@ -661,10 +665,12 @@ func TestPreflightChecks(t *testing.T) { name: "control plane with an healthy machine and an healthy kcp condition should pass", kcp: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ - Conditions: clusterv1.Conditions{ - *conditions.TrueCondition(controlplanev1.ControlPlaneComponentsHealthyCondition), - *conditions.TrueCondition(controlplanev1.EtcdClusterHealthyCondition), - }, + Deprecated: &controlplanev1.KubeadmControlPlaneDeprecatedStatus{V1Beta1: &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(controlplanev1.ControlPlaneComponentsHealthyCondition), + *conditions.TrueCondition(controlplanev1.EtcdClusterHealthyCondition), + }, + }}, }, }, machines: []*clusterv1.Machine{ @@ -674,13 +680,15 @@ func TestPreflightChecks(t *testing.T) { Kind: "Node", Name: "node-1", }, - Conditions: clusterv1.Conditions{ - *conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineEtcdPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineEtcdMemberHealthyCondition), - }, + Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineEtcdPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineEtcdMemberHealthyCondition), + }, + }}, }, }, }, @@ -734,9 +742,11 @@ func TestPreflightCheckCondition(t *testing.T) { name: "false condition should return error", machine: &clusterv1.Machine{ Status: clusterv1.MachineStatus{ - Conditions: clusterv1.Conditions{ - *conditions.FalseCondition(condition, "fooReason", clusterv1.ConditionSeverityError, ""), - }, + Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.FalseCondition(condition, "fooReason", clusterv1.ConditionSeverityError, ""), + }, + }}, }, }, expectErr: true, @@ -745,9 +755,11 @@ func TestPreflightCheckCondition(t *testing.T) { name: "unknown condition should return error", machine: &clusterv1.Machine{ Status: clusterv1.MachineStatus{ - Conditions: clusterv1.Conditions{ - *conditions.UnknownCondition(condition, "fooReason", ""), - }, + Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.UnknownCondition(condition, "fooReason", ""), + }, + }}, }, }, expectErr: true, @@ -756,9 +768,11 @@ func TestPreflightCheckCondition(t *testing.T) { name: "true condition should not return error", machine: &clusterv1.Machine{ Status: clusterv1.MachineStatus{ - Conditions: clusterv1.Conditions{ - *conditions.TrueCondition(condition), - }, + Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(condition), + }, + }}, }, }, expectErr: false, diff --git a/controlplane/kubeadm/internal/controllers/status.go b/controlplane/kubeadm/internal/controllers/status.go index c6787c262320..68a52fca8104 100644 --- a/controlplane/kubeadm/internal/controllers/status.go +++ b/controlplane/kubeadm/internal/controllers/status.go @@ -48,15 +48,21 @@ func (r *KubeadmControlPlaneReconciler) updateStatus(ctx context.Context, contro controlPlane.KCP.Status.Selector = selector.String() upToDateMachines := controlPlane.UpToDateMachines() - controlPlane.KCP.Status.UpdatedReplicas = int32(len(upToDateMachines)) + if controlPlane.KCP.Status.Deprecated == nil { + controlPlane.KCP.Status.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} + } + if controlPlane.KCP.Status.Deprecated.V1Beta1 == nil { + controlPlane.KCP.Status.Deprecated.V1Beta1 = &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{} + } + controlPlane.KCP.Status.Deprecated.V1Beta1.UpdatedReplicas = int32(len(upToDateMachines)) replicas := int32(len(controlPlane.Machines)) desiredReplicas := *controlPlane.KCP.Spec.Replicas // set basic data that does not require interacting with the workload cluster controlPlane.KCP.Status.Replicas = replicas - controlPlane.KCP.Status.ReadyReplicas = 0 - controlPlane.KCP.Status.UnavailableReplicas = replicas + controlPlane.KCP.Status.Deprecated.V1Beta1.ReadyReplicas = 0 + controlPlane.KCP.Status.Deprecated.V1Beta1.UnavailableReplicas = replicas // Return early if the deletion timestamp is set, because we don't want to try to connect to the workload cluster // and we don't want to report resize condition (because it is set to deleting into reconcile delete). @@ -100,8 +106,8 @@ func (r *KubeadmControlPlaneReconciler) updateStatus(ctx context.Context, contro if err != nil { return err } - controlPlane.KCP.Status.ReadyReplicas = status.ReadyNodes - controlPlane.KCP.Status.UnavailableReplicas = replicas - status.ReadyNodes + controlPlane.KCP.Status.Deprecated.V1Beta1.ReadyReplicas = status.ReadyNodes + controlPlane.KCP.Status.Deprecated.V1Beta1.UnavailableReplicas = replicas - status.ReadyNodes // This only gets initialized once and does not change if the kubeadm config map goes away. if status.HasKubeadmConfig { @@ -109,7 +115,7 @@ func (r *KubeadmControlPlaneReconciler) updateStatus(ctx context.Context, contro conditions.MarkTrue(controlPlane.KCP, controlplanev1.AvailableCondition) } - if controlPlane.KCP.Status.ReadyReplicas > 0 { + if controlPlane.KCP.Status.Deprecated.V1Beta1.ReadyReplicas > 0 { controlPlane.KCP.Status.Ready = true } @@ -185,13 +191,9 @@ func setReplicas(_ context.Context, kcp *controlplanev1.KubeadmControlPlane, mac } } - if kcp.Status.V1Beta2 == nil { - kcp.Status.V1Beta2 = &controlplanev1.KubeadmControlPlaneV1Beta2Status{} - } - - kcp.Status.V1Beta2.ReadyReplicas = ptr.To(readyReplicas) - kcp.Status.V1Beta2.AvailableReplicas = ptr.To(availableReplicas) - kcp.Status.V1Beta2.UpToDateReplicas = ptr.To(upToDateReplicas) + kcp.Status.ReadyReplicas = ptr.To(readyReplicas) + kcp.Status.AvailableReplicas = ptr.To(availableReplicas) + kcp.Status.UpToDateReplicas = ptr.To(upToDateReplicas) } func setInitializedCondition(_ context.Context, kcp *controlplanev1.KubeadmControlPlane) { diff --git a/controlplane/kubeadm/internal/controllers/status_test.go b/controlplane/kubeadm/internal/controllers/status_test.go index 9b2beb399847..6eac17deffe2 100644 --- a/controlplane/kubeadm/internal/controllers/status_test.go +++ b/controlplane/kubeadm/internal/controllers/status_test.go @@ -57,24 +57,24 @@ func TestSetReplicas(t *testing.T) { c := &internal.ControlPlane{ KCP: kcp, Machines: collections.FromMachines( - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{readyTrue, availableTrue, upToDateTrue}}}}, - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{readyTrue, availableTrue, upToDateTrue}}}}, - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{readyFalse, availableFalse, upToDateTrue}}}}, - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m4"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{readyTrue, availableFalse, upToDateTrue}}}}, - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m5"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{readyFalse, availableFalse, upToDateFalse}}}}, - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m6"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{readyUnknown, availableUnknown, upToDateUnknown}}}}, + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{readyTrue, availableTrue, upToDateTrue}}}, + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{readyTrue, availableTrue, upToDateTrue}}}, + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{readyFalse, availableFalse, upToDateTrue}}}, + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m4"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{readyTrue, availableFalse, upToDateTrue}}}, + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m5"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{readyFalse, availableFalse, upToDateFalse}}}, + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m6"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{readyUnknown, availableUnknown, upToDateUnknown}}}, ), } setReplicas(ctx, c.KCP, c.Machines) - g.Expect(kcp.Status.V1Beta2).ToNot(BeNil()) - g.Expect(kcp.Status.V1Beta2.ReadyReplicas).ToNot(BeNil()) - g.Expect(*kcp.Status.V1Beta2.ReadyReplicas).To(Equal(int32(3))) - g.Expect(kcp.Status.V1Beta2.AvailableReplicas).ToNot(BeNil()) - g.Expect(*kcp.Status.V1Beta2.AvailableReplicas).To(Equal(int32(2))) - g.Expect(kcp.Status.V1Beta2.UpToDateReplicas).ToNot(BeNil()) - g.Expect(*kcp.Status.V1Beta2.UpToDateReplicas).To(Equal(int32(4))) + g.Expect(kcp.Status).ToNot(BeNil()) + g.Expect(kcp.Status.ReadyReplicas).ToNot(BeNil()) + g.Expect(*kcp.Status.ReadyReplicas).To(Equal(int32(3))) + g.Expect(kcp.Status.AvailableReplicas).ToNot(BeNil()) + g.Expect(*kcp.Status.AvailableReplicas).To(Equal(int32(2))) + g.Expect(kcp.Status.UpToDateReplicas).ToNot(BeNil()) + g.Expect(*kcp.Status.UpToDateReplicas).To(Equal(int32(4))) } func Test_setInitializedCondition(t *testing.T) { @@ -148,8 +148,8 @@ func Test_setRollingOutCondition(t *testing.T) { name: "all machines are up to date", kcp: &controlplanev1.KubeadmControlPlane{}, machines: []*clusterv1.Machine{ - {ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{upToDateCondition}}}}, - {ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{upToDateCondition}}}}, + {ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{upToDateCondition}}}, + {ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{upToDateCondition}}}, }, expectCondition: metav1.Condition{ Type: controlplanev1.KubeadmControlPlaneRollingOutV1Beta2Condition, @@ -161,15 +161,15 @@ func Test_setRollingOutCondition(t *testing.T) { name: "one up-to-date, two not up-to-date, one reporting up-to-date unknown", kcp: &controlplanev1.KubeadmControlPlane{}, machines: []*clusterv1.Machine{ - {ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{upToDateCondition}}}}, - {ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{ + {ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{upToDateCondition}}}, + {ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{ { Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionUnknown, Reason: clusterv1.InternalErrorV1Beta2Reason, }, - }}}}, - {ObjectMeta: metav1.ObjectMeta{Name: "m4"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{ + }}}, + {ObjectMeta: metav1.ObjectMeta{Name: "m4"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{ { Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionFalse, @@ -177,15 +177,15 @@ func Test_setRollingOutCondition(t *testing.T) { Message: "* Failure domain failure-domain1, failure-domain2 required\n" + "* InfrastructureMachine is not up-to-date", }, - }}}}, - {ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{ + }}}, + {ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{ { Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.MachineNotUpToDateV1Beta2Reason, Message: "* Version v1.25.0, v1.26.0 required", }, - }}}}, + }}}, }, expectCondition: metav1.Condition{ Type: controlplanev1.KubeadmControlPlaneRollingOutV1Beta2Condition, @@ -478,19 +478,17 @@ func Test_setScalingDownCondition(t *testing.T) { Machines: collections.FromMachines( &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1", DeletionTimestamp: ptr.To(metav1.Time{Time: time.Now().Add(-1 * time.Hour)})}, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineDeletingDrainingNodeV1Beta2Reason, - Message: `Drain not completed yet (started at 2024-10-09T16:13:59Z): + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineDeletingDrainingNodeV1Beta2Reason, + Message: `Drain not completed yet (started at 2024-10-09T16:13:59Z): * Pods pod-2-deletionTimestamp-set-1, pod-3-to-trigger-eviction-successfully-1: deletionTimestamp set, but still not removed from the Node * Pod pod-5-to-trigger-eviction-pdb-violated-1: cannot evict pod as it would violate the pod's disruption budget. The disruption budget pod-5-pdb needs 20 healthy pods and has 20 currently * Pod pod-6-to-trigger-eviction-some-other-error: failed to evict Pod, some other error 1 * Pod pod-9-wait-completed: waiting for completion After above Pods have been removed from the Node, the following Pods will be evicted: pod-7-eviction-later, pod-8-eviction-later`, - }, }, }, Deletion: &clusterv1.MachineDeletionStatus{ @@ -617,11 +615,11 @@ func Test_setMachinesReadyAndMachinesUpToDateConditions(t *testing.T) { controlPlane: &internal.ControlPlane{ KCP: &controlplanev1.KubeadmControlPlane{}, Machines: collections.FromMachines( - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{readyTrue, upToDateTrue}}}}, - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{readyTrue, upToDateFalse}}}}, - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{readyFalse, upToDateFalse}}}}, - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m4"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{readyFalse}}}}, // Machine without UpToDate condition - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m5", CreationTimestamp: metav1.Time{Time: time.Now().Add(-5 * time.Second)}}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{readyFalse}}}}, // New Machine without UpToDate condition (should be ignored) + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{readyTrue, upToDateTrue}}}, + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{readyTrue, upToDateFalse}}}, + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{readyFalse, upToDateFalse}}}, + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m4"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{readyFalse}}}, // Machine without UpToDate condition + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m5", CreationTimestamp: metav1.Time{Time: time.Now().Add(-5 * time.Second)}}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{readyFalse}}}, // New Machine without UpToDate condition (should be ignored) ), }, expectMachinesReadyCondition: metav1.Condition{ @@ -688,9 +686,9 @@ func Test_setRemediatingCondition(t *testing.T) { controlPlane: &internal.ControlPlane{ KCP: &controlplanev1.KubeadmControlPlane{}, Machines: collections.FromMachines( - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Conditions: clusterv1.Conditions{healthCheckSucceeded}}}, // Healthy machine - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{Conditions: clusterv1.Conditions{healthCheckNotSucceeded}}}, // Unhealthy machine, not yet marked for remediation - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Status: clusterv1.MachineStatus{Conditions: clusterv1.Conditions{healthCheckNotSucceeded, ownerRemediated}, V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{ownerRemediatedV1Beta2}}}}, + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{Conditions: clusterv1.Conditions{healthCheckSucceeded}}}}}, // Healthy machine + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{Conditions: clusterv1.Conditions{healthCheckNotSucceeded}}}}}, // Unhealthy machine, not yet marked for remediation + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Status: clusterv1.MachineStatus{Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{Conditions: clusterv1.Conditions{healthCheckNotSucceeded, ownerRemediated}}}, Conditions: []metav1.Condition{ownerRemediatedV1Beta2}}}, ), }, expectCondition: metav1.Condition{ @@ -705,9 +703,9 @@ func Test_setRemediatingCondition(t *testing.T) { controlPlane: &internal.ControlPlane{ KCP: &controlplanev1.KubeadmControlPlane{}, Machines: collections.FromMachines( - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Conditions: clusterv1.Conditions{healthCheckSucceeded}}}, // Healthy machine - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{Conditions: clusterv1.Conditions{healthCheckNotSucceeded}}}, // Unhealthy machine, not yet marked for remediation - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Status: clusterv1.MachineStatus{Conditions: clusterv1.Conditions{healthCheckSucceeded}}}, // Healthy machine + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{Conditions: clusterv1.Conditions{healthCheckSucceeded}}}}}, // Healthy machine + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{Conditions: clusterv1.Conditions{healthCheckNotSucceeded}}}}}, // Unhealthy machine, not yet marked for remediation + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Status: clusterv1.MachineStatus{Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{Conditions: clusterv1.Conditions{healthCheckSucceeded}}}}}, // Healthy machine ), }, expectCondition: metav1.Condition{ @@ -722,9 +720,9 @@ func Test_setRemediatingCondition(t *testing.T) { controlPlane: &internal.ControlPlane{ KCP: &controlplanev1.KubeadmControlPlane{}, Machines: collections.FromMachines( - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Conditions: clusterv1.Conditions{healthCheckNotSucceeded}}}, // Unhealthy machine, not yet marked for remediation - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{Conditions: clusterv1.Conditions{healthCheckNotSucceeded}}}, // Unhealthy machine, not yet marked for remediation - &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Status: clusterv1.MachineStatus{Conditions: clusterv1.Conditions{healthCheckSucceeded}}}, // Healthy machine + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{Conditions: clusterv1.Conditions{healthCheckNotSucceeded}}}}}, // Unhealthy machine, not yet marked for remediation + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{Conditions: clusterv1.Conditions{healthCheckNotSucceeded}}}}}, // Unhealthy machine, not yet marked for remediation + &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Status: clusterv1.MachineStatus{Deprecated: &clusterv1.MachineDeprecatedStatus{V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{Conditions: clusterv1.Conditions{healthCheckSucceeded}}}}}, // Healthy machine ), }, expectCondition: metav1.Condition{ @@ -822,17 +820,17 @@ func Test_shouldSurfaceWhenAvailableTrue(t *testing.T) { }{ { name: "Machine doesn't have issues, it should not surface", - machine: &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, etcdMemberHealthy}}}}, + machine: &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{apiServerPodHealthy, etcdMemberHealthy}}}, want: false, }, { name: "Machine has issue set by less than 10s it should not surface", - machine: &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodNotHealthy, etcdMemberNotHealthy}}}}, + machine: &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{apiServerPodNotHealthy, etcdMemberNotHealthy}}}, want: false, }, { name: "Machine has at least one issue set by more than 10s it should surface", - machine: &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodNotHealthy11s, etcdMemberNotHealthy}}}}, + machine: &clusterv1.Machine{ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{apiServerPodNotHealthy11s, etcdMemberNotHealthy}}}, want: true, }, } @@ -907,9 +905,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -917,8 +913,8 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, ), @@ -939,9 +935,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -949,24 +943,24 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m2"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m2"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m3"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m3"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, ), @@ -999,10 +993,8 @@ func Test_setAvailableCondition(t *testing.T) { }, Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{ - {Type: controlplanev1.KubeadmControlPlaneInitializedV1Beta2Condition, Status: metav1.ConditionTrue, Reason: controlplanev1.KubeadmControlPlaneInitializedV1Beta2Reason, LastTransitionTime: metav1.Time{Time: reconcileTime.Add(-5 * time.Second)}}, - }, + Conditions: []metav1.Condition{ + {Type: controlplanev1.KubeadmControlPlaneInitializedV1Beta2Condition, Status: metav1.ConditionTrue, Reason: controlplanev1.KubeadmControlPlaneInitializedV1Beta2Reason, LastTransitionTime: metav1.Time{Time: reconcileTime.Add(-5 * time.Second)}}, }, }, }, @@ -1028,10 +1020,8 @@ func Test_setAvailableCondition(t *testing.T) { }, Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{ - {Type: controlplanev1.KubeadmControlPlaneInitializedV1Beta2Condition, Status: metav1.ConditionTrue, Reason: controlplanev1.KubeadmControlPlaneInitializedV1Beta2Reason, LastTransitionTime: metav1.Time{Time: reconcileTime.Add(-5 * time.Minute)}}, - }, + Conditions: []metav1.Condition{ + {Type: controlplanev1.KubeadmControlPlaneInitializedV1Beta2Condition, Status: metav1.ConditionTrue, Reason: controlplanev1.KubeadmControlPlaneInitializedV1Beta2Reason, LastTransitionTime: metav1.Time{Time: reconcileTime.Add(-5 * time.Minute)}}, }, }, }, @@ -1074,9 +1064,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -1084,24 +1072,24 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m2"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m2"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m3"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m3"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy}, }, }, ), @@ -1124,9 +1112,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -1134,24 +1120,24 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m2"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m2"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m3"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy11s}}, + NodeRef: &corev1.ObjectReference{Name: "m3"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy11s}, }, }, ), @@ -1176,9 +1162,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -1186,24 +1170,24 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m2"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m2"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m3"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m3"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy}, }, }, ), @@ -1227,9 +1211,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -1237,15 +1219,15 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m2"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthyUnknown, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m2"}, + Conditions: []metav1.Condition{apiServerPodHealthyUnknown, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, ), @@ -1267,9 +1249,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -1277,32 +1257,32 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m2"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m2"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m3"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy11s}}, + NodeRef: &corev1.ObjectReference{Name: "m3"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy11s}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m4"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m4")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m4"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy11s}}, + NodeRef: &corev1.ObjectReference{Name: "m4"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy11s}, }, }, ), @@ -1328,9 +1308,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -1338,24 +1316,24 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m2"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m2"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m3"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy11s}}, + NodeRef: &corev1.ObjectReference{Name: "m3"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy11s}, }, }, &clusterv1.Machine{ @@ -1365,7 +1343,7 @@ func Test_setAvailableCondition(t *testing.T) { NodeRef: nil, // Note this is not a real use case, but it helps to validate that machine m4 is bound to an etcd member and counted as healthy. // If instead we use unknown or false conditions, it would not be possible to understand if the best effort binding happened or the etcd member was considered unhealthy because without a machine match. - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, ), @@ -1391,9 +1369,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -1401,32 +1377,32 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m2"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m2"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m3"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m3"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m4"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m4")}, Status: clusterv1.MachineStatus{ - NodeRef: nil, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthyUnknown, controllerManagerPodHealthyUnknown, schedulerPodHealthyUnknown, etcdPodHealthyUnknown, etcdMemberHealthyUnknown11s}}, + NodeRef: nil, + Conditions: []metav1.Condition{apiServerPodHealthyUnknown, controllerManagerPodHealthyUnknown, schedulerPodHealthyUnknown, etcdPodHealthyUnknown, etcdMemberHealthyUnknown11s}, }, }, ), @@ -1452,9 +1428,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -1462,24 +1436,24 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m2"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m2"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m3-does-not-exist"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m3-does-not-exist"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, ), @@ -1503,9 +1477,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -1513,32 +1485,32 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m2"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m2"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m3"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy11s}}, + NodeRef: &corev1.ObjectReference{Name: "m3"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy11s}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m4"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m4")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m4"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy11s}}, + NodeRef: &corev1.ObjectReference{Name: "m4"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberNotHealthy11s}, }, }, ), @@ -1567,9 +1539,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -1577,15 +1547,15 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m2"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthyUnknown, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m2"}, + Conditions: []metav1.Condition{apiServerPodHealthyUnknown, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, ), @@ -1607,9 +1577,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -1617,24 +1585,24 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m2"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m2"}, + Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m3"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodNotHealthy11s, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m3"}, + Conditions: []metav1.Condition{apiServerPodNotHealthy11s, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, ), @@ -1658,26 +1626,24 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, - Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}}, + Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, - Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}}, + Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, - Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}}, + Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, }, ), EtcdMembers: []*etcd.Member{{}, {}, {}}, @@ -1706,26 +1672,24 @@ func Test_setAvailableCondition(t *testing.T) { }, Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, - Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy}}}, + Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy}}, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, - Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy}}}, + Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy}}, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, - Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodNotHealthy11s, controllerManagerPodHealthy, schedulerPodHealthy}}}, + Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{apiServerPodNotHealthy11s, controllerManagerPodHealthy, schedulerPodHealthy}}, }, ), EtcdMembers: nil, @@ -1751,26 +1715,24 @@ func Test_setAvailableCondition(t *testing.T) { }, Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, - Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy}}}, + Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy}}, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m2"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m2")}, - Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy}}}, + Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy}}, }, &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "m3"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m3")}, - Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy}}}, + Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{apiServerPodNotHealthy, controllerManagerPodHealthy, schedulerPodHealthy}}, }, ), EtcdMembers: nil, @@ -1792,9 +1754,7 @@ func Test_setAvailableCondition(t *testing.T) { KCP: &controlplanev1.KubeadmControlPlane{ Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesNotReady}, - }, + Conditions: []metav1.Condition{certificatesNotReady}, }, }, Machines: collections.FromMachines( @@ -1802,8 +1762,8 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, ), @@ -1831,9 +1791,7 @@ func Test_setAvailableCondition(t *testing.T) { }, Status: controlplanev1.KubeadmControlPlaneStatus{ Initialized: true, - V1Beta2: &controlplanev1.KubeadmControlPlaneV1Beta2Status{ - Conditions: []metav1.Condition{certificatesReady}, - }, + Conditions: []metav1.Condition{certificatesReady}, }, }, Machines: collections.FromMachines( @@ -1841,8 +1799,8 @@ func Test_setAvailableCondition(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "m1"}, Spec: clusterv1.MachineSpec{ProviderID: ptr.To("m1")}, Status: clusterv1.MachineStatus{ - NodeRef: &corev1.ObjectReference{Name: "m1"}, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}}, + NodeRef: &corev1.ObjectReference{Name: "m1"}, + Conditions: []metav1.Condition{apiServerPodHealthy, controllerManagerPodHealthy, schedulerPodHealthy, etcdPodHealthy, etcdMemberHealthy}, }, }, ), @@ -1924,13 +1882,13 @@ func TestKubeadmControlPlaneReconciler_updateStatusNoMachines(t *testing.T) { g.Expect(r.updateStatus(ctx, controlPlane)).To(Succeed()) g.Expect(kcp.Status.Replicas).To(BeEquivalentTo(0)) - g.Expect(kcp.Status.ReadyReplicas).To(BeEquivalentTo(0)) - g.Expect(kcp.Status.UnavailableReplicas).To(BeEquivalentTo(0)) + g.Expect(kcp.Status.Deprecated.V1Beta1.ReadyReplicas).To(BeEquivalentTo(0)) + g.Expect(kcp.Status.Deprecated.V1Beta1.UnavailableReplicas).To(BeEquivalentTo(0)) g.Expect(kcp.Status.Initialized).To(BeFalse()) g.Expect(kcp.Status.Ready).To(BeFalse()) g.Expect(kcp.Status.Selector).NotTo(BeEmpty()) - g.Expect(kcp.Status.FailureMessage).To(BeNil()) - g.Expect(kcp.Status.FailureReason).To(BeEquivalentTo("")) + g.Expect(kcp.Status.Deprecated.V1Beta1.FailureMessage).To(BeNil()) + g.Expect(kcp.Status.Deprecated.V1Beta1.FailureReason).To(BeEquivalentTo("")) } func TestKubeadmControlPlaneReconciler_updateStatusAllMachinesNotReady(t *testing.T) { @@ -1997,11 +1955,11 @@ func TestKubeadmControlPlaneReconciler_updateStatusAllMachinesNotReady(t *testin g.Expect(r.updateStatus(ctx, controlPlane)).To(Succeed()) g.Expect(kcp.Status.Replicas).To(BeEquivalentTo(3)) - g.Expect(kcp.Status.ReadyReplicas).To(BeEquivalentTo(0)) - g.Expect(kcp.Status.UnavailableReplicas).To(BeEquivalentTo(3)) + g.Expect(kcp.Status.Deprecated.V1Beta1.ReadyReplicas).To(BeEquivalentTo(0)) + g.Expect(kcp.Status.Deprecated.V1Beta1.UnavailableReplicas).To(BeEquivalentTo(3)) g.Expect(kcp.Status.Selector).NotTo(BeEmpty()) - g.Expect(kcp.Status.FailureMessage).To(BeNil()) - g.Expect(kcp.Status.FailureReason).To(BeEquivalentTo("")) + g.Expect(kcp.Status.Deprecated.V1Beta1.FailureMessage).To(BeNil()) + g.Expect(kcp.Status.Deprecated.V1Beta1.FailureReason).To(BeEquivalentTo("")) g.Expect(kcp.Status.Initialized).To(BeFalse()) g.Expect(kcp.Status.Ready).To(BeFalse()) } @@ -2076,11 +2034,11 @@ func TestKubeadmControlPlaneReconciler_updateStatusAllMachinesReady(t *testing.T g.Expect(r.updateStatus(ctx, controlPlane)).To(Succeed()) g.Expect(kcp.Status.Replicas).To(BeEquivalentTo(3)) - g.Expect(kcp.Status.ReadyReplicas).To(BeEquivalentTo(3)) - g.Expect(kcp.Status.UnavailableReplicas).To(BeEquivalentTo(0)) + g.Expect(kcp.Status.Deprecated.V1Beta1.ReadyReplicas).To(BeEquivalentTo(3)) + g.Expect(kcp.Status.Deprecated.V1Beta1.UnavailableReplicas).To(BeEquivalentTo(0)) g.Expect(kcp.Status.Selector).NotTo(BeEmpty()) - g.Expect(kcp.Status.FailureMessage).To(BeNil()) - g.Expect(kcp.Status.FailureReason).To(BeEquivalentTo("")) + g.Expect(kcp.Status.Deprecated.V1Beta1.FailureMessage).To(BeNil()) + g.Expect(kcp.Status.Deprecated.V1Beta1.FailureReason).To(BeEquivalentTo("")) g.Expect(kcp.Status.Initialized).To(BeTrue()) g.Expect(conditions.IsTrue(kcp, controlplanev1.AvailableCondition)).To(BeTrue()) g.Expect(conditions.IsTrue(kcp, controlplanev1.MachinesCreatedCondition)).To(BeTrue()) @@ -2158,11 +2116,11 @@ func TestKubeadmControlPlaneReconciler_updateStatusMachinesReadyMixed(t *testing g.Expect(r.updateStatus(ctx, controlPlane)).To(Succeed()) g.Expect(kcp.Status.Replicas).To(BeEquivalentTo(5)) - g.Expect(kcp.Status.ReadyReplicas).To(BeEquivalentTo(1)) - g.Expect(kcp.Status.UnavailableReplicas).To(BeEquivalentTo(4)) + g.Expect(kcp.Status.Deprecated.V1Beta1.ReadyReplicas).To(BeEquivalentTo(1)) + g.Expect(kcp.Status.Deprecated.V1Beta1.UnavailableReplicas).To(BeEquivalentTo(4)) g.Expect(kcp.Status.Selector).NotTo(BeEmpty()) - g.Expect(kcp.Status.FailureMessage).To(BeNil()) - g.Expect(kcp.Status.FailureReason).To(BeEquivalentTo("")) + g.Expect(kcp.Status.Deprecated.V1Beta1.FailureMessage).To(BeNil()) + g.Expect(kcp.Status.Deprecated.V1Beta1.FailureReason).To(BeEquivalentTo("")) g.Expect(kcp.Status.Initialized).To(BeTrue()) g.Expect(kcp.Status.Ready).To(BeTrue()) } @@ -2239,8 +2197,8 @@ func TestKubeadmControlPlaneReconciler_machinesCreatedIsIsTrueEvenWhenTheNodesAr g.Expect(r.updateStatus(ctx, controlPlane)).To(Succeed()) g.Expect(kcp.Status.Replicas).To(BeEquivalentTo(3)) - g.Expect(kcp.Status.ReadyReplicas).To(BeEquivalentTo(0)) - g.Expect(kcp.Status.UnavailableReplicas).To(BeEquivalentTo(3)) + g.Expect(kcp.Status.Deprecated.V1Beta1.ReadyReplicas).To(BeEquivalentTo(0)) + g.Expect(kcp.Status.Deprecated.V1Beta1.UnavailableReplicas).To(BeEquivalentTo(3)) g.Expect(kcp.Status.Ready).To(BeFalse()) g.Expect(conditions.IsTrue(kcp, controlplanev1.MachinesCreatedCondition)).To(BeTrue()) } diff --git a/controlplane/kubeadm/internal/workload_cluster_conditions_test.go b/controlplane/kubeadm/internal/workload_cluster_conditions_test.go index 7a04610d41b1..59b889cb6d67 100644 --- a/controlplane/kubeadm/internal/workload_cluster_conditions_test.go +++ b/controlplane/kubeadm/internal/workload_cluster_conditions_test.go @@ -1486,7 +1486,13 @@ func withProviderID(providerID string) fakeMachineOption { func withMachineReadyCondition(status corev1.ConditionStatus, severity clusterv1.ConditionSeverity) fakeMachineOption { return func(machine *clusterv1.Machine) { - machine.Status.Conditions = append(machine.Status.Conditions, clusterv1.Condition{ + if machine.Status.Deprecated == nil { + machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} + } + if machine.Status.Deprecated.V1Beta1 == nil { + machine.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + } + machine.Status.Deprecated.V1Beta1.Conditions = append(machine.Status.Deprecated.V1Beta1.Conditions, clusterv1.Condition{ Type: clusterv1.MachinesReadyCondition, Status: status, Severity: severity, @@ -1496,10 +1502,7 @@ func withMachineReadyCondition(status corev1.ConditionStatus, severity clusterv1 func withMachineReadyV1beta2Condition(status metav1.ConditionStatus) fakeMachineOption { return func(machine *clusterv1.Machine) { - if machine.Status.V1Beta2 == nil { - machine.Status.V1Beta2 = &clusterv1.MachineV1Beta2Status{} - } - machine.Status.V1Beta2.Conditions = append(machine.Status.V1Beta2.Conditions, metav1.Condition{ + machine.Status.Conditions = append(machine.Status.Conditions, metav1.Condition{ Type: clusterv1.MachineReadyV1Beta2Condition, Status: status, Reason: "SomeReason", diff --git a/exp/internal/controllers/machinepool_controller_noderef.go b/exp/internal/controllers/machinepool_controller_noderef.go index eb8d73ad9685..60cf557efcba 100644 --- a/exp/internal/controllers/machinepool_controller_noderef.go +++ b/exp/internal/controllers/machinepool_controller_noderef.go @@ -64,7 +64,12 @@ func (r *MachinePoolReconciler) reconcileNodeRefs(ctx context.Context, s *scope) // Check that the Machine doesn't already have a NodeRefs. // Return early if there is no work to do. - if mp.Status.Replicas == mp.Status.ReadyReplicas && len(mp.Status.NodeRefs) == int(mp.Status.ReadyReplicas) { + // TODO (v1beta2) + readyReplicas := int32(0) + if mp.Status.Deprecated != nil && mp.Status.Deprecated.V1Beta1 != nil { + readyReplicas = mp.Status.Deprecated.V1Beta1.ReadyReplicas + } + if mp.Status.Replicas == readyReplicas && len(mp.Status.NodeRefs) == int(readyReplicas) { conditions.MarkTrue(mp, expv1.ReplicasReadyCondition) return ctrl.Result{}, nil } @@ -101,9 +106,15 @@ func (r *MachinePoolReconciler) reconcileNodeRefs(ctx context.Context, s *scope) return ctrl.Result{}, errors.Wrapf(err, "failed to get node references") } - mp.Status.ReadyReplicas = int32(nodeRefsResult.ready) - mp.Status.AvailableReplicas = int32(nodeRefsResult.available) - mp.Status.UnavailableReplicas = mp.Status.Replicas - mp.Status.AvailableReplicas + if mp.Status.Deprecated == nil { + mp.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + } + if mp.Status.Deprecated.V1Beta1 == nil { + mp.Status.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + } + mp.Status.Deprecated.V1Beta1.ReadyReplicas = int32(nodeRefsResult.ready) + mp.Status.Deprecated.V1Beta1.AvailableReplicas = int32(nodeRefsResult.available) + mp.Status.Deprecated.V1Beta1.UnavailableReplicas = mp.Status.Replicas - mp.Status.Deprecated.V1Beta1.AvailableReplicas mp.Status.NodeRefs = nodeRefsResult.references log.Info("Set MachinePool's NodeRefs", "nodeRefs", mp.Status.NodeRefs) @@ -115,7 +126,7 @@ func (r *MachinePoolReconciler) reconcileNodeRefs(ctx context.Context, s *scope) return ctrl.Result{}, err } - if mp.Status.Replicas != mp.Status.ReadyReplicas || len(nodeRefsResult.references) != int(mp.Status.ReadyReplicas) { + if mp.Status.Replicas != mp.Status.Deprecated.V1Beta1.ReadyReplicas || len(nodeRefsResult.references) != int(mp.Status.Deprecated.V1Beta1.ReadyReplicas) { log.Info("Not enough ready replicas or node references", "nodeRefs", len(nodeRefsResult.references), "readyReplicas", mp.Status.ReadyReplicas, "replicas", mp.Status.Replicas) conditions.MarkFalse(mp, expv1.ReplicasReadyCondition, expv1.WaitingForReplicasReadyReason, clusterv1.ConditionSeverityInfo, "") return ctrl.Result{RequeueAfter: 30 * time.Second}, nil diff --git a/exp/internal/controllers/machinepool_controller_phases.go b/exp/internal/controllers/machinepool_controller_phases.go index 7d425260a26d..d640be6b522e 100644 --- a/exp/internal/controllers/machinepool_controller_phases.go +++ b/exp/internal/controllers/machinepool_controller_phases.go @@ -69,12 +69,17 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) { } // Set the phase to "running" if the number of ready replicas is equal to desired replicas. - if mp.Status.InfrastructureReady && mp.Spec.Replicas != nil && *mp.Spec.Replicas == mp.Status.ReadyReplicas { + // TODO (v1beta2) + readyReplicas := int32(0) + if mp.Status.Deprecated != nil && mp.Status.Deprecated.V1Beta1 != nil { + readyReplicas = mp.Status.Deprecated.V1Beta1.ReadyReplicas + } + if mp.Status.InfrastructureReady && mp.Spec.Replicas != nil && *mp.Spec.Replicas == readyReplicas { mp.Status.SetTypedPhase(expv1.MachinePoolPhaseRunning) } // Set the appropriate phase in response to the MachinePool replica count being greater than the observed infrastructure replicas. - if mp.Status.InfrastructureReady && mp.Spec.Replicas != nil && *mp.Spec.Replicas > mp.Status.ReadyReplicas { + if mp.Status.InfrastructureReady && mp.Spec.Replicas != nil && *mp.Spec.Replicas > readyReplicas { // If we are being managed by an external autoscaler and can't predict scaling direction, set to "Scaling". if annotations.ReplicasManagedByExternalAutoscaler(mp) { mp.Status.SetTypedPhase(expv1.MachinePoolPhaseScaling) @@ -85,7 +90,7 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) { } // Set the appropriate phase in response to the MachinePool replica count being less than the observed infrastructure replicas. - if mp.Status.InfrastructureReady && mp.Spec.Replicas != nil && *mp.Spec.Replicas < mp.Status.ReadyReplicas { + if mp.Status.InfrastructureReady && mp.Spec.Replicas != nil && *mp.Spec.Replicas < readyReplicas { // If we are being managed by an external autoscaler and can't predict scaling direction, set to "Scaling". if annotations.ReplicasManagedByExternalAutoscaler(mp) { mp.Status.SetTypedPhase(expv1.MachinePoolPhaseScaling) @@ -96,7 +101,7 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) { } // Set the phase to "failed" if any of Status.FailureReason or Status.FailureMessage is not-nil. - if mp.Status.FailureReason != nil || mp.Status.FailureMessage != nil { + if mp.Status.Deprecated != nil && mp.Status.Deprecated.V1Beta1 != nil && (mp.Status.Deprecated.V1Beta1.FailureReason != nil || mp.Status.Deprecated.V1Beta1.FailureMessage != nil) { mp.Status.SetTypedPhase(expv1.MachinePoolPhaseFailed) } @@ -159,10 +164,22 @@ func (r *MachinePoolReconciler) reconcileExternal(ctx context.Context, m *expv1. } if failureReason != "" { machineStatusFailure := capierrors.MachinePoolStatusFailure(failureReason) - m.Status.FailureReason = &machineStatusFailure + if m.Status.Deprecated != nil { + m.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 != nil { + m.Status.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.FailureReason = &machineStatusFailure } if failureMessage != "" { - m.Status.FailureMessage = ptr.To( + if m.Status.Deprecated != nil { + m.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 != nil { + m.Status.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.FailureMessage = ptr.To( fmt.Sprintf("Failure detected from referenced resource %v with name %q: %s", obj.GroupVersionKind(), obj.GetName(), failureMessage), ) @@ -244,8 +261,14 @@ func (r *MachinePoolReconciler) reconcileInfrastructure(ctx context.Context, s * if mp.Status.InfrastructureReady { // Infra object went missing after the machine pool was up and running log.Error(err, "infrastructure reference has been deleted after being ready, setting failure state") - mp.Status.FailureReason = ptr.To(capierrors.InvalidConfigurationMachinePoolError) - mp.Status.FailureMessage = ptr.To(fmt.Sprintf("MachinePool infrastructure resource %v with name %q has been deleted after being ready", + if mp.Status.Deprecated == nil { + mp.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + } + if mp.Status.Deprecated.V1Beta1 == nil { + mp.Status.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + } + mp.Status.Deprecated.V1Beta1.FailureReason = ptr.To(capierrors.InvalidConfigurationMachinePoolError) + mp.Status.Deprecated.V1Beta1.FailureMessage = ptr.To(fmt.Sprintf("MachinePool infrastructure resource %v with name %q has been deleted after being ready", mp.Spec.Template.Spec.InfrastructureRef.GroupVersionKind(), mp.Spec.Template.Spec.InfrastructureRef.Name)) } conditions.MarkFalse(mp, clusterv1.InfrastructureReadyCondition, clusterv1.IncorrectExternalRefReason, clusterv1.ConditionSeverityError, fmt.Sprintf("could not find infra reference of kind %s with name %s", mp.Spec.Template.Spec.InfrastructureRef.Kind, mp.Spec.Template.Spec.InfrastructureRef.Name)) @@ -312,9 +335,15 @@ func (r *MachinePoolReconciler) reconcileInfrastructure(ctx context.Context, s * if !reflect.DeepEqual(mp.Spec.ProviderIDList, providerIDList) { mp.Spec.ProviderIDList = providerIDList - mp.Status.ReadyReplicas = 0 - mp.Status.AvailableReplicas = 0 - mp.Status.UnavailableReplicas = mp.Status.Replicas + if mp.Status.Deprecated == nil { + mp.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + } + if mp.Status.Deprecated.V1Beta1 == nil { + mp.Status.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + } + mp.Status.Deprecated.V1Beta1.ReadyReplicas = 0 + mp.Status.Deprecated.V1Beta1.AvailableReplicas = 0 + mp.Status.Deprecated.V1Beta1.UnavailableReplicas = mp.Status.Replicas } return ctrl.Result{}, nil diff --git a/exp/internal/controllers/machinepool_controller_phases_test.go b/exp/internal/controllers/machinepool_controller_phases_test.go index e6ce49bb8df1..89444aeffe19 100644 --- a/exp/internal/controllers/machinepool_controller_phases_test.go +++ b/exp/internal/controllers/machinepool_controller_phases_test.go @@ -292,7 +292,11 @@ func TestReconcileMachinePoolPhases(t *testing.T) { g.Expect(res.Requeue).To(BeFalse()) // Set ReadyReplicas - machinepool.Status.ReadyReplicas = 1 + machinepool.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: 1, + }, + } r.reconcilePhase(machinepool) g.Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseRunning)) @@ -360,7 +364,11 @@ func TestReconcileMachinePoolPhases(t *testing.T) { g.Expect(res.Requeue).To(BeFalse()) // Set ReadyReplicas - machinepool.Status.ReadyReplicas = 1 + machinepool.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: 1, + }, + } r.reconcilePhase(machinepool) g.Expect(machinepool.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseRunning)) @@ -459,7 +467,11 @@ func TestReconcileMachinePoolPhases(t *testing.T) { g.Expect(res.Requeue).To(BeFalse()) // Set ReadyReplicas - machinepool.Status.ReadyReplicas = 1 + machinepool.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: 1, + }, + } // Scale up machinepool.Spec.Replicas = ptr.To[int32](5) @@ -525,7 +537,11 @@ func TestReconcileMachinePoolPhases(t *testing.T) { g.Expect(res.Requeue).To(BeFalse()) // Set ReadyReplicas - machinepool.Status.ReadyReplicas = 4 + machinepool.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: 4, + }, + } // Scale down machinepool.Spec.Replicas = ptr.To[int32](1) @@ -642,7 +658,11 @@ func TestReconcileMachinePoolPhases(t *testing.T) { // Set replicas to fully reconciled machinePool.Spec.ProviderIDList = []string{"test://id-1"} - machinePool.Status.ReadyReplicas = 1 + machinePool.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: 1, + }, + } machinePool.Status.Replicas = 1 fakeClient := fake.NewClientBuilder().WithObjects(defaultCluster, defaultKubeconfigSecret, machinePool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build() @@ -734,7 +754,11 @@ func TestReconcileMachinePoolPhases(t *testing.T) { // Set replicas to fully reconciled machinePool.Spec.ProviderIDList = []string{"test://id-1"} - machinePool.Status.ReadyReplicas = 1 + machinePool.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: 1, + }, + } machinePool.Status.Replicas = 1 fakeClient := fake.NewClientBuilder().WithObjects(defaultCluster, defaultKubeconfigSecret, machinePool, bootstrapConfig, infraConfig, builder.TestBootstrapConfigCRD, builder.TestInfrastructureMachineTemplateCRD).Build() @@ -1234,8 +1258,8 @@ func TestReconcileMachinePoolInfrastructure(t *testing.T) { expectRequeueAfter: false, expected: func(g *WithT, m *expv1.MachinePool) { g.Expect(m.Status.InfrastructureReady).To(BeTrue()) - g.Expect(m.Status.FailureMessage).ToNot(BeNil()) - g.Expect(m.Status.FailureReason).ToNot(BeNil()) + g.Expect(m.Status.Deprecated.V1Beta1.FailureMessage).ToNot(BeNil()) + g.Expect(m.Status.Deprecated.V1Beta1.FailureReason).ToNot(BeNil()) g.Expect(m.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseFailed)) }, }, @@ -1314,11 +1338,11 @@ func TestReconcileMachinePoolInfrastructure(t *testing.T) { expectRequeueAfter: false, expected: func(g *WithT, m *expv1.MachinePool) { g.Expect(m.Status.InfrastructureReady).To(BeTrue()) - g.Expect(m.Status.ReadyReplicas).To(Equal(int32(0))) - g.Expect(m.Status.AvailableReplicas).To(Equal(int32(0))) - g.Expect(m.Status.UnavailableReplicas).To(Equal(int32(0))) - g.Expect(m.Status.FailureMessage).To(BeNil()) - g.Expect(m.Status.FailureReason).To(BeNil()) + g.Expect(m.Status.Deprecated.V1Beta1.ReadyReplicas).To(Equal(int32(0))) + g.Expect(m.Status.Deprecated.V1Beta1.AvailableReplicas).To(Equal(int32(0))) + g.Expect(m.Status.Deprecated.V1Beta1.UnavailableReplicas).To(Equal(int32(0))) + g.Expect(m.Status.Deprecated.V1Beta1.FailureMessage).To(BeNil()) + g.Expect(m.Status.Deprecated.V1Beta1.FailureReason).To(BeNil()) g.Expect(m.Status.GetTypedPhase()).To(Equal(expv1.MachinePoolPhaseRunning)) }, }, diff --git a/exp/internal/controllers/machinepool_controller_test.go b/exp/internal/controllers/machinepool_controller_test.go index 49be99497228..594f7cef476c 100644 --- a/exp/internal/controllers/machinepool_controller_test.go +++ b/exp/internal/controllers/machinepool_controller_test.go @@ -164,11 +164,11 @@ func TestMachinePoolOwnerReference(t *testing.T) { ClusterName: "invalid", }, Status: expv1.MachinePoolStatus{ - V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, } @@ -189,11 +189,11 @@ func TestMachinePoolOwnerReference(t *testing.T) { ClusterName: "test-cluster", }, Status: expv1.MachinePoolStatus{ - V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, } @@ -217,11 +217,11 @@ func TestMachinePoolOwnerReference(t *testing.T) { ClusterName: "test-cluster", }, Status: expv1.MachinePoolStatus{ - V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, } @@ -366,17 +366,21 @@ func TestReconcileMachinePoolRequest(t *testing.T) { }, }, Status: expv1.MachinePoolStatus{ - Replicas: 1, - ReadyReplicas: 1, + Replicas: 1, + Deprecated: &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: 1, + }, + }, NodeRefs: []corev1.ObjectReference{ {Name: "test"}, }, ObservedGeneration: 1, - V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, }, expected: expected{ @@ -423,11 +427,11 @@ func TestReconcileMachinePoolRequest(t *testing.T) { Name: "test-node", }, }, - V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, }, nodes: []corev1.Node{ @@ -486,11 +490,11 @@ func TestReconcileMachinePoolRequest(t *testing.T) { Name: "test-node", }, }, - V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, }, nodes: []corev1.Node{ @@ -549,11 +553,11 @@ func TestReconcileMachinePoolRequest(t *testing.T) { Name: "test-node", }, }, - V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, }, nodes: []corev1.Node{ @@ -880,11 +884,11 @@ func TestRemoveMachinePoolFinalizerAfterDeleteReconcile(t *testing.T) { }, }, Status: expv1.MachinePoolStatus{ - V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, } key := client.ObjectKey{Namespace: m.Namespace, Name: m.Name} @@ -981,11 +985,11 @@ func TestMachinePoolConditions(t *testing.T) { }, }, Status: expv1.MachinePoolStatus{ - V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, } @@ -1031,7 +1035,13 @@ func TestMachinePoolConditions(t *testing.T) { {Name: "azure-node-4"}, } mp.Status.Replicas = 2 - mp.Status.ReadyReplicas = 2 + if mp.Status.Deprecated == nil { + mp.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{} + } + if mp.Status.Deprecated.V1Beta1 == nil { + mp.Status.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} + } + mp.Status.Deprecated.V1Beta1.ReadyReplicas = 2 }, conditionAssertFunc: func(t *testing.T, getter conditions.Getter) { t.Helper() diff --git a/exp/topology/desiredstate/desired_state_test.go b/exp/topology/desiredstate/desired_state_test.go index 3b573cc9aec8..ead1391ba2c1 100644 --- a/exp/topology/desiredstate/desired_state_test.go +++ b/exp/topology/desiredstate/desired_state_test.go @@ -1859,9 +1859,13 @@ func TestComputeMachineDeployment(t *testing.T) { WithStatus(clusterv1.MachineDeploymentStatus{ ObservedGeneration: 2, Replicas: 2, - ReadyReplicas: 2, - UpdatedReplicas: 2, - AvailableReplicas: 2, + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + ReadyReplicas: 2, + UpdatedReplicas: 2, + AvailableReplicas: 2, + }, + }, }). Build() mdsState = duplicateMachineDeploymentsState(mdsState) @@ -2257,8 +2261,12 @@ func TestComputeMachinePool(t *testing.T) { WithStatus(expv1.MachinePoolStatus{ ObservedGeneration: 2, Replicas: 2, - ReadyReplicas: 2, - AvailableReplicas: 2, + Deprecated: &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: 2, + AvailableReplicas: 2, + }, + }, }). Build() mpsState = duplicateMachinePoolsState(mpsState) diff --git a/internal/controllers/cluster/cluster_controller_phases.go b/internal/controllers/cluster/cluster_controller_phases.go index 7f0a89c63961..476c2c43d30d 100644 --- a/internal/controllers/cluster/cluster_controller_phases.go +++ b/internal/controllers/cluster/cluster_controller_phases.go @@ -62,8 +62,10 @@ func (r *Reconciler) reconcilePhase(_ context.Context, cluster *clusterv1.Cluste cluster.Status.SetTypedPhase(clusterv1.ClusterPhaseProvisioned) } - if cluster.Status.FailureReason != nil || cluster.Status.FailureMessage != nil { + failedMessage := "" + if cluster.Status.Deprecated != nil && cluster.Status.Deprecated.V1Beta1 != nil && (cluster.Status.Deprecated.V1Beta1.FailureReason != nil || cluster.Status.Deprecated.V1Beta1.FailureMessage != nil) { cluster.Status.SetTypedPhase(clusterv1.ClusterPhaseFailed) + failedMessage = ptr.Deref(cluster.Status.Deprecated.V1Beta1.FailureMessage, "unknown") } if !cluster.DeletionTimestamp.IsZero() { @@ -74,7 +76,7 @@ func (r *Reconciler) reconcilePhase(_ context.Context, cluster *clusterv1.Cluste if preReconcilePhase != cluster.Status.GetTypedPhase() { // Failed clusters should get a Warning event if cluster.Status.GetTypedPhase() == clusterv1.ClusterPhaseFailed { - r.recorder.Eventf(cluster, corev1.EventTypeWarning, string(cluster.Status.GetTypedPhase()), "Cluster %s is %s: %s", cluster.Name, string(cluster.Status.GetTypedPhase()), ptr.Deref(cluster.Status.FailureMessage, "unknown")) + r.recorder.Eventf(cluster, corev1.EventTypeWarning, string(cluster.Status.GetTypedPhase()), "Cluster %s is %s: %s", cluster.Name, string(cluster.Status.GetTypedPhase()), failedMessage) } else { r.recorder.Eventf(cluster, corev1.EventTypeNormal, string(cluster.Status.GetTypedPhase()), "Cluster %s is %s", cluster.Name, string(cluster.Status.GetTypedPhase())) } @@ -114,10 +116,22 @@ func (r *Reconciler) reconcileExternal(ctx context.Context, cluster *clusterv1.C } if failureReason != "" { clusterStatusError := capierrors.ClusterStatusError(failureReason) - cluster.Status.FailureReason = &clusterStatusError + if cluster.Status.Deprecated == nil { + cluster.Status.Deprecated = &clusterv1.ClusterDeprecatedStatus{} + } + if cluster.Status.Deprecated.V1Beta1 == nil { + cluster.Status.Deprecated.V1Beta1 = &clusterv1.ClusterV1Beta1DeprecatedStatus{} + } + cluster.Status.Deprecated.V1Beta1.FailureReason = &clusterStatusError } if failureMessage != "" { - cluster.Status.FailureMessage = ptr.To( + if cluster.Status.Deprecated == nil { + cluster.Status.Deprecated = &clusterv1.ClusterDeprecatedStatus{} + } + if cluster.Status.Deprecated.V1Beta1 == nil { + cluster.Status.Deprecated.V1Beta1 = &clusterv1.ClusterV1Beta1DeprecatedStatus{} + } + cluster.Status.Deprecated.V1Beta1.FailureMessage = ptr.To( fmt.Sprintf("Failure detected from referenced resource %v with name %q: %s", obj.GroupVersionKind(), obj.GetName(), failureMessage), ) diff --git a/internal/controllers/cluster/cluster_controller_phases_test.go b/internal/controllers/cluster/cluster_controller_phases_test.go index 395aa723e95e..51820ce90b3f 100644 --- a/internal/controllers/cluster/cluster_controller_phases_test.go +++ b/internal/controllers/cluster/cluster_controller_phases_test.go @@ -759,7 +759,11 @@ func TestClusterReconciler_reconcilePhase(t *testing.T) { }, Status: clusterv1.ClusterStatus{ InfrastructureReady: true, - FailureReason: &createClusterError, + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + FailureReason: &createClusterError, + }, + }, }, Spec: clusterv1.ClusterSpec{ InfrastructureRef: &corev1.ObjectReference{}, @@ -776,7 +780,11 @@ func TestClusterReconciler_reconcilePhase(t *testing.T) { }, Status: clusterv1.ClusterStatus{ InfrastructureReady: true, - FailureMessage: &failureMsg, + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + FailureMessage: &failureMsg, + }, + }, }, Spec: clusterv1.ClusterSpec{ InfrastructureRef: &corev1.ObjectReference{}, diff --git a/internal/controllers/cluster/cluster_controller_status.go b/internal/controllers/cluster/cluster_controller_status.go index 0ae1af4b64a5..6830c05009c0 100644 --- a/internal/controllers/cluster/cluster_controller_status.go +++ b/internal/controllers/cluster/cluster_controller_status.go @@ -78,12 +78,8 @@ func (r *Reconciler) updateStatus(ctx context.Context, s *scope) { } func setControlPlaneReplicas(_ context.Context, cluster *clusterv1.Cluster, controlPlane *unstructured.Unstructured, controlPlaneMachines collections.Machines, controlPlaneIsNotFound bool, getDescendantsSucceeded bool) { - if cluster.Status.V1Beta2 == nil { - cluster.Status.V1Beta2 = &clusterv1.ClusterV1Beta2Status{} - } - - if cluster.Status.V1Beta2.ControlPlane == nil { - cluster.Status.V1Beta2.ControlPlane = &clusterv1.ClusterControlPlaneStatus{} + if cluster.Status.ControlPlane == nil { + cluster.Status.ControlPlane = &clusterv1.ClusterControlPlaneStatus{} } // If this cluster is using a control plane object, surface the replica counters reported by it. @@ -92,28 +88,28 @@ func setControlPlaneReplicas(_ context.Context, cluster *clusterv1.Cluster, cont // corresponding replicas will be left empty. if cluster.Spec.ControlPlaneRef != nil || cluster.Spec.Topology != nil { if controlPlane == nil || controlPlaneIsNotFound { - cluster.Status.V1Beta2.ControlPlane.Replicas = nil - cluster.Status.V1Beta2.ControlPlane.ReadyReplicas = nil - cluster.Status.V1Beta2.ControlPlane.AvailableReplicas = nil - cluster.Status.V1Beta2.ControlPlane.UpToDateReplicas = nil - cluster.Status.V1Beta2.ControlPlane.DesiredReplicas = nil + cluster.Status.ControlPlane.Replicas = nil + cluster.Status.ControlPlane.ReadyReplicas = nil + cluster.Status.ControlPlane.AvailableReplicas = nil + cluster.Status.ControlPlane.UpToDateReplicas = nil + cluster.Status.ControlPlane.DesiredReplicas = nil return } if replicas, err := contract.ControlPlane().Replicas().Get(controlPlane); err == nil && replicas != nil { - cluster.Status.V1Beta2.ControlPlane.DesiredReplicas = ptr.To(int32(*replicas)) + cluster.Status.ControlPlane.DesiredReplicas = ptr.To(int32(*replicas)) } if replicas, err := contract.ControlPlane().StatusReplicas().Get(controlPlane); err == nil && replicas != nil { - cluster.Status.V1Beta2.ControlPlane.Replicas = ptr.To(int32(*replicas)) + cluster.Status.ControlPlane.Replicas = ptr.To(int32(*replicas)) } if replicas, err := contract.ControlPlane().V1Beta2ReadyReplicas().Get(controlPlane); err == nil && replicas != nil { - cluster.Status.V1Beta2.ControlPlane.ReadyReplicas = replicas + cluster.Status.ControlPlane.ReadyReplicas = replicas } if replicas, err := contract.ControlPlane().V1Beta2AvailableReplicas().Get(controlPlane); err == nil && replicas != nil { - cluster.Status.V1Beta2.ControlPlane.AvailableReplicas = replicas + cluster.Status.ControlPlane.AvailableReplicas = replicas } if replicas, err := contract.ControlPlane().V1Beta2UpToDateReplicas().Get(controlPlane); err == nil && replicas != nil { - cluster.Status.V1Beta2.ControlPlane.UpToDateReplicas = replicas + cluster.Status.ControlPlane.UpToDateReplicas = replicas } return } @@ -138,23 +134,19 @@ func setControlPlaneReplicas(_ context.Context, cluster *clusterv1.Cluster, cont } } - cluster.Status.V1Beta2.ControlPlane.Replicas = replicas - cluster.Status.V1Beta2.ControlPlane.ReadyReplicas = readyReplicas - cluster.Status.V1Beta2.ControlPlane.AvailableReplicas = availableReplicas - cluster.Status.V1Beta2.ControlPlane.UpToDateReplicas = upToDateReplicas + cluster.Status.ControlPlane.Replicas = replicas + cluster.Status.ControlPlane.ReadyReplicas = readyReplicas + cluster.Status.ControlPlane.AvailableReplicas = availableReplicas + cluster.Status.ControlPlane.UpToDateReplicas = upToDateReplicas // There is no concept of desired replicas for stand-alone machines, but for sake of consistency // we consider the fact that the machine has been creates as equivalent to the intent to have one replica. - cluster.Status.V1Beta2.ControlPlane.DesiredReplicas = replicas + cluster.Status.ControlPlane.DesiredReplicas = replicas } func setWorkersReplicas(_ context.Context, cluster *clusterv1.Cluster, machinePools expv1.MachinePoolList, machineDeployments clusterv1.MachineDeploymentList, machineSets clusterv1.MachineSetList, workerMachines collections.Machines, getDescendantsSucceeded bool) { - if cluster.Status.V1Beta2 == nil { - cluster.Status.V1Beta2 = &clusterv1.ClusterV1Beta2Status{} - } - - if cluster.Status.V1Beta2.Workers == nil { - cluster.Status.V1Beta2.Workers = &clusterv1.WorkersStatus{} + if cluster.Status.Workers == nil { + cluster.Status.Workers = &clusterv1.WorkersStatus{} } // If there was some unexpected errors in listing descendants (this should never happen), do not update replica counters. @@ -168,14 +160,14 @@ func setWorkersReplicas(_ context.Context, cluster *clusterv1.Cluster, machinePo desiredReplicas = ptr.To(ptr.Deref(desiredReplicas, 0) + *mp.Spec.Replicas) } currentReplicas = ptr.To(ptr.Deref(currentReplicas, 0) + mp.Status.Replicas) - if mp.Status.V1Beta2 != nil && mp.Status.V1Beta2.ReadyReplicas != nil { - readyReplicas = ptr.To(ptr.Deref(readyReplicas, 0) + *mp.Status.V1Beta2.ReadyReplicas) + if mp.Status.ReadyReplicas != nil { + readyReplicas = ptr.To(ptr.Deref(readyReplicas, 0) + *mp.Status.ReadyReplicas) } - if mp.Status.V1Beta2 != nil && mp.Status.V1Beta2.AvailableReplicas != nil { - availableReplicas = ptr.To(ptr.Deref(availableReplicas, 0) + *mp.Status.V1Beta2.AvailableReplicas) + if mp.Status.AvailableReplicas != nil { + availableReplicas = ptr.To(ptr.Deref(availableReplicas, 0) + *mp.Status.AvailableReplicas) } - if mp.Status.V1Beta2 != nil && mp.Status.V1Beta2.UpToDateReplicas != nil { - upToDateReplicas = ptr.To(ptr.Deref(upToDateReplicas, 0) + *mp.Status.V1Beta2.UpToDateReplicas) + if mp.Status.UpToDateReplicas != nil { + upToDateReplicas = ptr.To(ptr.Deref(upToDateReplicas, 0) + *mp.Status.UpToDateReplicas) } } @@ -184,14 +176,14 @@ func setWorkersReplicas(_ context.Context, cluster *clusterv1.Cluster, machinePo desiredReplicas = ptr.To(ptr.Deref(desiredReplicas, 0) + *md.Spec.Replicas) } currentReplicas = ptr.To(ptr.Deref(currentReplicas, 0) + md.Status.Replicas) - if md.Status.V1Beta2 != nil && md.Status.V1Beta2.ReadyReplicas != nil { - readyReplicas = ptr.To(ptr.Deref(readyReplicas, 0) + *md.Status.V1Beta2.ReadyReplicas) + if md.Status.ReadyReplicas != nil { + readyReplicas = ptr.To(ptr.Deref(readyReplicas, 0) + *md.Status.ReadyReplicas) } - if md.Status.V1Beta2 != nil && md.Status.V1Beta2.AvailableReplicas != nil { - availableReplicas = ptr.To(ptr.Deref(availableReplicas, 0) + *md.Status.V1Beta2.AvailableReplicas) + if md.Status.AvailableReplicas != nil { + availableReplicas = ptr.To(ptr.Deref(availableReplicas, 0) + *md.Status.AvailableReplicas) } - if md.Status.V1Beta2 != nil && md.Status.V1Beta2.UpToDateReplicas != nil { - upToDateReplicas = ptr.To(ptr.Deref(upToDateReplicas, 0) + *md.Status.V1Beta2.UpToDateReplicas) + if md.Status.UpToDateReplicas != nil { + upToDateReplicas = ptr.To(ptr.Deref(upToDateReplicas, 0) + *md.Status.UpToDateReplicas) } } @@ -203,14 +195,14 @@ func setWorkersReplicas(_ context.Context, cluster *clusterv1.Cluster, machinePo desiredReplicas = ptr.To(ptr.Deref(desiredReplicas, 0) + *ms.Spec.Replicas) } currentReplicas = ptr.To(ptr.Deref(currentReplicas, 0) + ms.Status.Replicas) - if ms.Status.V1Beta2 != nil && ms.Status.V1Beta2.ReadyReplicas != nil { - readyReplicas = ptr.To(ptr.Deref(readyReplicas, 0) + *ms.Status.V1Beta2.ReadyReplicas) + if ms.Status.ReadyReplicas != nil { + readyReplicas = ptr.To(ptr.Deref(readyReplicas, 0) + *ms.Status.ReadyReplicas) } - if ms.Status.V1Beta2 != nil && ms.Status.V1Beta2.AvailableReplicas != nil { - availableReplicas = ptr.To(ptr.Deref(availableReplicas, 0) + *ms.Status.V1Beta2.AvailableReplicas) + if ms.Status.AvailableReplicas != nil { + availableReplicas = ptr.To(ptr.Deref(availableReplicas, 0) + *ms.Status.AvailableReplicas) } - if ms.Status.V1Beta2 != nil && ms.Status.V1Beta2.UpToDateReplicas != nil { - upToDateReplicas = ptr.To(ptr.Deref(upToDateReplicas, 0) + *ms.Status.V1Beta2.UpToDateReplicas) + if ms.Status.UpToDateReplicas != nil { + upToDateReplicas = ptr.To(ptr.Deref(upToDateReplicas, 0) + *ms.Status.UpToDateReplicas) } } @@ -234,11 +226,11 @@ func setWorkersReplicas(_ context.Context, cluster *clusterv1.Cluster, machinePo desiredReplicas = ptr.To(ptr.Deref(desiredReplicas, 0) + 1) } - cluster.Status.V1Beta2.Workers.DesiredReplicas = desiredReplicas - cluster.Status.V1Beta2.Workers.Replicas = currentReplicas - cluster.Status.V1Beta2.Workers.ReadyReplicas = readyReplicas - cluster.Status.V1Beta2.Workers.AvailableReplicas = availableReplicas - cluster.Status.V1Beta2.Workers.UpToDateReplicas = upToDateReplicas + cluster.Status.Workers.DesiredReplicas = desiredReplicas + cluster.Status.Workers.Replicas = currentReplicas + cluster.Status.Workers.ReadyReplicas = readyReplicas + cluster.Status.Workers.AvailableReplicas = availableReplicas + cluster.Status.Workers.UpToDateReplicas = upToDateReplicas } func setInfrastructureReadyCondition(_ context.Context, cluster *clusterv1.Cluster, infraCluster *unstructured.Unstructured, infraClusterIsNotFound bool) { diff --git a/internal/controllers/cluster/cluster_controller_status_test.go b/internal/controllers/cluster/cluster_controller_status_test.go index a450495d3124..24ea168f69cf 100644 --- a/internal/controllers/cluster/cluster_controller_status_test.go +++ b/internal/controllers/cluster/cluster_controller_status_test.go @@ -108,13 +108,12 @@ func TestSetControlPlaneReplicas(t *testing.T) { setControlPlaneReplicas(ctx, tt.cluster, tt.controlPlane, tt.machines, tt.controlPlaneIsNotFound, tt.getDescendantsSucceeded) - g.Expect(tt.cluster.Status.V1Beta2).ToNot(BeNil()) - g.Expect(tt.cluster.Status.V1Beta2.ControlPlane).ToNot(BeNil()) - g.Expect(tt.cluster.Status.V1Beta2.ControlPlane.DesiredReplicas).To(Equal(tt.expectDesiredReplicas)) - g.Expect(tt.cluster.Status.V1Beta2.ControlPlane.Replicas).To(Equal(tt.expectReplicas)) - g.Expect(tt.cluster.Status.V1Beta2.ControlPlane.ReadyReplicas).To(Equal(tt.expectReadyReplicas)) - g.Expect(tt.cluster.Status.V1Beta2.ControlPlane.AvailableReplicas).To(Equal(tt.expectAvailableReplicas)) - g.Expect(tt.cluster.Status.V1Beta2.ControlPlane.UpToDateReplicas).To(Equal(tt.expectUpToDateReplicas)) + g.Expect(tt.cluster.Status.ControlPlane).ToNot(BeNil()) + g.Expect(tt.cluster.Status.ControlPlane.DesiredReplicas).To(Equal(tt.expectDesiredReplicas)) + g.Expect(tt.cluster.Status.ControlPlane.Replicas).To(Equal(tt.expectReplicas)) + g.Expect(tt.cluster.Status.ControlPlane.ReadyReplicas).To(Equal(tt.expectReadyReplicas)) + g.Expect(tt.cluster.Status.ControlPlane.AvailableReplicas).To(Equal(tt.expectAvailableReplicas)) + g.Expect(tt.cluster.Status.ControlPlane.UpToDateReplicas).To(Equal(tt.expectUpToDateReplicas)) }) } } @@ -197,13 +196,12 @@ func TestSetWorkersReplicas(t *testing.T) { setWorkersReplicas(ctx, tt.cluster, tt.machinePools, tt.machineDeployments, tt.machineSets, tt.workerMachines, tt.getDescendantsSucceeded) - g.Expect(tt.cluster.Status.V1Beta2).ToNot(BeNil()) - g.Expect(tt.cluster.Status.V1Beta2.Workers).ToNot(BeNil()) - g.Expect(tt.cluster.Status.V1Beta2.Workers.DesiredReplicas).To(Equal(tt.expectDesiredReplicas)) - g.Expect(tt.cluster.Status.V1Beta2.Workers.Replicas).To(Equal(tt.expectReplicas)) - g.Expect(tt.cluster.Status.V1Beta2.Workers.ReadyReplicas).To(Equal(tt.expectReadyReplicas)) - g.Expect(tt.cluster.Status.V1Beta2.Workers.AvailableReplicas).To(Equal(tt.expectAvailableReplicas)) - g.Expect(tt.cluster.Status.V1Beta2.Workers.UpToDateReplicas).To(Equal(tt.expectUpToDateReplicas)) + g.Expect(tt.cluster.Status.Workers).ToNot(BeNil()) + g.Expect(tt.cluster.Status.Workers.DesiredReplicas).To(Equal(tt.expectDesiredReplicas)) + g.Expect(tt.cluster.Status.Workers.Replicas).To(Equal(tt.expectReplicas)) + g.Expect(tt.cluster.Status.Workers.ReadyReplicas).To(Equal(tt.expectReadyReplicas)) + g.Expect(tt.cluster.Status.Workers.AvailableReplicas).To(Equal(tt.expectAvailableReplicas)) + g.Expect(tt.cluster.Status.Workers.UpToDateReplicas).To(Equal(tt.expectUpToDateReplicas)) }) } } @@ -2192,10 +2190,8 @@ func TestSetAvailableCondition(t *testing.T) { Topology: nil, // not using CC }, Status: clusterv1.ClusterStatus{ - V1Beta2: &clusterv1.ClusterV1Beta2Status{ - Conditions: []metav1.Condition{ - // No condition reported yet, the required ones should be reported as missing. - }, + Conditions: []metav1.Condition{ + // No condition reported yet, the required ones should be reported as missing. }, }, }, @@ -2221,35 +2217,33 @@ func TestSetAvailableCondition(t *testing.T) { Topology: nil, // not using CC }, Status: clusterv1.ClusterStatus{ - V1Beta2: &clusterv1.ClusterV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterDeletingV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: "Foo", - }, - // TopologyReconciled missing + Conditions: []metav1.Condition{ + { + Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", }, + { + Type: clusterv1.ClusterDeletingV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: "Foo", + }, + // TopologyReconciled missing }, }, }, @@ -2271,37 +2265,35 @@ func TestSetAvailableCondition(t *testing.T) { Topology: nil, // not using CC }, Status: clusterv1.ClusterStatus{ - V1Beta2: &clusterv1.ClusterV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterDeletingV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.ClusterDeletingWaitingForWorkersDeletionV1Beta2Reason, - Message: "* Control plane Machines: cp1, cp2, cp3\n" + - "* MachineDeployments: md1, md2\n" + - "* MachineSets: ms1, ms2\n" + - "* Worker Machines: w1, w2, w3, w4, w5, ... (3 more)", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterDeletingV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.ClusterDeletingWaitingForWorkersDeletionV1Beta2Reason, + Message: "* Control plane Machines: cp1, cp2, cp3\n" + + "* MachineDeployments: md1, md2\n" + + "* MachineSets: ms1, ms2\n" + + "* Worker Machines: w1, w2, w3, w4, w5, ... (3 more)", }, }, }, @@ -2328,35 +2320,33 @@ func TestSetAvailableCondition(t *testing.T) { Topology: &clusterv1.Topology{}, // using CC }, Status: clusterv1.ClusterStatus{ - V1Beta2: &clusterv1.ClusterV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterDeletingV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: "Foo", - }, - // TopologyReconciled missing + Conditions: []metav1.Condition{ + { + Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", }, + { + Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterDeletingV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: "Foo", + }, + // TopologyReconciled missing }, }, }, @@ -2386,45 +2376,43 @@ func TestSetAvailableCondition(t *testing.T) { }, }, Status: clusterv1.ClusterStatus{ - V1Beta2: &clusterv1.ClusterV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterDeletingV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: "Foo", - }, - { - Type: "MyAvailabilityGate", - Status: metav1.ConditionFalse, - Reason: "SomeReason", - Message: "Some message", - }, - { - Type: "MyAvailabilityGateWithNegativePolarity", - Status: metav1.ConditionTrue, - Reason: "SomeReason", - Message: "Some other message", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterDeletingV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: "Foo", + }, + { + Type: "MyAvailabilityGate", + Status: metav1.ConditionFalse, + Reason: "SomeReason", + Message: "Some message", + }, + { + Type: "MyAvailabilityGateWithNegativePolarity", + Status: metav1.ConditionTrue, + Reason: "SomeReason", + Message: "Some other message", }, }, }, @@ -2454,45 +2442,43 @@ func TestSetAvailableCondition(t *testing.T) { Namespace: metav1.NamespaceDefault, }, Status: clusterv1.ClusterStatus{ - V1Beta2: &clusterv1.ClusterV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterDeletingV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: "Foo", - }, - { - Type: "MyClusterClassAvailabilityGate", - Status: metav1.ConditionFalse, - Reason: "SomeReason", - Message: "Some message", - }, - { - Type: "MyClusterClassAvailabilityGateWithNegativePolarity", - Status: metav1.ConditionTrue, - Reason: "SomeReason", - Message: "Some other message", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterDeletingV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: "Foo", + }, + { + Type: "MyClusterClassAvailabilityGate", + Status: metav1.ConditionFalse, + Reason: "SomeReason", + Message: "Some message", + }, + { + Type: "MyClusterClassAvailabilityGateWithNegativePolarity", + Status: metav1.ConditionTrue, + Reason: "SomeReason", + Message: "Some other message", }, }, }, @@ -2527,34 +2513,32 @@ func TestSetAvailableCondition(t *testing.T) { DeletionTimestamp: &metav1.Time{Time: time.Now()}, }, Status: clusterv1.ClusterStatus{ - V1Beta2: &clusterv1.ClusterV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.ClusterInfrastructureDeletedV1Beta2Reason, - }, - { - Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.ClusterControlPlaneDeletedV1Beta2Reason, - }, - { - Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterDeletingV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.ClusterDeletingWaitingForBeforeDeleteHookV1Beta2Reason, - Message: "Some message", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.ClusterInfrastructureDeletedV1Beta2Reason, + }, + { + Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.ClusterControlPlaneDeletedV1Beta2Reason, + }, + { + Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterDeletingV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.ClusterDeletingWaitingForBeforeDeleteHookV1Beta2Reason, + Message: "Some message", }, }, }, @@ -2577,39 +2561,37 @@ func TestSetAvailableCondition(t *testing.T) { Topology: &clusterv1.Topology{}, // using CC }, Status: clusterv1.ClusterStatus{ - V1Beta2: &clusterv1.ClusterV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterDeletingV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterTopologyReconciledV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.ClusterTopologyReconciledControlPlaneUpgradePendingV1Beta2Reason, - Message: "Control plane rollout and upgrade to version v1.29.0 on hold.", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterDeletingV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterTopologyReconciledV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.ClusterTopologyReconciledControlPlaneUpgradePendingV1Beta2Reason, + Message: "Control plane rollout and upgrade to version v1.29.0 on hold.", }, }, }, @@ -2632,40 +2614,38 @@ func TestSetAvailableCondition(t *testing.T) { Topology: &clusterv1.Topology{}, // using CC }, Status: clusterv1.ClusterStatus{ - V1Beta2: &clusterv1.ClusterV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.ClusterWorkersNotAvailableV1Beta2Reason, - Message: "3 available replicas, at least 4 required (spec.strategy.rollout.maxUnavailable is 1, spec.replicas is 5) from MachineDeployment md1; 2 available replicas, at least 3 required (spec.strategy.rollout.maxUnavailable is 1, spec.replicas is 4) from MachinePool mp1", - }, - { - Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterDeletingV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterTopologyReconciledV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.ClusterTopologyReconciledControlPlaneUpgradePendingV1Beta2Reason, - Message: "Control plane rollout and upgrade to version v1.29.0 on hold.", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.ClusterWorkersNotAvailableV1Beta2Reason, + Message: "3 available replicas, at least 4 required (spec.strategy.rollout.maxUnavailable is 1, spec.replicas is 5) from MachineDeployment md1; 2 available replicas, at least 3 required (spec.strategy.rollout.maxUnavailable is 1, spec.replicas is 4) from MachinePool mp1", + }, + { + Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterDeletingV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterTopologyReconciledV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.ClusterTopologyReconciledControlPlaneUpgradePendingV1Beta2Reason, + Message: "Control plane rollout and upgrade to version v1.29.0 on hold.", }, }, }, @@ -2688,40 +2668,38 @@ func TestSetAvailableCondition(t *testing.T) { Topology: &clusterv1.Topology{}, // using CC }, Status: clusterv1.ClusterStatus{ - V1Beta2: &clusterv1.ClusterV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterDeletingV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterTopologyReconciledV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.ClusterTopologyReconciledClusterClassNotReconciledV1Beta2Reason, - Message: "ClusterClass not reconciled. If this condition persists please check ClusterClass status. A ClusterClass is reconciled if" + - ".status.observedGeneration == .metadata.generation is true. If this is not the case either ClusterClass reconciliation failed or the ClusterClass is paused", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterDeletingV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterTopologyReconciledV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.ClusterTopologyReconciledClusterClassNotReconciledV1Beta2Reason, + Message: "ClusterClass not reconciled. If this condition persists please check ClusterClass status. A ClusterClass is reconciled if" + + ".status.observedGeneration == .metadata.generation is true. If this is not the case either ClusterClass reconciliation failed or the ClusterClass is paused", }, }, }, @@ -2745,41 +2723,39 @@ func TestSetAvailableCondition(t *testing.T) { Topology: &clusterv1.Topology{}, // using CC }, Status: clusterv1.ClusterStatus{ - V1Beta2: &clusterv1.ClusterV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.ClusterWorkersNotAvailableV1Beta2Reason, - Message: "3 available replicas, at least 4 required (spec.strategy.rollout.maxUnavailable is 1, spec.replicas is 5) from MachineDeployment md1; 2 available replicas, at least 3 required (spec.strategy.rollout.maxUnavailable is 1, spec.replicas is 4) from MachinePool mp1", - }, - { - Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterDeletingV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: "Foo", - }, - { - Type: clusterv1.ClusterTopologyReconciledV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.ClusterTopologyReconciledClusterClassNotReconciledV1Beta2Reason, - Message: "ClusterClass not reconciled. If this condition persists please check ClusterClass status. A ClusterClass is reconciled if" + - ".status.observedGeneration == .metadata.generation is true. If this is not the case either ClusterClass reconciliation failed or the ClusterClass is paused", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.ClusterInfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterControlPlaneAvailableV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterWorkersAvailableV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.ClusterWorkersNotAvailableV1Beta2Reason, + Message: "3 available replicas, at least 4 required (spec.strategy.rollout.maxUnavailable is 1, spec.replicas is 5) from MachineDeployment md1; 2 available replicas, at least 3 required (spec.strategy.rollout.maxUnavailable is 1, spec.replicas is 4) from MachinePool mp1", + }, + { + Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterDeletingV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: "Foo", + }, + { + Type: clusterv1.ClusterTopologyReconciledV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.ClusterTopologyReconciledClusterClassNotReconciledV1Beta2Reason, + Message: "ClusterClass not reconciled. If this condition persists please check ClusterClass status. A ClusterClass is reconciled if" + + ".status.observedGeneration == .metadata.generation is true. If this is not the case either ClusterClass reconciliation failed or the ClusterClass is paused", }, }, }, @@ -2996,24 +2972,15 @@ func (r v1beta2ReadyReplicas) ApplyToControlPlane(cp *unstructured.Unstructured) } func (r v1beta2ReadyReplicas) ApplyToMachinePool(mp *expv1.MachinePool) { - if mp.Status.V1Beta2 == nil { - mp.Status.V1Beta2 = &expv1.MachinePoolV1Beta2Status{} - } - mp.Status.V1Beta2.ReadyReplicas = ptr.To(int32(r)) + mp.Status.ReadyReplicas = ptr.To(int32(r)) } func (r v1beta2ReadyReplicas) ApplyToMachineDeployment(md *clusterv1.MachineDeployment) { - if md.Status.V1Beta2 == nil { - md.Status.V1Beta2 = &clusterv1.MachineDeploymentV1Beta2Status{} - } - md.Status.V1Beta2.ReadyReplicas = ptr.To(int32(r)) + md.Status.ReadyReplicas = ptr.To(int32(r)) } func (r v1beta2ReadyReplicas) ApplyToMachineSet(ms *clusterv1.MachineSet) { - if ms.Status.V1Beta2 == nil { - ms.Status.V1Beta2 = &clusterv1.MachineSetV1Beta2Status{} - } - ms.Status.V1Beta2.ReadyReplicas = ptr.To(int32(r)) + ms.Status.ReadyReplicas = ptr.To(int32(r)) } type v1beta2AvailableReplicas int32 @@ -3023,24 +2990,15 @@ func (r v1beta2AvailableReplicas) ApplyToControlPlane(cp *unstructured.Unstructu } func (r v1beta2AvailableReplicas) ApplyToMachinePool(mp *expv1.MachinePool) { - if mp.Status.V1Beta2 == nil { - mp.Status.V1Beta2 = &expv1.MachinePoolV1Beta2Status{} - } - mp.Status.V1Beta2.AvailableReplicas = ptr.To(int32(r)) + mp.Status.AvailableReplicas = ptr.To(int32(r)) } func (r v1beta2AvailableReplicas) ApplyToMachineDeployment(md *clusterv1.MachineDeployment) { - if md.Status.V1Beta2 == nil { - md.Status.V1Beta2 = &clusterv1.MachineDeploymentV1Beta2Status{} - } - md.Status.V1Beta2.AvailableReplicas = ptr.To(int32(r)) + md.Status.AvailableReplicas = ptr.To(int32(r)) } func (r v1beta2AvailableReplicas) ApplyToMachineSet(ms *clusterv1.MachineSet) { - if ms.Status.V1Beta2 == nil { - ms.Status.V1Beta2 = &clusterv1.MachineSetV1Beta2Status{} - } - ms.Status.V1Beta2.AvailableReplicas = ptr.To(int32(r)) + ms.Status.AvailableReplicas = ptr.To(int32(r)) } type v1beta2UpToDateReplicas int32 @@ -3050,24 +3008,15 @@ func (r v1beta2UpToDateReplicas) ApplyToControlPlane(cp *unstructured.Unstructur } func (r v1beta2UpToDateReplicas) ApplyToMachinePool(mp *expv1.MachinePool) { - if mp.Status.V1Beta2 == nil { - mp.Status.V1Beta2 = &expv1.MachinePoolV1Beta2Status{} - } - mp.Status.V1Beta2.UpToDateReplicas = ptr.To(int32(r)) + mp.Status.UpToDateReplicas = ptr.To(int32(r)) } func (r v1beta2UpToDateReplicas) ApplyToMachineDeployment(md *clusterv1.MachineDeployment) { - if md.Status.V1Beta2 == nil { - md.Status.V1Beta2 = &clusterv1.MachineDeploymentV1Beta2Status{} - } - md.Status.V1Beta2.UpToDateReplicas = ptr.To(int32(r)) + md.Status.UpToDateReplicas = ptr.To(int32(r)) } func (r v1beta2UpToDateReplicas) ApplyToMachineSet(ms *clusterv1.MachineSet) { - if ms.Status.V1Beta2 == nil { - ms.Status.V1Beta2 = &clusterv1.MachineSetV1Beta2Status{} - } - ms.Status.V1Beta2.UpToDateReplicas = ptr.To(int32(r)) + ms.Status.UpToDateReplicas = ptr.To(int32(r)) } type deleted bool @@ -3083,44 +3032,35 @@ func (s deleted) ApplyToCluster(c *clusterv1.Cluster) { type v1beta2Condition metav1.Condition func (c v1beta2Condition) ApplyToCluster(cluster *clusterv1.Cluster) { - if cluster.Status.V1Beta2 == nil { - cluster.Status.V1Beta2 = &clusterv1.ClusterV1Beta2Status{} - } v1beta2conditions.Set(cluster, metav1.Condition(c)) } func (c v1beta2Condition) ApplyToMachinePool(mp *expv1.MachinePool) { - if mp.Status.V1Beta2 == nil { - mp.Status.V1Beta2 = &expv1.MachinePoolV1Beta2Status{} - } v1beta2conditions.Set(mp, metav1.Condition(c)) } func (c v1beta2Condition) ApplyToMachineDeployment(md *clusterv1.MachineDeployment) { - if md.Status.V1Beta2 == nil { - md.Status.V1Beta2 = &clusterv1.MachineDeploymentV1Beta2Status{} - } v1beta2conditions.Set(md, metav1.Condition(c)) } func (c v1beta2Condition) ApplyToMachineSet(ms *clusterv1.MachineSet) { - if ms.Status.V1Beta2 == nil { - ms.Status.V1Beta2 = &clusterv1.MachineSetV1Beta2Status{} - } v1beta2conditions.Set(ms, metav1.Condition(c)) } func (c v1beta2Condition) ApplyToMachine(m *clusterv1.Machine) { - if m.Status.V1Beta2 == nil { - m.Status.V1Beta2 = &clusterv1.MachineV1Beta2Status{} - } v1beta2conditions.Set(m, metav1.Condition(c)) } type condition clusterv1.Condition func (c condition) ApplyToMachine(m *clusterv1.Machine) { - m.Status.Conditions = append(m.Status.Conditions, clusterv1.Condition(c)) + if m.Status.Deprecated == nil { + m.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.Conditions = append(m.Status.Deprecated.V1Beta1.Conditions, clusterv1.Condition(c)) } func (c condition) ApplyToControlPlane(cp *unstructured.Unstructured) { diff --git a/internal/controllers/machine/machine_controller_phases.go b/internal/controllers/machine/machine_controller_phases.go index 809f1d721b64..0e73d5bebccd 100644 --- a/internal/controllers/machine/machine_controller_phases.go +++ b/internal/controllers/machine/machine_controller_phases.go @@ -68,10 +68,22 @@ func (r *Reconciler) reconcileExternal(ctx context.Context, cluster *clusterv1.C } if failureReason != "" { machineStatusError := capierrors.MachineStatusError(failureReason) - m.Status.FailureReason = &machineStatusError + if m.Status.Deprecated == nil { + m.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.FailureReason = &machineStatusError } if failureMessage != "" { - m.Status.FailureMessage = ptr.To( + if m.Status.Deprecated == nil { + m.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.FailureMessage = ptr.To( fmt.Sprintf("Failure detected from referenced resource %v with name %q: %s", obj.GroupVersionKind(), obj.GetName(), failureMessage), ) @@ -253,8 +265,14 @@ func (r *Reconciler) reconcileInfrastructure(ctx context.Context, s *scope) (ctr if m.Status.InfrastructureReady { // Infra object went missing after the machine was up and running log.Error(err, "Machine infrastructure reference has been deleted after provisioning was completed, setting failure state") - m.Status.FailureReason = ptr.To(capierrors.InvalidConfigurationMachineError) - m.Status.FailureMessage = ptr.To(fmt.Sprintf("Machine infrastructure resource %v with name %q has been deleted after provisioning was completed", + if m.Status.Deprecated == nil { + m.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.FailureReason = ptr.To(capierrors.InvalidConfigurationMachineError) + m.Status.Deprecated.V1Beta1.FailureMessage = ptr.To(fmt.Sprintf("Machine infrastructure resource %v with name %q has been deleted after provisioning was completed", m.Spec.InfrastructureRef.GroupVersionKind(), m.Spec.InfrastructureRef.Name)) return ctrl.Result{}, errors.Errorf("could not find %v %q for Machine %q in namespace %q", m.Spec.InfrastructureRef.GroupVersionKind().String(), m.Spec.InfrastructureRef.Name, m.Name, m.Namespace) } diff --git a/internal/controllers/machine/machine_controller_phases_test.go b/internal/controllers/machine/machine_controller_phases_test.go index 6295d906c317..da34e71fc39e 100644 --- a/internal/controllers/machine/machine_controller_phases_test.go +++ b/internal/controllers/machine/machine_controller_phases_test.go @@ -433,8 +433,7 @@ func TestReconcileInfrastructure(t *testing.T) { expectError: false, expected: func(g *WithT, m *clusterv1.Machine) { g.Expect(m.Status.InfrastructureReady).To(BeFalse()) - g.Expect(m.Status.FailureMessage).To(BeNil()) - g.Expect(m.Status.FailureReason).To(BeNil()) + g.Expect(m.Status.Deprecated).To(BeNil()) }, }, { @@ -853,8 +852,7 @@ func TestReconcileInfrastructure(t *testing.T) { expectError: true, expected: func(g *WithT, m *clusterv1.Machine) { g.Expect(m.Status.InfrastructureReady).To(BeTrue()) - g.Expect(m.Status.FailureMessage).To(BeNil()) - g.Expect(m.Status.FailureReason).To(BeNil()) + g.Expect(m.Status.Deprecated).To(BeNil()) }, }, { @@ -883,8 +881,10 @@ func TestReconcileInfrastructure(t *testing.T) { expectError: true, expected: func(g *WithT, m *clusterv1.Machine) { g.Expect(m.Status.InfrastructureReady).To(BeTrue()) - g.Expect(m.Status.FailureMessage).ToNot(BeNil()) - g.Expect(m.Status.FailureReason).ToNot(BeNil()) + g.Expect(m.Status.Deprecated).ToNot(BeNil()) + g.Expect(m.Status.Deprecated.V1Beta1).ToNot(BeNil()) + g.Expect(m.Status.Deprecated.V1Beta1.FailureMessage).ToNot(BeNil()) + g.Expect(m.Status.Deprecated.V1Beta1.FailureReason).ToNot(BeNil()) }, }, { diff --git a/internal/controllers/machine/machine_controller_status.go b/internal/controllers/machine/machine_controller_status.go index 02321ca7149e..f10feb761bf2 100644 --- a/internal/controllers/machine/machine_controller_status.go +++ b/internal/controllers/machine/machine_controller_status.go @@ -804,7 +804,7 @@ func setMachinePhaseAndLastUpdated(_ context.Context, m *clusterv1.Machine) { } // Set the phase to "failed" if any of Status.FailureReason or Status.FailureMessage is not-nil. - if m.Status.FailureReason != nil || m.Status.FailureMessage != nil { + if m.Status.Deprecated != nil && m.Status.Deprecated.V1Beta1 != nil && (m.Status.Deprecated.V1Beta1.FailureReason != nil || m.Status.Deprecated.V1Beta1.FailureMessage != nil) { m.Status.SetTypedPhase(clusterv1.MachinePhaseFailed) } diff --git a/internal/controllers/machine/machine_controller_status_test.go b/internal/controllers/machine/machine_controller_status_test.go index 8874deacead4..f8314ca0247c 100644 --- a/internal/controllers/machine/machine_controller_status_test.go +++ b/internal/controllers/machine/machine_controller_status_test.go @@ -657,9 +657,13 @@ func TestSetNodeHealthyAndReadyConditions(t *testing.T) { }, Status: clusterv1.ClusterStatus{ InfrastructureReady: true, - Conditions: clusterv1.Conditions{ - {Type: clusterv1.ControlPlaneInitializedCondition, Status: corev1.ConditionTrue, - LastTransitionTime: metav1.Time{Time: now.Add(-5 * time.Second)}}, + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + {Type: clusterv1.ControlPlaneInitializedCondition, Status: corev1.ConditionTrue, + LastTransitionTime: metav1.Time{Time: now.Add(-5 * time.Second)}}, + }, + }, }, }, } @@ -936,9 +940,11 @@ func TestSetNodeHealthyAndReadyConditions(t *testing.T) { name: "connection down, preserve conditions as they have been set before (remote conditions grace period not passed yet)", cluster: func() *clusterv1.Cluster { c := defaultCluster.DeepCopy() - for i, condition := range c.Status.Conditions { - if condition.Type == clusterv1.ControlPlaneInitializedCondition { - c.Status.Conditions[i].LastTransitionTime.Time = now.Add(-4 * time.Minute) + if c.Status.Deprecated != nil && c.Status.Deprecated.V1Beta1 != nil { + for i, condition := range c.Status.Deprecated.V1Beta1.Conditions { + if condition.Type == clusterv1.ControlPlaneInitializedCondition { + c.Status.Deprecated.V1Beta1.Conditions[i].LastTransitionTime.Time = now.Add(-4 * time.Minute) + } } } return c @@ -982,9 +988,11 @@ func TestSetNodeHealthyAndReadyConditions(t *testing.T) { name: "connection down, set conditions as they haven't been set before (remote conditions grace period not passed yet)", cluster: func() *clusterv1.Cluster { c := defaultCluster.DeepCopy() - for i, condition := range c.Status.Conditions { - if condition.Type == clusterv1.ControlPlaneInitializedCondition { - c.Status.Conditions[i].LastTransitionTime.Time = now.Add(-4 * time.Minute) + if c.Status.Deprecated != nil && c.Status.Deprecated.V1Beta1 != nil { + for i, condition := range c.Status.Deprecated.V1Beta1.Conditions { + if condition.Type == clusterv1.ControlPlaneInitializedCondition { + c.Status.Deprecated.V1Beta1.Conditions[i].LastTransitionTime.Time = now.Add(-4 * time.Minute) + } } } return c @@ -1015,9 +1023,11 @@ func TestSetNodeHealthyAndReadyConditions(t *testing.T) { name: "connection down, set conditions to unknown (remote conditions grace period passed)", cluster: func() *clusterv1.Cluster { c := defaultCluster.DeepCopy() - for i, condition := range c.Status.Conditions { - if condition.Type == clusterv1.ControlPlaneInitializedCondition { - c.Status.Conditions[i].LastTransitionTime.Time = now.Add(-7 * time.Minute) + if c.Status.Deprecated != nil && c.Status.Deprecated.V1Beta1 != nil { + for i, condition := range c.Status.Deprecated.V1Beta1.Conditions { + if condition.Type == clusterv1.ControlPlaneInitializedCondition { + c.Status.Deprecated.V1Beta1.Conditions[i].LastTransitionTime.Time = now.Add(-7 * time.Minute) + } } } return c @@ -1180,14 +1190,12 @@ func TestDeletingCondition(t *testing.T) { DeletionTimestamp: &metav1.Time{Time: time.Now()}, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason, - Message: "Waiting for pre-drain hooks to succeed (hooks: test-hook)", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason, + Message: "Waiting for pre-drain hooks to succeed (hooks: test-hook)", }, }, }, @@ -1347,28 +1355,26 @@ func TestSetReadyCondition(t *testing.T) { Namespace: metav1.NamespaceDefault, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.InfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.MachineNodeHealthyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineNotDeletingV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.InfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.MachineNodeHealthyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineNotDeletingV1Beta2Reason, }, }, }, @@ -1388,29 +1394,27 @@ func TestSetReadyCondition(t *testing.T) { DeletionTimestamp: &metav1.Time{Time: time.Now()}, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineBootstrapConfigDoesNotExistV1Beta2Reason, - }, - { - Type: clusterv1.InfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineInfrastructureDeletedV1Beta2Reason, - }, - { - Type: clusterv1.MachineNodeHealthyV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineNodeDeletedV1Beta2Reason, - }, - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason, - Message: "Waiting for pre-drain hooks to succeed (hooks: test-hook)", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineBootstrapConfigDoesNotExistV1Beta2Reason, + }, + { + Type: clusterv1.InfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineInfrastructureDeletedV1Beta2Reason, + }, + { + Type: clusterv1.MachineNodeHealthyV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineNodeDeletedV1Beta2Reason, + }, + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason, + Message: "Waiting for pre-drain hooks to succeed (hooks: test-hook)", }, }, }, @@ -1431,28 +1435,27 @@ func TestSetReadyCondition(t *testing.T) { DeletionTimestamp: &metav1.Time{Time: time.Now()}, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.InfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.MachineNodeHealthyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineDeletingDrainingNodeV1Beta2Reason, - Message: `Drain not completed yet (started at 2024-10-09T16:13:59Z): + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.InfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.MachineNodeHealthyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineDeletingDrainingNodeV1Beta2Reason, + Message: `Drain not completed yet (started at 2024-10-09T16:13:59Z): * Pods with deletionTimestamp that still exist: pod-2-deletionTimestamp-set-1, pod-2-deletionTimestamp-set-2, pod-2-deletionTimestamp-set-3, pod-3-to-trigger-eviction-successfully-1, pod-3-to-trigger-eviction-successfully-2, ... (2 more) * Pods with eviction failed: * Cannot evict pod as it would violate the pod's disruption budget. The disruption budget pod-5-pdb needs 20 healthy pods and has 20 currently: pod-5-to-trigger-eviction-pdb-violated-1, pod-5-to-trigger-eviction-pdb-violated-2, pod-5-to-trigger-eviction-pdb-violated-3, ... (3 more) @@ -1461,7 +1464,6 @@ func TestSetReadyCondition(t *testing.T) { * some other error 3: pod-8-to-trigger-eviction-some-other-error * some other error 4: pod-9-to-trigger-eviction-some-other-error * ... (1 more error applying to 1 Pod)`, - }, }, }, }, @@ -1481,34 +1483,32 @@ func TestSetReadyCondition(t *testing.T) { Namespace: metav1.NamespaceDefault, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.InfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.MachineNodeHealthyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: "SomeReason", - Message: "Some message", - }, - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineNotDeletingV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.InfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.MachineNodeHealthyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: "SomeReason", + Message: "Some message", + }, + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineNotDeletingV1Beta2Reason, }, }, }, @@ -1539,45 +1539,43 @@ func TestSetReadyCondition(t *testing.T) { }, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.InfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.MachineNodeHealthyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: "MyReadinessGate", - Status: metav1.ConditionFalse, - Reason: "SomeReason", - Message: "Some message", - }, - { - Type: "MyReadinessGateGateWithNegativePolarity", - Status: metav1.ConditionTrue, - Reason: "SomeReason", - Message: "Some other message", - }, - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineNotDeletingV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.InfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.MachineNodeHealthyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: "MyReadinessGate", + Status: metav1.ConditionFalse, + Reason: "SomeReason", + Message: "Some message", + }, + { + Type: "MyReadinessGateGateWithNegativePolarity", + Status: metav1.ConditionTrue, + Reason: "SomeReason", + Message: "Some other message", + }, + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineNotDeletingV1Beta2Reason, }, }, }, @@ -1605,51 +1603,49 @@ func TestSetReadyCondition(t *testing.T) { }, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.InfrastructureReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.MachineNodeHealthyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: "Foo", - }, - { - Type: "APIServerSomething", - Status: metav1.ConditionFalse, - Reason: "SomeReason", - Message: "Some control plane message", - }, - { - Type: "ControllerManagerSomething", - Status: metav1.ConditionFalse, - Reason: "SomeReason", - Message: "Some control plane message", - }, - { - Type: "EtcdSomething", - Status: metav1.ConditionFalse, - Reason: "SomeReason", - Message: "Some etcd message", - }, - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineNotDeletingV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineBootstrapConfigReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.InfrastructureReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.MachineNodeHealthyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: "Foo", + }, + { + Type: "APIServerSomething", + Status: metav1.ConditionFalse, + Reason: "SomeReason", + Message: "Some control plane message", + }, + { + Type: "ControllerManagerSomething", + Status: metav1.ConditionFalse, + Reason: "SomeReason", + Message: "Some control plane message", + }, + { + Type: "EtcdSomething", + Status: metav1.ConditionFalse, + Reason: "SomeReason", + Message: "Some etcd message", + }, + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineNotDeletingV1Beta2Reason, }, }, }, @@ -1691,9 +1687,7 @@ func TestCalculateDeletingConditionForSummary(t *testing.T) { Namespace: metav1.NamespaceDefault, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{}, - }, + Conditions: []metav1.Condition{}, }, }, expectCondition: v1beta2conditions.ConditionWithOwnerInfo{ @@ -1718,19 +1712,17 @@ func TestCalculateDeletingConditionForSummary(t *testing.T) { DeletionTimestamp: &metav1.Time{Time: time.Now().Add(-16 * time.Minute)}, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineDeletingDrainingNodeV1Beta2Reason, - Message: `Drain not completed yet (started at 2024-10-09T16:13:59Z): + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineDeletingDrainingNodeV1Beta2Reason, + Message: `Drain not completed yet (started at 2024-10-09T16:13:59Z): * Pods pod-2-deletionTimestamp-set-1, pod-3-to-trigger-eviction-successfully-1: deletionTimestamp set, but still not removed from the Node * Pod pod-5-to-trigger-eviction-pdb-violated-1: cannot evict pod as it would violate the pod's disruption budget. The disruption budget pod-5-pdb needs 20 healthy pods and has 20 currently * Pod pod-6-to-trigger-eviction-some-other-error: failed to evict Pod, some other error 1 * Pod pod-9-wait-completed: waiting for completion After above Pods have been removed from the Node, the following Pods will be evicted: pod-7-eviction-later, pod-8-eviction-later`, - }, }, }, Deletion: &clusterv1.MachineDeletionStatus{ @@ -1760,14 +1752,12 @@ After above Pods have been removed from the Node, the following Pods will be evi DeletionTimestamp: &metav1.Time{Time: time.Now().Add(-16 * time.Minute)}, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineDeletingWaitingForVolumeDetachV1Beta2Reason, - Message: "Waiting for Node volumes to be detached (started at 2024-10-09T16:13:59Z)", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineDeletingWaitingForVolumeDetachV1Beta2Reason, + Message: "Waiting for Node volumes to be detached (started at 2024-10-09T16:13:59Z)", }, }, Deletion: &clusterv1.MachineDeletionStatus{ @@ -1796,14 +1786,12 @@ After above Pods have been removed from the Node, the following Pods will be evi Namespace: metav1.NamespaceDefault, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason, - Message: "Waiting for pre-drain hooks to succeed (hooks: test-hook)", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineDeletingWaitingForPreDrainHookV1Beta2Reason, + Message: "Waiting for pre-drain hooks to succeed (hooks: test-hook)", }, }, }, @@ -1846,13 +1834,11 @@ func TestAvailableCondition(t *testing.T) { Namespace: metav1.NamespaceDefault, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineReadyV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: "SomeReason", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineReadyV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: "SomeReason", }, }, }, @@ -1871,14 +1857,12 @@ func TestAvailableCondition(t *testing.T) { Namespace: metav1.NamespaceDefault, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineReadyV1Beta2Reason, - LastTransitionTime: metav1.Time{Time: time.Now().Add(10 * time.Second)}, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineReadyV1Beta2Reason, + LastTransitionTime: metav1.Time{Time: time.Now().Add(10 * time.Second)}, }, }, }, @@ -1897,14 +1881,12 @@ func TestAvailableCondition(t *testing.T) { Namespace: metav1.NamespaceDefault, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineReadyV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineReadyV1Beta2Reason, - LastTransitionTime: metav1.Time{Time: time.Now().Add(-10 * time.Second)}, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineReadyV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineReadyV1Beta2Reason, + LastTransitionTime: metav1.Time{Time: time.Now().Add(-10 * time.Second)}, }, }, }, diff --git a/internal/controllers/machine/machine_controller_test.go b/internal/controllers/machine/machine_controller_test.go index b80f04e894f3..80257098a333 100644 --- a/internal/controllers/machine/machine_controller_test.go +++ b/internal/controllers/machine/machine_controller_test.go @@ -194,7 +194,10 @@ func TestWatches(t *testing.T) { if err := env.Get(ctx, key, machine); err != nil { return false } - return machine.Status.FailureMessage != nil + if machine.Status.Deprecated == nil || machine.Status.Deprecated.V1Beta1 == nil { + return false + } + return machine.Status.Deprecated.V1Beta1.FailureMessage != nil }, timeout).Should(BeTrue()) } @@ -647,11 +650,11 @@ func TestMachineOwnerReference(t *testing.T) { ClusterName: "test-cluster", }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, } @@ -678,11 +681,11 @@ func TestMachineOwnerReference(t *testing.T) { ClusterName: "test-cluster", }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, } @@ -1062,11 +1065,11 @@ func TestMachineConditions(t *testing.T) { Name: "test", }, ObservedGeneration: 1, - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, } @@ -1300,11 +1303,11 @@ func TestRemoveMachineFinalizerAfterDeleteReconcile(t *testing.T) { Bootstrap: clusterv1.Bootstrap{DataSecretName: ptr.To("data")}, }, Status: clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, } key := client.ObjectKey{Namespace: m.Namespace, Name: m.Name} diff --git a/internal/controllers/machinedeployment/machinedeployment_rolling.go b/internal/controllers/machinedeployment/machinedeployment_rolling.go index 38954011c0b0..96147a829b04 100644 --- a/internal/controllers/machinedeployment/machinedeployment_rolling.go +++ b/internal/controllers/machinedeployment/machinedeployment_rolling.go @@ -157,8 +157,14 @@ func (r *Reconciler) reconcileOldMachineSets(ctx context.Context, allMSs []*clus // * The new MachineSet created must start with 0 replicas because allMachinesCount is already at 13. // * However, newMSMachinesUnavailable would also be 0, so the 2 old MachineSets could be scaled down by 5 (13 - 8 - 0), which would then // allow the new MachineSet to be scaled up by 5. + // TODO (v1beta2) + availableReplicas := int32(0) + if newMS.Status.Deprecated != nil && newMS.Status.Deprecated.V1Beta1 != nil { + availableReplicas = newMS.Status.Deprecated.V1Beta1.AvailableReplicas + } + minAvailable := *(deployment.Spec.Replicas) - maxUnavailable - newMSUnavailableMachineCount := *(newMS.Spec.Replicas) - newMS.Status.AvailableReplicas + newMSUnavailableMachineCount := *(newMS.Spec.Replicas) - availableReplicas maxScaledDown := allMachinesCount - minAvailable - newMSUnavailableMachineCount if maxScaledDown <= 0 { return nil @@ -212,7 +218,11 @@ func (r *Reconciler) cleanupUnhealthyReplicas(ctx context.Context, oldMSs []*clu continue } - oldMSAvailableReplicas := targetMS.Status.AvailableReplicas + // TODO (v1beta2) + oldMSAvailableReplicas := int32(0) + if targetMS.Status.Deprecated != nil && targetMS.Status.Deprecated.V1Beta1 != nil { + oldMSAvailableReplicas = targetMS.Status.Deprecated.V1Beta1.AvailableReplicas + } log.V(4).Info("Found available Machines in old MachineSet", "count", oldMSAvailableReplicas, "target-machineset", client.ObjectKeyFromObject(targetMS).String()) if oldMSReplicas == oldMSAvailableReplicas { diff --git a/internal/controllers/machinedeployment/machinedeployment_rolling_test.go b/internal/controllers/machinedeployment/machinedeployment_rolling_test.go index b3fce75fc9aa..696efda400ad 100644 --- a/internal/controllers/machinedeployment/machinedeployment_rolling_test.go +++ b/internal/controllers/machinedeployment/machinedeployment_rolling_test.go @@ -367,7 +367,11 @@ func TestReconcileOldMachineSets(t *testing.T) { Replicas: ptr.To[int32](0), }, Status: clusterv1.MachineSetStatus{ - AvailableReplicas: 2, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: 2, + }, + }, }, }, oldMachineSets: []*clusterv1.MachineSet{ @@ -380,7 +384,11 @@ func TestReconcileOldMachineSets(t *testing.T) { Replicas: ptr.To[int32](2), }, Status: clusterv1.MachineSetStatus{ - AvailableReplicas: 2, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: 2, + }, + }, }, }, { @@ -392,7 +400,11 @@ func TestReconcileOldMachineSets(t *testing.T) { Replicas: ptr.To[int32](1), }, Status: clusterv1.MachineSetStatus{ - AvailableReplicas: 1, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: 1, + }, + }, }, }, }, @@ -425,9 +437,13 @@ func TestReconcileOldMachineSets(t *testing.T) { Replicas: ptr.To[int32](5), }, Status: clusterv1.MachineSetStatus{ - Replicas: 5, - ReadyReplicas: 0, - AvailableReplicas: 0, + Replicas: 5, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + ReadyReplicas: 0, + AvailableReplicas: 0, + }, + }, }, }, oldMachineSets: []*clusterv1.MachineSet{ @@ -440,9 +456,13 @@ func TestReconcileOldMachineSets(t *testing.T) { Replicas: ptr.To[int32](8), }, Status: clusterv1.MachineSetStatus{ - Replicas: 10, - ReadyReplicas: 8, - AvailableReplicas: 8, + Replicas: 10, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + ReadyReplicas: 8, + AvailableReplicas: 8, + }, + }, }, }, }, diff --git a/internal/controllers/machinedeployment/machinedeployment_status.go b/internal/controllers/machinedeployment/machinedeployment_status.go index f041e7dabcd1..f68f1183113a 100644 --- a/internal/controllers/machinedeployment/machinedeployment_status.go +++ b/internal/controllers/machinedeployment/machinedeployment_status.go @@ -82,13 +82,9 @@ func (r *Reconciler) updateStatus(ctx context.Context, s *scope) (retErr error) // as a consequence it is required to compute the counters again before calling scale down machine sets, // and again to before computing the overall availability of the Machine deployment. func setReplicas(machineDeployment *clusterv1.MachineDeployment, machineSets []*clusterv1.MachineSet) { - if machineDeployment.Status.V1Beta2 == nil { - machineDeployment.Status.V1Beta2 = &clusterv1.MachineDeploymentV1Beta2Status{} - } - - machineDeployment.Status.V1Beta2.ReadyReplicas = mdutil.GetV1Beta2ReadyReplicaCountForMachineSets(machineSets) - machineDeployment.Status.V1Beta2.AvailableReplicas = mdutil.GetV1Beta2AvailableReplicaCountForMachineSets(machineSets) - machineDeployment.Status.V1Beta2.UpToDateReplicas = mdutil.GetV1Beta2UptoDateReplicaCountForMachineSets(machineSets) + machineDeployment.Status.ReadyReplicas = mdutil.GetV1Beta2ReadyReplicaCountForMachineSets(machineSets) + machineDeployment.Status.AvailableReplicas = mdutil.GetV1Beta2AvailableReplicaCountForMachineSets(machineSets) + machineDeployment.Status.UpToDateReplicas = mdutil.GetV1Beta2UptoDateReplicaCountForMachineSets(machineSets) } func setAvailableCondition(_ context.Context, machineDeployment *clusterv1.MachineDeployment, getAndAdoptMachineSetsForDeploymentSucceeded bool) { @@ -115,7 +111,7 @@ func setAvailableCondition(_ context.Context, machineDeployment *clusterv1.Machi } // Surface if .status.v1beta2.availableReplicas is not yet set. - if machineDeployment.Status.V1Beta2 == nil || machineDeployment.Status.V1Beta2.AvailableReplicas == nil { + if machineDeployment.Status.AvailableReplicas == nil { v1beta2conditions.Set(machineDeployment, metav1.Condition{ Type: clusterv1.MachineDeploymentAvailableV1Beta2Condition, Status: metav1.ConditionUnknown, @@ -128,7 +124,7 @@ func setAvailableCondition(_ context.Context, machineDeployment *clusterv1.Machi // minReplicasNeeded will be equal to md.Spec.Replicas when the strategy is not RollingUpdateMachineDeploymentStrategyType. minReplicasNeeded := *(machineDeployment.Spec.Replicas) - mdutil.MaxUnavailable(*machineDeployment) - if *machineDeployment.Status.V1Beta2.AvailableReplicas >= minReplicasNeeded { + if *machineDeployment.Status.AvailableReplicas >= minReplicasNeeded { v1beta2conditions.Set(machineDeployment, metav1.Condition{ Type: clusterv1.MachineDeploymentAvailableV1Beta2Condition, Status: metav1.ConditionTrue, @@ -137,7 +133,7 @@ func setAvailableCondition(_ context.Context, machineDeployment *clusterv1.Machi return } - message := fmt.Sprintf("%d available replicas, at least %d required", *machineDeployment.Status.V1Beta2.AvailableReplicas, minReplicasNeeded) + message := fmt.Sprintf("%d available replicas, at least %d required", *machineDeployment.Status.AvailableReplicas, minReplicasNeeded) if machineDeployment.Spec.Strategy != nil && mdutil.IsRollingUpdate(machineDeployment) && machineDeployment.Spec.Strategy.RollingUpdate != nil { message += fmt.Sprintf(" (spec.strategy.rollout.maxUnavailable is %s, spec.replicas is %d)", machineDeployment.Spec.Strategy.RollingUpdate.MaxUnavailable, *machineDeployment.Spec.Replicas) } diff --git a/internal/controllers/machinedeployment/machinedeployment_status_test.go b/internal/controllers/machinedeployment/machinedeployment_status_test.go index 53ed823d4d49..ccc36223c896 100644 --- a/internal/controllers/machinedeployment/machinedeployment_status_test.go +++ b/internal/controllers/machinedeployment/machinedeployment_status_test.go @@ -74,10 +74,9 @@ func Test_setReplicas(t *testing.T) { md := &clusterv1.MachineDeployment{} setReplicas(md, tt.machineSets) - g.Expect(md.Status.V1Beta2).ToNot(BeNil()) - g.Expect(md.Status.V1Beta2.ReadyReplicas).To(Equal(tt.expectReadyReplicas)) - g.Expect(md.Status.V1Beta2.AvailableReplicas).To(Equal(tt.expectAvailableReplicas)) - g.Expect(md.Status.V1Beta2.UpToDateReplicas).To(Equal(tt.expectUpToDateReplicas)) + g.Expect(md.Status.ReadyReplicas).To(Equal(tt.expectReadyReplicas)) + g.Expect(md.Status.AvailableReplicas).To(Equal(tt.expectAvailableReplicas)) + g.Expect(md.Status.UpToDateReplicas).To(Equal(tt.expectUpToDateReplicas)) }) } } @@ -137,7 +136,7 @@ func Test_setAvailableCondition(t *testing.T) { }, }, }, - Status: clusterv1.MachineDeploymentStatus{V1Beta2: &clusterv1.MachineDeploymentV1Beta2Status{AvailableReplicas: ptr.To(int32(5))}}, + Status: clusterv1.MachineDeploymentStatus{AvailableReplicas: ptr.To(int32(5))}, }, getAndAdoptMachineSetsForDeploymentSucceeded: true, expectCondition: metav1.Condition{ @@ -159,7 +158,7 @@ func Test_setAvailableCondition(t *testing.T) { }, }, }, - Status: clusterv1.MachineDeploymentStatus{V1Beta2: &clusterv1.MachineDeploymentV1Beta2Status{AvailableReplicas: ptr.To(int32(4))}}, + Status: clusterv1.MachineDeploymentStatus{AvailableReplicas: ptr.To(int32(4))}, }, getAndAdoptMachineSetsForDeploymentSucceeded: true, expectCondition: metav1.Condition{ @@ -181,7 +180,7 @@ func Test_setAvailableCondition(t *testing.T) { }, }, }, - Status: clusterv1.MachineDeploymentStatus{V1Beta2: &clusterv1.MachineDeploymentV1Beta2Status{AvailableReplicas: ptr.To(int32(3))}}, + Status: clusterv1.MachineDeploymentStatus{AvailableReplicas: ptr.To(int32(3))}, }, getAndAdoptMachineSetsForDeploymentSucceeded: true, expectCondition: metav1.Condition{ @@ -207,7 +206,7 @@ func Test_setAvailableCondition(t *testing.T) { }, }, }, - Status: clusterv1.MachineDeploymentStatus{V1Beta2: &clusterv1.MachineDeploymentV1Beta2Status{AvailableReplicas: ptr.To(int32(0))}}, + Status: clusterv1.MachineDeploymentStatus{AvailableReplicas: ptr.To(int32(0))}, }, getAndAdoptMachineSetsForDeploymentSucceeded: true, expectCondition: metav1.Condition{ @@ -650,19 +649,17 @@ func Test_setScalingDownCondition(t *testing.T) { fakeMachine("m1"), fakeMachine("stale-machine-1", withStaleDeletion(), func(m *clusterv1.Machine) { m.Status = clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineDeletingDrainingNodeV1Beta2Reason, - Message: `Drain not completed yet (started at 2024-10-09T16:13:59Z): + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineDeletingDrainingNodeV1Beta2Reason, + Message: `Drain not completed yet (started at 2024-10-09T16:13:59Z): * Pods pod-2-deletionTimestamp-set-1, pod-3-to-trigger-eviction-successfully-1: deletionTimestamp set, but still not removed from the Node * Pod pod-5-to-trigger-eviction-pdb-violated-1: cannot evict pod as it would violate the pod's disruption budget. The disruption budget pod-5-pdb needs 20 healthy pods and has 20 currently * Pod pod-6-to-trigger-eviction-some-other-error: failed to evict Pod, some other error 1 * Pod pod-9-wait-completed: waiting for completion After above Pods have been removed from the Node, the following Pods will be evicted: pod-7-eviction-later, pod-8-eviction-later`, - }, }, }, Deletion: &clusterv1.MachineDeletionStatus{ @@ -1293,28 +1290,19 @@ func withStatusReplicas(n int32) fakeMachineSetOption { func withStatusV1beta2ReadyReplicas(n int32) fakeMachineSetOption { return func(ms *clusterv1.MachineSet) { - if ms.Status.V1Beta2 == nil { - ms.Status.V1Beta2 = &clusterv1.MachineSetV1Beta2Status{} - } - ms.Status.V1Beta2.ReadyReplicas = ptr.To(n) + ms.Status.ReadyReplicas = ptr.To(n) } } func withStatusV1beta2AvailableReplicas(n int32) fakeMachineSetOption { return func(ms *clusterv1.MachineSet) { - if ms.Status.V1Beta2 == nil { - ms.Status.V1Beta2 = &clusterv1.MachineSetV1Beta2Status{} - } - ms.Status.V1Beta2.AvailableReplicas = ptr.To(n) + ms.Status.AvailableReplicas = ptr.To(n) } } func withStatusV1beta2UpToDateReplicas(n int32) fakeMachineSetOption { return func(ms *clusterv1.MachineSet) { - if ms.Status.V1Beta2 == nil { - ms.Status.V1Beta2 = &clusterv1.MachineSetV1Beta2Status{} - } - ms.Status.V1Beta2.UpToDateReplicas = ptr.To(n) + ms.Status.UpToDateReplicas = ptr.To(n) } } @@ -1346,15 +1334,18 @@ func withStaleDeletion() fakeMachinesOption { func withV1Beta2Condition(c metav1.Condition) fakeMachinesOption { return func(m *clusterv1.Machine) { - if m.Status.V1Beta2 == nil { - m.Status.V1Beta2 = &clusterv1.MachineV1Beta2Status{} - } v1beta2conditions.Set(m, c) } } func withConditions(c ...clusterv1.Condition) fakeMachinesOption { return func(m *clusterv1.Machine) { - m.Status.Conditions = append(m.Status.Conditions, c...) + if m.Status.Deprecated == nil { + m.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.Conditions = append(m.Status.Deprecated.V1Beta1.Conditions, c...) } } diff --git a/internal/controllers/machinedeployment/machinedeployment_sync.go b/internal/controllers/machinedeployment/machinedeployment_sync.go index 569b61dcae54..a00c68926f8a 100644 --- a/internal/controllers/machinedeployment/machinedeployment_sync.go +++ b/internal/controllers/machinedeployment/machinedeployment_sync.go @@ -482,7 +482,12 @@ func (r *Reconciler) syncDeploymentStatus(allMSs []*clusterv1.MachineSet, newMS // minReplicasNeeded will be equal to md.Spec.Replicas when the strategy is not RollingUpdateMachineDeploymentStrategyType. minReplicasNeeded := *(md.Spec.Replicas) - mdutil.MaxUnavailable(*md) - if md.Status.AvailableReplicas >= minReplicasNeeded { + // TODO: v1beta2 + availableReplicas := int32(0) + if md.Status.Deprecated != nil && md.Status.Deprecated.V1Beta1 != nil { + availableReplicas = md.Status.Deprecated.V1Beta1.AvailableReplicas + } + if availableReplicas >= minReplicasNeeded { // NOTE: The structure of calculateStatus() does not allow us to update the machinedeployment directly, we can only update the status obj it returns. Ideally, we should change calculateStatus() --> updateStatus() to be consistent with the rest of the code base, until then, we update conditions here. conditions.MarkTrue(md, clusterv1.MachineDeploymentAvailableCondition) } else { @@ -520,25 +525,37 @@ func calculateStatus(allMSs []*clusterv1.MachineSet, newMS *clusterv1.MachineSet // Calculate the label selector. We check the error in the MD reconcile function, ignore here. selector, _ := metav1.LabelSelectorAsSelector(&deployment.Spec.Selector) + // TODO (v1beta2) + var conditions clusterv1.Conditions + if deployment.Status.Deprecated != nil && deployment.Status.Deprecated.V1Beta1 != nil { + conditions = deployment.Status.Deprecated.V1Beta1.Conditions + } + status := clusterv1.MachineDeploymentStatus{ // TODO: Ensure that if we start retrying status updates, we won't pick up a new Generation value. - ObservedGeneration: deployment.Generation, - Selector: selector.String(), - Replicas: mdutil.GetActualReplicaCountForMachineSets(allMSs), - UpdatedReplicas: mdutil.GetActualReplicaCountForMachineSets([]*clusterv1.MachineSet{newMS}), - ReadyReplicas: mdutil.GetReadyReplicaCountForMachineSets(allMSs), - AvailableReplicas: availableReplicas, - UnavailableReplicas: unavailableReplicas, - Conditions: deployment.Status.Conditions, - + ObservedGeneration: deployment.Generation, + Selector: selector.String(), + Replicas: mdutil.GetActualReplicaCountForMachineSets(allMSs), + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + Conditions: conditions, + UpdatedReplicas: mdutil.GetActualReplicaCountForMachineSets([]*clusterv1.MachineSet{newMS}), + ReadyReplicas: mdutil.GetReadyReplicaCountForMachineSets(allMSs), + AvailableReplicas: availableReplicas, + UnavailableReplicas: unavailableReplicas, + }, + }, // preserve v1beta2 status - V1Beta2: deployment.Status.V1Beta2, + Conditions: deployment.Status.Conditions, + AvailableReplicas: deployment.Status.AvailableReplicas, + ReadyReplicas: deployment.Status.ReadyReplicas, + UpToDateReplicas: deployment.Status.UpToDateReplicas, } - if *deployment.Spec.Replicas == status.ReadyReplicas { + if *deployment.Spec.Replicas == status.Deprecated.V1Beta1.ReadyReplicas { status.Phase = string(clusterv1.MachineDeploymentPhaseRunning) } - if *deployment.Spec.Replicas > status.ReadyReplicas { + if *deployment.Spec.Replicas > status.Deprecated.V1Beta1.ReadyReplicas { status.Phase = string(clusterv1.MachineDeploymentPhaseScalingUp) } // This is the same as unavailableReplicas, but we have to recalculate because unavailableReplicas @@ -548,7 +565,7 @@ func calculateStatus(allMSs []*clusterv1.MachineSet, newMS *clusterv1.MachineSet } for _, ms := range allMSs { if ms != nil { - if ms.Status.FailureReason != nil || ms.Status.FailureMessage != nil { + if ms.Status.Deprecated != nil && ms.Status.Deprecated.V1Beta1 != nil && (ms.Status.Deprecated.V1Beta1.FailureReason != nil || ms.Status.Deprecated.V1Beta1.FailureMessage != nil) { status.Phase = string(clusterv1.MachineDeploymentPhaseFailed) break } diff --git a/internal/controllers/machinedeployment/machinedeployment_sync_test.go b/internal/controllers/machinedeployment/machinedeployment_sync_test.go index 9242c14d488a..c4fac8757f2a 100644 --- a/internal/controllers/machinedeployment/machinedeployment_sync_test.go +++ b/internal/controllers/machinedeployment/machinedeployment_sync_test.go @@ -55,10 +55,14 @@ func TestCalculateStatus(t *testing.T) { Replicas: ptr.To[int32](2), }, Status: clusterv1.MachineSetStatus{ - Selector: "", - AvailableReplicas: 2, - ReadyReplicas: 2, - Replicas: 2, + Selector: "", + Replicas: 2, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: 2, + ReadyReplicas: 2, + }, + }, ObservedGeneration: 1, }, }}, @@ -67,10 +71,14 @@ func TestCalculateStatus(t *testing.T) { Replicas: ptr.To[int32](2), }, Status: clusterv1.MachineSetStatus{ - Selector: "", - AvailableReplicas: 2, - ReadyReplicas: 2, - Replicas: 2, + Selector: "", + Replicas: 2, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: 2, + ReadyReplicas: 2, + }, + }, ObservedGeneration: 1, }, }, @@ -83,13 +91,17 @@ func TestCalculateStatus(t *testing.T) { }, }, expectedStatus: clusterv1.MachineDeploymentStatus{ - ObservedGeneration: 2, - Replicas: 2, - UpdatedReplicas: 2, - ReadyReplicas: 2, - AvailableReplicas: 2, - UnavailableReplicas: 0, - Phase: "Running", + ObservedGeneration: 2, + Replicas: 2, + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: 2, + ReadyReplicas: 2, + AvailableReplicas: 2, + UnavailableReplicas: 0, + }, + }, + Phase: "Running", }, }, "scaling up": { @@ -98,10 +110,14 @@ func TestCalculateStatus(t *testing.T) { Replicas: ptr.To[int32](2), }, Status: clusterv1.MachineSetStatus{ - Selector: "", - AvailableReplicas: 1, - ReadyReplicas: 1, - Replicas: 2, + Selector: "", + Replicas: 2, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: 1, + ReadyReplicas: 1, + }, + }, ObservedGeneration: 1, }, }}, @@ -110,10 +126,14 @@ func TestCalculateStatus(t *testing.T) { Replicas: ptr.To[int32](2), }, Status: clusterv1.MachineSetStatus{ - Selector: "", - AvailableReplicas: 1, - ReadyReplicas: 1, - Replicas: 2, + Selector: "", + Replicas: 2, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: 1, + ReadyReplicas: 1, + }, + }, ObservedGeneration: 1, }, }, @@ -126,13 +146,17 @@ func TestCalculateStatus(t *testing.T) { }, }, expectedStatus: clusterv1.MachineDeploymentStatus{ - ObservedGeneration: 2, - Replicas: 2, - UpdatedReplicas: 2, - ReadyReplicas: 1, - AvailableReplicas: 1, - UnavailableReplicas: 1, - Phase: "ScalingUp", + ObservedGeneration: 2, + Replicas: 2, + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: 2, + ReadyReplicas: 1, + AvailableReplicas: 1, + UnavailableReplicas: 1, + }, + }, + Phase: "ScalingUp", }, }, "scaling down": { @@ -141,10 +165,14 @@ func TestCalculateStatus(t *testing.T) { Replicas: ptr.To[int32](2), }, Status: clusterv1.MachineSetStatus{ - Selector: "", - AvailableReplicas: 3, - ReadyReplicas: 2, - Replicas: 2, + Selector: "", + Replicas: 2, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: 3, + ReadyReplicas: 2, + }, + }, ObservedGeneration: 1, }, }}, @@ -153,10 +181,14 @@ func TestCalculateStatus(t *testing.T) { Replicas: ptr.To[int32](2), }, Status: clusterv1.MachineSetStatus{ - Selector: "", - AvailableReplicas: 3, - ReadyReplicas: 2, - Replicas: 2, + Selector: "", + Replicas: 2, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: 3, + ReadyReplicas: 2, + }, + }, ObservedGeneration: 1, }, }, @@ -169,13 +201,17 @@ func TestCalculateStatus(t *testing.T) { }, }, expectedStatus: clusterv1.MachineDeploymentStatus{ - ObservedGeneration: 2, - Replicas: 2, - UpdatedReplicas: 2, - ReadyReplicas: 2, - AvailableReplicas: 3, - UnavailableReplicas: 0, - Phase: "ScalingDown", + ObservedGeneration: 2, + Replicas: 2, + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: 2, + ReadyReplicas: 2, + AvailableReplicas: 3, + UnavailableReplicas: 0, + }, + }, + Phase: "ScalingDown", }, }, "MachineSet failed": { @@ -184,12 +220,16 @@ func TestCalculateStatus(t *testing.T) { Replicas: ptr.To[int32](2), }, Status: clusterv1.MachineSetStatus{ - Selector: "", - AvailableReplicas: 0, - ReadyReplicas: 0, - Replicas: 2, + Selector: "", + Replicas: 2, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: 0, + ReadyReplicas: 0, + FailureReason: &msStatusError, + }, + }, ObservedGeneration: 1, - FailureReason: &msStatusError, }, }}, newMachineSet: &clusterv1.MachineSet{ @@ -197,10 +237,14 @@ func TestCalculateStatus(t *testing.T) { Replicas: ptr.To[int32](2), }, Status: clusterv1.MachineSetStatus{ - Selector: "", - AvailableReplicas: 0, - ReadyReplicas: 0, - Replicas: 2, + Selector: "", + Replicas: 2, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: 0, + ReadyReplicas: 0, + }, + }, ObservedGeneration: 1, }, }, @@ -213,13 +257,17 @@ func TestCalculateStatus(t *testing.T) { }, }, expectedStatus: clusterv1.MachineDeploymentStatus{ - ObservedGeneration: 2, - Replicas: 2, - UpdatedReplicas: 2, - ReadyReplicas: 0, - AvailableReplicas: 0, - UnavailableReplicas: 2, - Phase: "Failed", + ObservedGeneration: 2, + Replicas: 2, + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: 2, + ReadyReplicas: 0, + AvailableReplicas: 0, + UnavailableReplicas: 2, + }, + }, + Phase: "Failed", }, }, } @@ -420,10 +468,14 @@ func newTestMachineDeployment(pds *int32, replicas, statusReplicas, updatedRepli }, }, Status: clusterv1.MachineDeploymentStatus{ - Replicas: statusReplicas, - UpdatedReplicas: updatedReplicas, - AvailableReplicas: availableReplicas, - Conditions: conditions, + Replicas: statusReplicas, + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: updatedReplicas, + AvailableReplicas: availableReplicas, + Conditions: conditions, + }, + }, }, } return d @@ -441,9 +493,13 @@ func newTestMachinesetWithReplicas(name string, specReplicas, statusReplicas, av Replicas: ptr.To[int32](specReplicas), }, Status: clusterv1.MachineSetStatus{ - AvailableReplicas: availableReplicas, - Replicas: statusReplicas, - Conditions: conditions, + Replicas: statusReplicas, + Deprecated: &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: availableReplicas, + Conditions: conditions, + }, + }, }, } } diff --git a/internal/controllers/machinedeployment/mdutil/util.go b/internal/controllers/machinedeployment/mdutil/util.go index ac3153d39d32..83af18152708 100644 --- a/internal/controllers/machinedeployment/mdutil/util.go +++ b/internal/controllers/machinedeployment/mdutil/util.go @@ -570,7 +570,12 @@ func GetReadyReplicaCountForMachineSets(machineSets []*clusterv1.MachineSet) int totalReadyReplicas := int32(0) for _, ms := range machineSets { if ms != nil { - totalReadyReplicas += ms.Status.ReadyReplicas + // TODO (v1beta2) + readyReplicas := int32(0) + if ms.Status.Deprecated != nil && ms.Status.Deprecated.V1Beta1 != nil { + readyReplicas = ms.Status.Deprecated.V1Beta1.ReadyReplicas + } + totalReadyReplicas += readyReplicas } } return totalReadyReplicas @@ -581,7 +586,11 @@ func GetAvailableReplicaCountForMachineSets(machineSets []*clusterv1.MachineSet) totalAvailableReplicas := int32(0) for _, ms := range machineSets { if ms != nil { - totalAvailableReplicas += ms.Status.AvailableReplicas + availableReplicas := int32(0) + if ms.Status.Deprecated != nil && ms.Status.Deprecated.V1Beta1 != nil { + availableReplicas = ms.Status.Deprecated.V1Beta1.AvailableReplicas + } + totalAvailableReplicas += availableReplicas } } return totalAvailableReplicas @@ -592,8 +601,8 @@ func GetAvailableReplicaCountForMachineSets(machineSets []*clusterv1.MachineSet) func GetV1Beta2ReadyReplicaCountForMachineSets(machineSets []*clusterv1.MachineSet) *int32 { var totalReadyReplicas *int32 for _, ms := range machineSets { - if ms != nil && ms.Status.V1Beta2 != nil && ms.Status.V1Beta2.ReadyReplicas != nil { - totalReadyReplicas = ptr.To(ptr.Deref(totalReadyReplicas, 0) + *ms.Status.V1Beta2.ReadyReplicas) + if ms != nil && ms.Status.ReadyReplicas != nil { + totalReadyReplicas = ptr.To(ptr.Deref(totalReadyReplicas, 0) + *ms.Status.ReadyReplicas) } } return totalReadyReplicas @@ -604,8 +613,8 @@ func GetV1Beta2ReadyReplicaCountForMachineSets(machineSets []*clusterv1.MachineS func GetV1Beta2AvailableReplicaCountForMachineSets(machineSets []*clusterv1.MachineSet) *int32 { var totalAvailableReplicas *int32 for _, ms := range machineSets { - if ms != nil && ms.Status.V1Beta2 != nil && ms.Status.V1Beta2.AvailableReplicas != nil { - totalAvailableReplicas = ptr.To(ptr.Deref(totalAvailableReplicas, 0) + *ms.Status.V1Beta2.AvailableReplicas) + if ms != nil && ms.Status.AvailableReplicas != nil { + totalAvailableReplicas = ptr.To(ptr.Deref(totalAvailableReplicas, 0) + *ms.Status.AvailableReplicas) } } return totalAvailableReplicas @@ -616,8 +625,8 @@ func GetV1Beta2AvailableReplicaCountForMachineSets(machineSets []*clusterv1.Mach func GetV1Beta2UptoDateReplicaCountForMachineSets(machineSets []*clusterv1.MachineSet) *int32 { var totalUpToDateReplicas *int32 for _, ms := range machineSets { - if ms != nil && ms.Status.V1Beta2 != nil && ms.Status.V1Beta2.UpToDateReplicas != nil { - totalUpToDateReplicas = ptr.To(ptr.Deref(totalUpToDateReplicas, 0) + *ms.Status.V1Beta2.UpToDateReplicas) + if ms != nil && ms.Status.UpToDateReplicas != nil { + totalUpToDateReplicas = ptr.To(ptr.Deref(totalUpToDateReplicas, 0) + *ms.Status.UpToDateReplicas) } } return totalUpToDateReplicas @@ -631,9 +640,18 @@ func IsRollingUpdate(deployment *clusterv1.MachineDeployment) bool { // DeploymentComplete considers a deployment to be complete once all of its desired replicas // are updated and available, and no old machines are running. func DeploymentComplete(deployment *clusterv1.MachineDeployment, newStatus *clusterv1.MachineDeploymentStatus) bool { - return newStatus.UpdatedReplicas == *(deployment.Spec.Replicas) && + // TODO (v1beta2) + updatedReplicas := int32(0) + if newStatus.Deprecated != nil && newStatus.Deprecated.V1Beta1 != nil { + updatedReplicas = newStatus.Deprecated.V1Beta1.UpdatedReplicas + } + availableReplicas := int32(0) + if newStatus.Deprecated != nil && newStatus.Deprecated.V1Beta1 != nil { + availableReplicas = newStatus.Deprecated.V1Beta1.AvailableReplicas + } + return updatedReplicas == *(deployment.Spec.Replicas) && newStatus.Replicas == *(deployment.Spec.Replicas) && - newStatus.AvailableReplicas == *(deployment.Spec.Replicas) && + availableReplicas == *(deployment.Spec.Replicas) && newStatus.ObservedGeneration >= deployment.Generation } @@ -691,9 +709,14 @@ func IsSaturated(deployment *clusterv1.MachineDeployment, ms *clusterv1.MachineS if err != nil { return false } + // TODO (v1beta2) + availableReplicas := int32(0) + if ms.Status.Deprecated != nil && ms.Status.Deprecated.V1Beta1 != nil { + availableReplicas = ms.Status.Deprecated.V1Beta1.AvailableReplicas + } return *(ms.Spec.Replicas) == *(deployment.Spec.Replicas) && int32(desired) == *(deployment.Spec.Replicas) && - ms.Status.AvailableReplicas == *(deployment.Spec.Replicas) + availableReplicas == *(deployment.Spec.Replicas) } // ResolveFenceposts resolves both maxSurge and maxUnavailable. This needs to happen in one diff --git a/internal/controllers/machinedeployment/mdutil/util_test.go b/internal/controllers/machinedeployment/mdutil/util_test.go index 390c859076a2..c32a3b71d5dc 100644 --- a/internal/controllers/machinedeployment/mdutil/util_test.go +++ b/internal/controllers/machinedeployment/mdutil/util_test.go @@ -783,9 +783,13 @@ func TestDeploymentComplete(t *testing.T) { }, }, Status: clusterv1.MachineDeploymentStatus{ - Replicas: current, - UpdatedReplicas: updated, - AvailableReplicas: available, + Replicas: current, + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: updated, + AvailableReplicas: available, + }, + }, }, } } @@ -931,7 +935,11 @@ func TestAnnotationUtils(t *testing.T) { // Test Case 2: Check if annotations reflect deployments state tMS.Annotations[clusterv1.DesiredReplicasAnnotation] = "1" - tMS.Status.AvailableReplicas = 1 + tMS.Status.Deprecated = &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{ + AvailableReplicas: 1, + }, + } tMS.Spec.Replicas = new(int32) *tMS.Spec.Replicas = 1 diff --git a/internal/controllers/machinehealthcheck/machinehealthcheck_controller_test.go b/internal/controllers/machinehealthcheck/machinehealthcheck_controller_test.go index d8c3c4b505b5..76da975d2131 100644 --- a/internal/controllers/machinehealthcheck/machinehealthcheck_controller_test.go +++ b/internal/controllers/machinehealthcheck/machinehealthcheck_controller_test.go @@ -235,19 +235,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 2, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -297,19 +299,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 2, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -356,19 +360,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 2, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -445,19 +451,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 2, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -515,19 +523,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 2, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -623,19 +633,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 2, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -732,23 +744,25 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 0, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionFalse, - Severity: clusterv1.ConditionSeverityWarning, - Reason: clusterv1.TooManyUnhealthyReason, - Message: "Remediation is not allowed, the number of not started or unhealthy machines exceeds maxUnhealthy (total: 3, unhealthy: 2, maxUnhealthy: 40%)", + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionFalse, + Severity: clusterv1.ConditionSeverityWarning, + Reason: clusterv1.TooManyUnhealthyReason, + Message: "Remediation is not allowed, the number of not started or unhealthy machines exceeds maxUnhealthy (total: 3, unhealthy: 2, maxUnhealthy: 40%)", + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineHealthCheckTooManyUnhealthyV1Beta2Reason, - Message: "Remediation is not allowed, the number of not started or unhealthy machines exceeds maxUnhealthy (total: 3, unhealthy: 2, maxUnhealthy: 40%)", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineHealthCheckTooManyUnhealthyV1Beta2Reason, + Message: "Remediation is not allowed, the number of not started or unhealthy machines exceeds maxUnhealthy (total: 3, unhealthy: 2, maxUnhealthy: 40%)", }, }, })) @@ -807,19 +821,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 2, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -878,23 +894,25 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 0, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionFalse, - Severity: clusterv1.ConditionSeverityWarning, - Reason: clusterv1.TooManyUnhealthyReason, - Message: "Remediation is not allowed, the number of not started or unhealthy machines does not fall within the range (total: 3, unhealthy: 2, unhealthyRange: [3-5])", + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionFalse, + Severity: clusterv1.ConditionSeverityWarning, + Reason: clusterv1.TooManyUnhealthyReason, + Message: "Remediation is not allowed, the number of not started or unhealthy machines does not fall within the range (total: 3, unhealthy: 2, unhealthyRange: [3-5])", + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineHealthCheckTooManyUnhealthyV1Beta2Reason, - Message: "Remediation is not allowed, the number of not started or unhealthy machines does not fall within the range (total: 3, unhealthy: 2, unhealthyRange: [3-5])", - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineHealthCheckTooManyUnhealthyV1Beta2Reason, + Message: "Remediation is not allowed, the number of not started or unhealthy machines does not fall within the range (total: 3, unhealthy: 2, unhealthyRange: [3-5])", }, }, })) @@ -960,19 +978,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 2, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -1033,19 +1053,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 2, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -1103,19 +1125,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 2, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -1165,19 +1189,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 3, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -1225,19 +1251,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 1, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -1269,19 +1297,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { CurrentHealthy: 0, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -1458,19 +1488,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { CurrentHealthy: 1, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -1507,19 +1539,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 0, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -1596,19 +1630,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 1, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -1641,19 +1677,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 0, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -1751,19 +1789,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 1, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -1796,19 +1836,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 0, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -1841,19 +1883,21 @@ func TestMachineHealthCheck_Reconcile(t *testing.T) { RemediationsAllowed: 1, ObservedGeneration: 1, Targets: targetMachines, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.RemediationAllowedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.MachineHealthCheckDeprecatedStatus{ + V1Beta1: &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.RemediationAllowedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, - V1Beta2: &clusterv1.MachineHealthCheckV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, - }, + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckRemediationAllowedV1Beta2Reason, }, }, })) @@ -2633,10 +2677,22 @@ func createMachinesWithNodes( if o.failureReason != "" { failureReason := capierrors.MachineStatusError(o.failureReason) - machine.Status.FailureReason = &failureReason + if machine.Status.Deprecated == nil { + machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} + } + if machine.Status.Deprecated.V1Beta1 == nil { + machine.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + } + machine.Status.Deprecated.V1Beta1.FailureReason = &failureReason } if o.failureMessage != "" { - machine.Status.FailureMessage = ptr.To(o.failureMessage) + if machine.Status.Deprecated == nil { + machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} + } + if machine.Status.Deprecated.V1Beta1 == nil { + machine.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + } + machine.Status.Deprecated.V1Beta1.FailureMessage = ptr.To(o.failureMessage) } // Adding one second to ensure there is a difference from the diff --git a/internal/controllers/machinehealthcheck/machinehealthcheck_status_matcher_test.go b/internal/controllers/machinehealthcheck/machinehealthcheck_status_matcher_test.go index 316e56e95a56..2402521d7817 100644 --- a/internal/controllers/machinehealthcheck/machinehealthcheck_status_matcher_test.go +++ b/internal/controllers/machinehealthcheck/machinehealthcheck_status_matcher_test.go @@ -59,7 +59,15 @@ func (m machineHealthCheckStatusMatcher) Match(actual interface{}) (success bool if !ok { return ok, err } - ok, err = conditions.MatchConditions(m.expected.Conditions).Match(actualStatus.Conditions) + var mConditions clusterv1.Conditions + if m.expected.Deprecated != nil && m.expected.Deprecated.V1Beta1 != nil { + mConditions = m.expected.Deprecated.V1Beta1.Conditions + } + var actualConditions clusterv1.Conditions + if actualStatus.Deprecated != nil && actualStatus.Deprecated.V1Beta1 != nil { + actualConditions = actualStatus.Deprecated.V1Beta1.Conditions + } + ok, err = conditions.MatchConditions(mConditions).Match(actualConditions) return ok, err } diff --git a/internal/controllers/machinehealthcheck/machinehealthcheck_targets.go b/internal/controllers/machinehealthcheck/machinehealthcheck_targets.go index e84d7590e839..b2a833071c54 100644 --- a/internal/controllers/machinehealthcheck/machinehealthcheck_targets.go +++ b/internal/controllers/machinehealthcheck/machinehealthcheck_targets.go @@ -99,15 +99,15 @@ func (t *healthCheckTarget) needsRemediation(logger logr.Logger, timeoutForMachi return true, time.Duration(0) } - if t.Machine.Status.FailureReason != nil { - conditions.MarkFalse(t.Machine, clusterv1.MachineHealthCheckSucceededCondition, clusterv1.MachineHasFailureReason, clusterv1.ConditionSeverityWarning, "FailureReason: %v", *t.Machine.Status.FailureReason) - logger.V(3).Info("Target is unhealthy", "failureReason", t.Machine.Status.FailureReason) + if t.Machine.Status.Deprecated != nil && t.Machine.Status.Deprecated.V1Beta1 != nil && t.Machine.Status.Deprecated.V1Beta1.FailureReason != nil { + conditions.MarkFalse(t.Machine, clusterv1.MachineHealthCheckSucceededCondition, clusterv1.MachineHasFailureReason, clusterv1.ConditionSeverityWarning, "FailureReason: %v", *t.Machine.Status.Deprecated.V1Beta1.FailureReason) + logger.V(3).Info("Target is unhealthy", "failureReason", t.Machine.Status.Deprecated.V1Beta1.FailureReason) return true, time.Duration(0) } - if t.Machine.Status.FailureMessage != nil { - conditions.MarkFalse(t.Machine, clusterv1.MachineHealthCheckSucceededCondition, clusterv1.MachineHasFailureReason, clusterv1.ConditionSeverityWarning, "FailureMessage: %v", *t.Machine.Status.FailureMessage) - logger.V(3).Info("Target is unhealthy", "failureMessage", t.Machine.Status.FailureMessage) + if t.Machine.Status.Deprecated != nil && t.Machine.Status.Deprecated.V1Beta1 != nil && t.Machine.Status.Deprecated.V1Beta1.FailureMessage != nil { + conditions.MarkFalse(t.Machine, clusterv1.MachineHealthCheckSucceededCondition, clusterv1.MachineHasFailureReason, clusterv1.ConditionSeverityWarning, "FailureMessage: %v", *t.Machine.Status.Deprecated.V1Beta1.FailureMessage) + logger.V(3).Info("Target is unhealthy", "failureMessage", t.Machine.Status.Deprecated.V1Beta1.FailureMessage) return true, time.Duration(0) } diff --git a/internal/controllers/machinehealthcheck/machinehealthcheck_targets_test.go b/internal/controllers/machinehealthcheck/machinehealthcheck_targets_test.go index 26cf4f1a0ec3..3677ddea3f1a 100644 --- a/internal/controllers/machinehealthcheck/machinehealthcheck_targets_test.go +++ b/internal/controllers/machinehealthcheck/machinehealthcheck_targets_test.go @@ -388,7 +388,11 @@ func TestHealthCheckTargets(t *testing.T) { // Target for when the machine has a failure reason failureReason := errors.UpdateMachineError testMachineFailureReason := testMachine.DeepCopy() - testMachineFailureReason.Status.FailureReason = &failureReason + testMachineFailureReason.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + FailureReason: &failureReason, + }, + } machineFailureReason := healthCheckTarget{ Cluster: cluster, MHC: testMHC, @@ -400,7 +404,11 @@ func TestHealthCheckTargets(t *testing.T) { // Target for when the machine has a failure message failureMsg := "some failure message" testMachineFailureMsg := testMachine.DeepCopy() - testMachineFailureMsg.Status.FailureMessage = &failureMsg + testMachineFailureMsg.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + FailureMessage: &failureMsg, + }, + } machineFailureMsg := healthCheckTarget{ Cluster: cluster, MHC: testMHC, diff --git a/internal/controllers/machineset/machineset_controller.go b/internal/controllers/machineset/machineset_controller.go index a69b600cc470..0bc4b59499c6 100644 --- a/internal/controllers/machineset/machineset_controller.go +++ b/internal/controllers/machineset/machineset_controller.go @@ -1212,21 +1212,34 @@ func (r *Reconciler) reconcileStatus(ctx context.Context, s *scope) error { } newStatus.Replicas = int32(len(filteredMachines)) - newStatus.FullyLabeledReplicas = int32(fullyLabeledReplicasCount) - newStatus.ReadyReplicas = int32(readyReplicasCount) - newStatus.AvailableReplicas = int32(availableReplicasCount) + // TODO (v1beta2) + newStatus.Deprecated = &clusterv1.MachineSetDeprecatedStatus{ + V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{}, + } + newStatus.Deprecated.V1Beta1.FullyLabeledReplicas = int32(fullyLabeledReplicasCount) + newStatus.Deprecated.V1Beta1.ReadyReplicas = int32(readyReplicasCount) + newStatus.Deprecated.V1Beta1.AvailableReplicas = int32(availableReplicasCount) + + fullyLabeledReplicas := int32(0) + readyReplicas := int32(0) + availableReplicas := int32(0) + if ms.Status.Deprecated != nil && ms.Status.Deprecated.V1Beta1 != nil { + fullyLabeledReplicas = ms.Status.Deprecated.V1Beta1.FullyLabeledReplicas + readyReplicas = ms.Status.Deprecated.V1Beta1.ReadyReplicas + availableReplicas = ms.Status.Deprecated.V1Beta1.AvailableReplicas + } // Copy the newly calculated status into the machineset if ms.Status.Replicas != newStatus.Replicas || - ms.Status.FullyLabeledReplicas != newStatus.FullyLabeledReplicas || - ms.Status.ReadyReplicas != newStatus.ReadyReplicas || - ms.Status.AvailableReplicas != newStatus.AvailableReplicas || + fullyLabeledReplicas != newStatus.Deprecated.V1Beta1.FullyLabeledReplicas || + readyReplicas != newStatus.Deprecated.V1Beta1.ReadyReplicas || + availableReplicas != newStatus.Deprecated.V1Beta1.AvailableReplicas || ms.Generation != ms.Status.ObservedGeneration { log.V(4).Info("Updating status: " + fmt.Sprintf("replicas %d->%d (need %d), ", ms.Status.Replicas, newStatus.Replicas, desiredReplicas) + - fmt.Sprintf("fullyLabeledReplicas %d->%d, ", ms.Status.FullyLabeledReplicas, newStatus.FullyLabeledReplicas) + - fmt.Sprintf("readyReplicas %d->%d, ", ms.Status.ReadyReplicas, newStatus.ReadyReplicas) + - fmt.Sprintf("availableReplicas %d->%d, ", ms.Status.AvailableReplicas, newStatus.AvailableReplicas) + + fmt.Sprintf("fullyLabeledReplicas %d->%d, ", fullyLabeledReplicas, newStatus.Deprecated.V1Beta1.FullyLabeledReplicas) + + fmt.Sprintf("readyReplicas %d->%d, ", readyReplicas, newStatus.Deprecated.V1Beta1.ReadyReplicas) + + fmt.Sprintf("availableReplicas %d->%d, ", availableReplicas, newStatus.Deprecated.V1Beta1.AvailableReplicas) + fmt.Sprintf("observedGeneration %v->%v", ms.Status.ObservedGeneration, ms.Generation)) // Save the generation number we acted on, otherwise we might wrongfully indicate @@ -1247,9 +1260,10 @@ func (r *Reconciler) reconcileStatus(ctx context.Context, s *scope) error { // Make sure last resize operation is marked as completed. // NOTE: we are checking the number of machines ready so we report resize completed only when the machines // are actually provisioned (vs reporting completed immediately after the last machine object is created). This convention is also used by KCP. - if newStatus.ReadyReplicas == newStatus.Replicas { + // TODO (v1beta2) + if newStatus.Deprecated.V1Beta1.ReadyReplicas == newStatus.Replicas { if conditions.IsFalse(ms, clusterv1.ResizedCondition) { - log.Info("All the replicas are ready", "replicas", newStatus.ReadyReplicas) + log.Info("All the replicas are ready", "replicas", newStatus.Deprecated.V1Beta1.ReadyReplicas) } conditions.MarkTrue(ms, clusterv1.ResizedCondition) } @@ -1274,15 +1288,16 @@ func shouldRequeueForReplicaCountersRefresh(s *scope) ctrl.Result { // exceeds MinReadySeconds could be incorrect. // To avoid an available replica stuck in the ready state, we force a reconcile after MinReadySeconds, // at which point it should confirm any available replica to be available. + // TODO (v1beta2) if s.machineSet.Spec.MinReadySeconds > 0 && - s.machineSet.Status.ReadyReplicas == replicas && - s.machineSet.Status.AvailableReplicas != replicas { + s.machineSet.Status.Deprecated.V1Beta1.ReadyReplicas == replicas && + s.machineSet.Status.Deprecated.V1Beta1.AvailableReplicas != replicas { minReadyResult := ctrl.Result{RequeueAfter: time.Duration(s.machineSet.Spec.MinReadySeconds) * time.Second} return minReadyResult } // Quickly reconcile until the nodes become Ready. - if s.machineSet.Status.ReadyReplicas != replicas { + if s.machineSet.Status.Deprecated.V1Beta1.ReadyReplicas != replicas { return ctrl.Result{RequeueAfter: 15 * time.Second} } diff --git a/internal/controllers/machineset/machineset_controller_status.go b/internal/controllers/machineset/machineset_controller_status.go index 56e42b71a4af..87639f9ae303 100644 --- a/internal/controllers/machineset/machineset_controller_status.go +++ b/internal/controllers/machineset/machineset_controller_status.go @@ -84,13 +84,9 @@ func setReplicas(_ context.Context, ms *clusterv1.MachineSet, machines []*cluste } } - if ms.Status.V1Beta2 == nil { - ms.Status.V1Beta2 = &clusterv1.MachineSetV1Beta2Status{} - } - - ms.Status.V1Beta2.ReadyReplicas = ptr.To(readyReplicas) - ms.Status.V1Beta2.AvailableReplicas = ptr.To(availableReplicas) - ms.Status.V1Beta2.UpToDateReplicas = ptr.To(upToDateReplicas) + ms.Status.ReadyReplicas = ptr.To(readyReplicas) + ms.Status.AvailableReplicas = ptr.To(availableReplicas) + ms.Status.UpToDateReplicas = ptr.To(upToDateReplicas) } func setScalingUpCondition(_ context.Context, ms *clusterv1.MachineSet, machines []*clusterv1.Machine, bootstrapObjectNotFound, infrastructureObjectNotFound, getAndAdoptMachinesForMachineSetSucceeded bool, scaleUpPreflightCheckErrMessages []string) { diff --git a/internal/controllers/machineset/machineset_controller_status_test.go b/internal/controllers/machineset/machineset_controller_status_test.go index b3088e9034fb..3e93336b6191 100644 --- a/internal/controllers/machineset/machineset_controller_status_test.go +++ b/internal/controllers/machineset/machineset_controller_status_test.go @@ -20,6 +20,7 @@ import ( "testing" "time" + "github.com/google/go-cmp/cmp" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -35,19 +36,19 @@ func Test_setReplicas(t *testing.T) { name string machines []*clusterv1.Machine getAndAdoptMachinesForMachineSetSucceeded bool - expectedStatus *clusterv1.MachineSetV1Beta2Status + expectedStatus clusterv1.MachineSetStatus }{ { name: "getAndAdoptMachines failed", machines: nil, getAndAdoptMachinesForMachineSetSucceeded: false, - expectedStatus: nil, + expectedStatus: clusterv1.MachineSetStatus{}, }, { name: "no machines", machines: nil, getAndAdoptMachinesForMachineSetSucceeded: true, - expectedStatus: &clusterv1.MachineSetV1Beta2Status{ + expectedStatus: clusterv1.MachineSetStatus{ ReadyReplicas: ptr.To[int32](0), AvailableReplicas: ptr.To[int32](0), UpToDateReplicas: ptr.To[int32](0), @@ -55,21 +56,21 @@ func Test_setReplicas(t *testing.T) { { name: "should count only ready machines", machines: []*clusterv1.Machine{ - {Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + {Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{{ Type: clusterv1.MachineReadyV1Beta2Condition, Status: metav1.ConditionTrue, - }}}}}, - {Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + }}}}, + {Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{{ Type: clusterv1.MachineReadyV1Beta2Condition, Status: metav1.ConditionFalse, - }}}}}, - {Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + }}}}, + {Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{{ Type: clusterv1.MachineReadyV1Beta2Condition, Status: metav1.ConditionUnknown, - }}}}}, + }}}}, }, getAndAdoptMachinesForMachineSetSucceeded: true, - expectedStatus: &clusterv1.MachineSetV1Beta2Status{ + expectedStatus: clusterv1.MachineSetStatus{ ReadyReplicas: ptr.To[int32](1), AvailableReplicas: ptr.To[int32](0), UpToDateReplicas: ptr.To[int32](0), @@ -78,21 +79,21 @@ func Test_setReplicas(t *testing.T) { { name: "should count only available machines", machines: []*clusterv1.Machine{ - {Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + {Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{{ Type: clusterv1.MachineAvailableV1Beta2Condition, Status: metav1.ConditionTrue, - }}}}}, - {Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + }}}}, + {Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{{ Type: clusterv1.MachineAvailableV1Beta2Condition, Status: metav1.ConditionFalse, - }}}}}, - {Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + }}}}, + {Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{{ Type: clusterv1.MachineAvailableV1Beta2Condition, Status: metav1.ConditionUnknown, - }}}}}, + }}}}, }, getAndAdoptMachinesForMachineSetSucceeded: true, - expectedStatus: &clusterv1.MachineSetV1Beta2Status{ + expectedStatus: clusterv1.MachineSetStatus{ ReadyReplicas: ptr.To[int32](0), AvailableReplicas: ptr.To[int32](1), UpToDateReplicas: ptr.To[int32](0), @@ -101,21 +102,21 @@ func Test_setReplicas(t *testing.T) { { name: "should count only up-to-date machines", machines: []*clusterv1.Machine{ - {Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + {Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{{ Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionTrue, - }}}}}, - {Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + }}}}, + {Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{{ Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionFalse, - }}}}}, - {Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{{ + }}}}, + {Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{{ Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionUnknown, - }}}}}, + }}}}, }, getAndAdoptMachinesForMachineSetSucceeded: true, - expectedStatus: &clusterv1.MachineSetV1Beta2Status{ + expectedStatus: clusterv1.MachineSetStatus{ ReadyReplicas: ptr.To[int32](0), AvailableReplicas: ptr.To[int32](0), UpToDateReplicas: ptr.To[int32](1), @@ -124,7 +125,7 @@ func Test_setReplicas(t *testing.T) { { name: "should count all conditions from a machine", machines: []*clusterv1.Machine{ - {Status: clusterv1.MachineStatus{V1Beta2: &clusterv1.MachineV1Beta2Status{Conditions: []metav1.Condition{ + {Status: clusterv1.MachineStatus{Conditions: []metav1.Condition{ { Type: clusterv1.MachineReadyV1Beta2Condition, Status: metav1.ConditionTrue, @@ -137,10 +138,10 @@ func Test_setReplicas(t *testing.T) { Type: clusterv1.MachineUpToDateV1Beta2Condition, Status: metav1.ConditionTrue, }, - }}}}, + }}}, }, getAndAdoptMachinesForMachineSetSucceeded: true, - expectedStatus: &clusterv1.MachineSetV1Beta2Status{ + expectedStatus: clusterv1.MachineSetStatus{ ReadyReplicas: ptr.To[int32](1), AvailableReplicas: ptr.To[int32](1), UpToDateReplicas: ptr.To[int32](1), @@ -152,7 +153,7 @@ func Test_setReplicas(t *testing.T) { g := NewWithT(t) ms := &clusterv1.MachineSet{} setReplicas(ctx, ms, tt.machines, tt.getAndAdoptMachinesForMachineSetSucceeded) - g.Expect(ms.Status.V1Beta2).To(BeEquivalentTo(tt.expectedStatus)) + g.Expect(ms.Status).To(BeEquivalentTo(tt.expectedStatus), cmp.Diff(tt.expectedStatus, ms.Status)) }) } } @@ -422,19 +423,17 @@ func Test_setScalingDownCondition(t *testing.T) { machines: []*clusterv1.Machine{ fakeMachine("stale-machine-1", withStaleDeletionTimestamp(), func(m *clusterv1.Machine) { m.Status = clusterv1.MachineStatus{ - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineDeletingV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineDeletingDrainingNodeV1Beta2Reason, - Message: `Drain not completed yet (started at 2024-10-09T16:13:59Z): + Conditions: []metav1.Condition{ + { + Type: clusterv1.MachineDeletingV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineDeletingDrainingNodeV1Beta2Reason, + Message: `Drain not completed yet (started at 2024-10-09T16:13:59Z): * Pods pod-2-deletionTimestamp-set-1, pod-3-to-trigger-eviction-successfully-1: deletionTimestamp set, but still not removed from the Node * Pod pod-5-to-trigger-eviction-pdb-violated-1: cannot evict pod as it would violate the pod's disruption budget. The disruption budget pod-5-pdb needs 20 healthy pods and has 20 currently * Pod pod-6-to-trigger-eviction-some-other-error: failed to evict Pod, some other error 1 * Pod pod-9-wait-completed: waiting for completion After above Pods have been removed from the Node, the following Pods will be evicted: pod-7-eviction-later, pod-8-eviction-later`, - }, }, }, Deletion: &clusterv1.MachineDeletionStatus{ @@ -1169,15 +1168,18 @@ func withStaleDrain() fakeMachinesOption { func withV1Beta2Condition(c metav1.Condition) fakeMachinesOption { return func(m *clusterv1.Machine) { - if m.Status.V1Beta2 == nil { - m.Status.V1Beta2 = &clusterv1.MachineV1Beta2Status{} - } v1beta2conditions.Set(m, c) } } func withConditions(c ...clusterv1.Condition) fakeMachinesOption { return func(m *clusterv1.Machine) { - m.Status.Conditions = append(m.Status.Conditions, c...) + if m.Status.Deprecated == nil { + m.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} + } + if m.Status.Deprecated.V1Beta1 == nil { + m.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} + } + m.Status.Deprecated.V1Beta1.Conditions = append(m.Status.Deprecated.V1Beta1.Conditions, c...) } } diff --git a/internal/controllers/machineset/machineset_controller_test.go b/internal/controllers/machineset/machineset_controller_test.go index 403d1644d2ea..fc9520f35b23 100644 --- a/internal/controllers/machineset/machineset_controller_test.go +++ b/internal/controllers/machineset/machineset_controller_test.go @@ -417,7 +417,11 @@ func TestMachineSetReconciler(t *testing.T) { if err := env.Get(ctx, key, instance); err != nil { return -1 } - return instance.Status.AvailableReplicas + availableReplicas := int32(0) + if instance.Status.Deprecated != nil && instance.Status.Deprecated.V1Beta1 != nil { + availableReplicas = instance.Status.Deprecated.V1Beta1.AvailableReplicas + } + return availableReplicas }, timeout).Should(BeEquivalentTo(replicas)) t.Log("Verifying MachineSet has MachinesCreatedCondition") @@ -602,12 +606,11 @@ func TestMachineSetReconcile(t *testing.T) { ClusterName: testClusterName, Replicas: ptr.To[int32](0), }, - Status: clusterv1.MachineSetStatus{ - V1Beta2: &clusterv1.MachineSetV1Beta2Status{Conditions: []metav1.Condition{{ - Type: clusterv1.PausedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + Status: clusterv1.MachineSetStatus{Conditions: []metav1.Condition{{ + Type: clusterv1.PausedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.NotPausedV1Beta2Reason, + }}, }, } request := reconcile.Request{ @@ -913,12 +916,11 @@ func newMachineSet(name, cluster string, replicas int32) *clusterv1.MachineSet { }, }, }, - Status: clusterv1.MachineSetStatus{ - V1Beta2: &clusterv1.MachineSetV1Beta2Status{Conditions: []metav1.Condition{{ - Type: clusterv1.PausedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + Status: clusterv1.MachineSetStatus{Conditions: []metav1.Condition{{ + Type: clusterv1.PausedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.NotPausedV1Beta2Reason, + }}, }, } } @@ -972,11 +974,11 @@ func TestMachineSetReconcile_MachinesCreatedConditionFalseOnBadInfraRef(t *testi }, }, Status: clusterv1.MachineSetStatus{ - V1Beta2: &clusterv1.MachineSetV1Beta2Status{Conditions: []metav1.Condition{{ + Conditions: []metav1.Condition{{ Type: clusterv1.PausedV1Beta2Condition, Status: metav1.ConditionFalse, Reason: clusterv1.NotPausedV1Beta2Reason, - }}}, + }}, }, } @@ -1515,30 +1517,32 @@ func TestMachineSetReconciler_reconcileUnhealthyMachines(t *testing.T) { Finalizers: []string{"block-deletion"}, }, Status: clusterv1.MachineStatus{ - Conditions: []clusterv1.Condition{ - { - Type: clusterv1.MachineOwnerRemediatedCondition, - Status: corev1.ConditionFalse, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + { + Type: clusterv1.MachineOwnerRemediatedCondition, + Status: corev1.ConditionFalse, + }, + { + Type: clusterv1.MachineHealthCheckSucceededCondition, + Status: corev1.ConditionFalse, + }, + }, }, + }, + Conditions: []metav1.Condition{ { - Type: clusterv1.MachineHealthCheckSucceededCondition, - Status: corev1.ConditionFalse, + Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, + Message: "Waiting for remediation", }, - }, - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, - Message: "Waiting for remediation", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, - Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation", - }, + { + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, + Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation", }, }, }, @@ -1549,31 +1553,33 @@ func TestMachineSetReconciler_reconcileUnhealthyMachines(t *testing.T) { Namespace: "default", }, Status: clusterv1.MachineStatus{ - Conditions: []clusterv1.Condition{ + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + { + // This condition should be cleaned up because HealthCheckSucceeded is true. + Type: clusterv1.MachineOwnerRemediatedCondition, + Status: corev1.ConditionFalse, + }, + { + Type: clusterv1.MachineHealthCheckSucceededCondition, + Status: corev1.ConditionTrue, + }, + }, + }, + }, + Conditions: []metav1.Condition{ { // This condition should be cleaned up because HealthCheckSucceeded is true. - Type: clusterv1.MachineOwnerRemediatedCondition, - Status: corev1.ConditionFalse, + Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, + Message: "Waiting for remediation", }, { - Type: clusterv1.MachineHealthCheckSucceededCondition, - Status: corev1.ConditionTrue, - }, - }, - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - // This condition should be cleaned up because HealthCheckSucceeded is true. - Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, - Message: "Waiting for remediation", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckSucceededV1Beta2Reason, - }, + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckSucceededV1Beta2Reason, }, }, }, @@ -1645,30 +1651,32 @@ func TestMachineSetReconciler_reconcileUnhealthyMachines(t *testing.T) { Namespace: "default", }, Status: clusterv1.MachineStatus{ - Conditions: []clusterv1.Condition{ - { - Type: clusterv1.MachineOwnerRemediatedCondition, - Status: corev1.ConditionFalse, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + { + Type: clusterv1.MachineOwnerRemediatedCondition, + Status: corev1.ConditionFalse, + }, + { + Type: clusterv1.MachineHealthCheckSucceededCondition, + Status: corev1.ConditionFalse, + }, + }, }, + }, + Conditions: []metav1.Condition{ { - Type: clusterv1.MachineHealthCheckSucceededCondition, - Status: corev1.ConditionFalse, + Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, + Message: "Waiting for remediation", }, - }, - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, - Message: "Waiting for remediation", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, - Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation", - }, + { + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, + Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation", }, }, }, @@ -1679,31 +1687,33 @@ func TestMachineSetReconciler_reconcileUnhealthyMachines(t *testing.T) { Namespace: "default", }, Status: clusterv1.MachineStatus{ - Conditions: []clusterv1.Condition{ + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + { + // This condition should be cleaned up because HealthCheckSucceeded is true. + Type: clusterv1.MachineOwnerRemediatedCondition, + Status: corev1.ConditionFalse, + }, + { + Type: clusterv1.MachineHealthCheckSucceededCondition, + Status: corev1.ConditionTrue, + }, + }, + }, + }, + Conditions: []metav1.Condition{ { // This condition should be cleaned up because HealthCheckSucceeded is true. - Type: clusterv1.MachineOwnerRemediatedCondition, - Status: corev1.ConditionFalse, + Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, + Message: "Waiting for remediation", }, { - Type: clusterv1.MachineHealthCheckSucceededCondition, - Status: corev1.ConditionTrue, - }, - }, - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - // This condition should be cleaned up because HealthCheckSucceeded is true. - Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, - Message: "Waiting for remediation", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckSucceededV1Beta2Reason, - }, + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckSucceededV1Beta2Reason, }, }, }, @@ -1813,30 +1823,32 @@ func TestMachineSetReconciler_reconcileUnhealthyMachines(t *testing.T) { Finalizers: []string{"block-deletion"}, }, Status: clusterv1.MachineStatus{ - Conditions: []clusterv1.Condition{ - { - Type: clusterv1.MachineOwnerRemediatedCondition, - Status: corev1.ConditionFalse, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + { + Type: clusterv1.MachineOwnerRemediatedCondition, + Status: corev1.ConditionFalse, + }, + { + Type: clusterv1.MachineHealthCheckSucceededCondition, + Status: corev1.ConditionFalse, + }, + }, }, + }, + Conditions: []metav1.Condition{ { - Type: clusterv1.MachineHealthCheckSucceededCondition, - Status: corev1.ConditionFalse, + Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, + Message: "Waiting for remediation", }, - }, - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, - Message: "Waiting for remediation", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, - Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation", - }, + { + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, + Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation", }, }, }, @@ -1847,31 +1859,33 @@ func TestMachineSetReconciler_reconcileUnhealthyMachines(t *testing.T) { Namespace: "default", }, Status: clusterv1.MachineStatus{ - Conditions: []clusterv1.Condition{ + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + { + // This condition should be cleaned up because HealthCheckSucceeded is true. + Type: clusterv1.MachineOwnerRemediatedCondition, + Status: corev1.ConditionFalse, + }, + { + Type: clusterv1.MachineHealthCheckSucceededCondition, + Status: corev1.ConditionTrue, + }, + }, + }, + }, + Conditions: []metav1.Condition{ { // This condition should be cleaned up because HealthCheckSucceeded is true. - Type: clusterv1.MachineOwnerRemediatedCondition, - Status: corev1.ConditionFalse, + Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, + Message: "Waiting for remediation", }, { - Type: clusterv1.MachineHealthCheckSucceededCondition, - Status: corev1.ConditionTrue, - }, - }, - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - // This condition should be cleaned up because HealthCheckSucceeded is true. - Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, - Message: "Waiting for remediation", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckSucceededV1Beta2Reason, - }, + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckSucceededV1Beta2Reason, }, }, }, @@ -2026,30 +2040,32 @@ func TestMachineSetReconciler_reconcileUnhealthyMachines(t *testing.T) { CreationTimestamp: metav1.Time{Time: metav1.Now().Add(time.Duration(i) * time.Second)}, }, Status: clusterv1.MachineStatus{ - Conditions: []clusterv1.Condition{ - { - Type: clusterv1.MachineOwnerRemediatedCondition, - Status: corev1.ConditionFalse, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + { + Type: clusterv1.MachineOwnerRemediatedCondition, + Status: corev1.ConditionFalse, + }, + { + Type: clusterv1.MachineHealthCheckSucceededCondition, + Status: corev1.ConditionFalse, + }, + }, }, + }, + Conditions: []metav1.Condition{ { - Type: clusterv1.MachineHealthCheckSucceededCondition, - Status: corev1.ConditionFalse, + Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, + Message: "Waiting for remediation", }, - }, - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, - Message: "Waiting for remediation", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, - Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation", - }, + { + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, + Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation", }, }, }, @@ -2062,31 +2078,33 @@ func TestMachineSetReconciler_reconcileUnhealthyMachines(t *testing.T) { Namespace: "default", }, Status: clusterv1.MachineStatus{ - Conditions: []clusterv1.Condition{ + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + { + // This condition should be cleaned up because HealthCheckSucceeded is true. + Type: clusterv1.MachineOwnerRemediatedCondition, + Status: corev1.ConditionFalse, + }, + { + Type: clusterv1.MachineHealthCheckSucceededCondition, + Status: corev1.ConditionTrue, + }, + }, + }, + }, + Conditions: []metav1.Condition{ { // This condition should be cleaned up because HealthCheckSucceeded is true. - Type: clusterv1.MachineOwnerRemediatedCondition, - Status: corev1.ConditionFalse, + Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, + Message: "Waiting for remediation", }, { - Type: clusterv1.MachineHealthCheckSucceededCondition, - Status: corev1.ConditionTrue, - }, - }, - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - // This condition should be cleaned up because HealthCheckSucceeded is true. - Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, - Message: "Waiting for remediation", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionTrue, - Reason: clusterv1.MachineHealthCheckSucceededV1Beta2Reason, - }, + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionTrue, + Reason: clusterv1.MachineHealthCheckSucceededV1Beta2Reason, }, }, }, @@ -3156,30 +3174,32 @@ func TestSortMachinesToRemediate(t *testing.T) { }, }, Status: clusterv1.MachineStatus{ - Conditions: []clusterv1.Condition{ - { - Type: clusterv1.MachineOwnerRemediatedCondition, - Status: corev1.ConditionFalse, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + { + Type: clusterv1.MachineOwnerRemediatedCondition, + Status: corev1.ConditionFalse, + }, + { + Type: clusterv1.MachineHealthCheckSucceededCondition, + Status: corev1.ConditionFalse, + }, + }, }, + }, + Conditions: []metav1.Condition{ { - Type: clusterv1.MachineHealthCheckSucceededCondition, - Status: corev1.ConditionFalse, + Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, + Message: "Waiting for remediation", }, - }, - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, - Message: "Waiting for remediation", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, - Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation", - }, + { + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, + Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation", }, }, }, @@ -3195,30 +3215,32 @@ func TestSortMachinesToRemediate(t *testing.T) { CreationTimestamp: metav1.Time{Time: metav1.Now().Add(time.Duration(i) * time.Second)}, }, Status: clusterv1.MachineStatus{ - Conditions: []clusterv1.Condition{ - { - Type: clusterv1.MachineOwnerRemediatedCondition, - Status: corev1.ConditionFalse, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: []clusterv1.Condition{ + { + Type: clusterv1.MachineOwnerRemediatedCondition, + Status: corev1.ConditionFalse, + }, + { + Type: clusterv1.MachineHealthCheckSucceededCondition, + Status: corev1.ConditionFalse, + }, + }, }, + }, + Conditions: []metav1.Condition{ { - Type: clusterv1.MachineHealthCheckSucceededCondition, - Status: corev1.ConditionFalse, + Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, + Message: "Waiting for remediation", }, - }, - V1Beta2: &clusterv1.MachineV1Beta2Status{ - Conditions: []metav1.Condition{ - { - Type: clusterv1.MachineOwnerRemediatedV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineOwnerRemediatedWaitingForRemediationV1Beta2Reason, - Message: "Waiting for remediation", - }, - { - Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, - Status: metav1.ConditionFalse, - Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, - Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation", - }, + { + Type: clusterv1.MachineHealthCheckSucceededV1Beta2Condition, + Status: metav1.ConditionFalse, + Reason: clusterv1.MachineHealthCheckHasRemediateAnnotationV1Beta2Reason, + Message: "Marked for remediation via cluster.x-k8s.io/remediate-machine annotation", }, }, }, diff --git a/internal/controllers/machineset/machineset_delete_policy.go b/internal/controllers/machineset/machineset_delete_policy.go index 6db017bb1a47..25dc5ad5da4a 100644 --- a/internal/controllers/machineset/machineset_delete_policy.go +++ b/internal/controllers/machineset/machineset_delete_policy.go @@ -143,7 +143,7 @@ func isMachineHealthy(machine *clusterv1.Machine) bool { if machine.Status.NodeRef == nil { return false } - if machine.Status.FailureReason != nil || machine.Status.FailureMessage != nil { + if machine.Status.Deprecated != nil && machine.Status.Deprecated.V1Beta1 != nil && (machine.Status.Deprecated.V1Beta1.FailureReason != nil || machine.Status.Deprecated.V1Beta1.FailureMessage != nil) { return false } // Note: for the sake of prioritization, we are not making any assumption about Health when ConditionUnknown. diff --git a/internal/controllers/machineset/machineset_delete_policy_test.go b/internal/controllers/machineset/machineset_delete_policy_test.go index 7c46ef97223d..3280d2783d79 100644 --- a/internal/controllers/machineset/machineset_delete_policy_test.go +++ b/internal/controllers/machineset/machineset_delete_policy_test.go @@ -39,7 +39,14 @@ func TestMachineToDelete(t *testing.T) { Status: clusterv1.MachineStatus{NodeRef: nodeRef}, } betterDeleteMachine := &clusterv1.Machine{ - Status: clusterv1.MachineStatus{FailureMessage: &msg, NodeRef: nodeRef}, + Status: clusterv1.MachineStatus{ + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + FailureMessage: &msg, + }, + }, + NodeRef: nodeRef, + }, } deleteMachineWithMachineAnnotation := &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{clusterv1.DeleteMachineAnnotation: ""}}, @@ -49,10 +56,14 @@ func TestMachineToDelete(t *testing.T) { nodeHealthyConditionFalseMachine := &clusterv1.Machine{ Status: clusterv1.MachineStatus{ NodeRef: nodeRef, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.MachineNodeHealthyCondition, - Status: corev1.ConditionFalse, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.MachineNodeHealthyCondition, + Status: corev1.ConditionFalse, + }, + }, }, }, }, @@ -60,10 +71,14 @@ func TestMachineToDelete(t *testing.T) { nodeHealthyConditionUnknownMachine := &clusterv1.Machine{ Status: clusterv1.MachineStatus{ NodeRef: nodeRef, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.MachineNodeHealthyCondition, - Status: corev1.ConditionUnknown, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.MachineNodeHealthyCondition, + Status: corev1.ConditionUnknown, + }, + }, }, }, }, @@ -71,10 +86,14 @@ func TestMachineToDelete(t *testing.T) { healthCheckSucceededConditionFalseMachine := &clusterv1.Machine{ Status: clusterv1.MachineStatus{ NodeRef: nodeRef, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.MachineHealthCheckSucceededCondition, - Status: corev1.ConditionFalse, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.MachineHealthCheckSucceededCondition, + Status: corev1.ConditionFalse, + }, + }, }, }, }, @@ -82,10 +101,14 @@ func TestMachineToDelete(t *testing.T) { healthCheckSucceededConditionUnknownMachine := &clusterv1.Machine{ Status: clusterv1.MachineStatus{ NodeRef: nodeRef, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.MachineHealthCheckSucceededCondition, - Status: corev1.ConditionUnknown, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.MachineHealthCheckSucceededCondition, + Status: corev1.ConditionUnknown, + }, + }, }, }, }, @@ -310,7 +333,14 @@ func TestMachineNewestDelete(t *testing.T) { } unhealthyMachine := &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, - Status: clusterv1.MachineStatus{FailureReason: &statusError, NodeRef: nodeRef}, + Status: clusterv1.MachineStatus{ + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + FailureReason: &statusError, + }, + }, + NodeRef: nodeRef, + }, } deleteMachineWithoutNodeRef := &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -1))}, @@ -319,10 +349,14 @@ func TestMachineNewestDelete(t *testing.T) { ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, Status: clusterv1.MachineStatus{ NodeRef: nodeRef, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.MachineNodeHealthyCondition, - Status: corev1.ConditionFalse, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.MachineNodeHealthyCondition, + Status: corev1.ConditionFalse, + }, + }, }, }, }, @@ -331,10 +365,14 @@ func TestMachineNewestDelete(t *testing.T) { ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, Status: clusterv1.MachineStatus{ NodeRef: nodeRef, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.MachineNodeHealthyCondition, - Status: corev1.ConditionUnknown, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.MachineNodeHealthyCondition, + Status: corev1.ConditionUnknown, + }, + }, }, }, }, @@ -452,7 +490,14 @@ func TestMachineOldestDelete(t *testing.T) { } unhealthyMachine := &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, - Status: clusterv1.MachineStatus{FailureReason: &statusError, NodeRef: nodeRef}, + Status: clusterv1.MachineStatus{ + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + FailureReason: &statusError, + }, + }, + NodeRef: nodeRef, + }, } mustDeleteMachine := &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "b", DeletionTimestamp: ¤tTime}, @@ -460,11 +505,25 @@ func TestMachineOldestDelete(t *testing.T) { } unhealthyMachineA := &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "a", CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, - Status: clusterv1.MachineStatus{FailureReason: &statusError, NodeRef: nodeRef}, + Status: clusterv1.MachineStatus{ + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + FailureReason: &statusError, + }, + }, + NodeRef: nodeRef, + }, } unhealthyMachineZ := &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{Name: "z", CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, - Status: clusterv1.MachineStatus{FailureReason: &statusError, NodeRef: nodeRef}, + Status: clusterv1.MachineStatus{ + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + FailureReason: &statusError, + }, + }, + NodeRef: nodeRef, + }, } deleteMachineWithoutNodeRef := &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, @@ -473,10 +532,14 @@ func TestMachineOldestDelete(t *testing.T) { ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, Status: clusterv1.MachineStatus{ NodeRef: nodeRef, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.MachineNodeHealthyCondition, - Status: corev1.ConditionFalse, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.MachineNodeHealthyCondition, + Status: corev1.ConditionFalse, + }, + }, }, }, }, @@ -485,10 +548,14 @@ func TestMachineOldestDelete(t *testing.T) { ObjectMeta: metav1.ObjectMeta{CreationTimestamp: metav1.NewTime(currentTime.Time.AddDate(0, 0, -10))}, Status: clusterv1.MachineStatus{ NodeRef: nodeRef, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.MachineNodeHealthyCondition, - Status: corev1.ConditionUnknown, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.MachineNodeHealthyCondition, + Status: corev1.ConditionUnknown, + }, + }, }, }, }, @@ -712,14 +779,28 @@ func TestIsMachineHealthy(t *testing.T) { { desc: "when it has a FailureReason", machine: &clusterv1.Machine{ - Status: clusterv1.MachineStatus{FailureReason: &statusError, NodeRef: nodeRef}, + Status: clusterv1.MachineStatus{ + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + FailureReason: &statusError, + }, + }, + NodeRef: nodeRef, + }, }, expect: false, }, { desc: "when it has a FailureMessage", machine: &clusterv1.Machine{ - Status: clusterv1.MachineStatus{FailureMessage: &msg, NodeRef: nodeRef}, + Status: clusterv1.MachineStatus{ + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + FailureMessage: &msg, + }, + }, + NodeRef: nodeRef, + }, }, expect: false, }, @@ -728,10 +809,14 @@ func TestIsMachineHealthy(t *testing.T) { machine: &clusterv1.Machine{ Status: clusterv1.MachineStatus{ NodeRef: nodeRef, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.MachineNodeHealthyCondition, - Status: corev1.ConditionFalse, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.MachineNodeHealthyCondition, + Status: corev1.ConditionFalse, + }, + }, }, }, }, @@ -743,10 +828,14 @@ func TestIsMachineHealthy(t *testing.T) { machine: &clusterv1.Machine{ Status: clusterv1.MachineStatus{ NodeRef: nodeRef, - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.MachineNodeHealthyCondition, - Status: corev1.ConditionUnknown, + Deprecated: &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + { + Type: clusterv1.MachineNodeHealthyCondition, + Status: corev1.ConditionUnknown, + }, + }, }, }, }, diff --git a/internal/controllers/topology/cluster/cluster_controller.go b/internal/controllers/topology/cluster/cluster_controller.go index eec470b5dbda..26169d53f7cb 100644 --- a/internal/controllers/topology/cluster/cluster_controller.go +++ b/internal/controllers/topology/cluster/cluster_controller.go @@ -172,10 +172,6 @@ func clusterChangeIsRelevant(scheme *runtime.Scheme, logger logr.Logger) predica // Drop metadata fields which are impacted by not relevant changes. c.ObjectMeta.ManagedFields = nil c.ObjectMeta.ResourceVersion = "" - - // Drop changes on v1beta2 conditions; when v1beta2 conditions will be moved top level, we will review this - // selectively drop changes not relevant for this controller. - c.Status.V1Beta2 = nil return c } @@ -224,10 +220,6 @@ func machineDeploymentChangeIsRelevant(scheme *runtime.Scheme, logger logr.Logge // Drop metadata fields which are impacted by not relevant changes. md.ObjectMeta.ManagedFields = nil md.ObjectMeta.ResourceVersion = "" - - // Drop changes on v1beta2 conditions; when v1beta2 conditions will be moved top level, we will review this - // selectively drop changes not relevant for this controller. - md.Status.V1Beta2 = nil return md } diff --git a/internal/controllers/topology/cluster/conditions_test.go b/internal/controllers/topology/cluster/conditions_test.go index 4bb6f321b358..ae4e0f7941f2 100644 --- a/internal/controllers/topology/cluster/conditions_test.go +++ b/internal/controllers/topology/cluster/conditions_test.go @@ -276,11 +276,15 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { Object: builder.MachineDeployment("ns1", "md0-abc123"). WithReplicas(2). WithStatus(clusterv1.MachineDeploymentStatus{ - Replicas: int32(1), - UpdatedReplicas: int32(1), - ReadyReplicas: int32(1), - AvailableReplicas: int32(1), - UnavailableReplicas: int32(0), + Replicas: int32(1), + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: int32(1), + ReadyReplicas: int32(1), + AvailableReplicas: int32(1), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -324,10 +328,14 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { Object: builder.MachinePool("ns1", "mp0-abc123"). WithReplicas(2). WithStatus(expv1.MachinePoolStatus{ - Replicas: int32(1), - ReadyReplicas: int32(1), - AvailableReplicas: int32(1), - UnavailableReplicas: int32(0), + Replicas: int32(1), + Deprecated: &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: int32(1), + AvailableReplicas: int32(1), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -371,11 +379,15 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { Object: builder.MachineDeployment("ns1", "md0-abc123"). WithReplicas(2). WithStatus(clusterv1.MachineDeploymentStatus{ - Replicas: int32(2), - UpdatedReplicas: int32(2), - ReadyReplicas: int32(2), - AvailableReplicas: int32(2), - UnavailableReplicas: int32(0), + Replicas: int32(2), + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: int32(2), + ReadyReplicas: int32(2), + AvailableReplicas: int32(2), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -420,10 +432,14 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { Object: builder.MachinePool("ns1", "mp0-abc123"). WithReplicas(2). WithStatus(expv1.MachinePoolStatus{ - Replicas: int32(2), - ReadyReplicas: int32(2), - AvailableReplicas: int32(2), - UnavailableReplicas: int32(0), + Replicas: int32(2), + Deprecated: &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: int32(2), + AvailableReplicas: int32(2), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -538,11 +554,15 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { }). WithStatus(clusterv1.MachineDeploymentStatus{ // MD is not ready because we don't have 2 updated, ready and available replicas. - Replicas: int32(2), - UpdatedReplicas: int32(1), - ReadyReplicas: int32(1), - AvailableReplicas: int32(1), - UnavailableReplicas: int32(0), + Replicas: int32(2), + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: int32(1), + ReadyReplicas: int32(1), + AvailableReplicas: int32(1), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -556,11 +576,15 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { }, }). WithStatus(clusterv1.MachineDeploymentStatus{ - Replicas: int32(2), - UpdatedReplicas: int32(2), - ReadyReplicas: int32(2), - AvailableReplicas: int32(2), - UnavailableReplicas: int32(0), + Replicas: int32(2), + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: int32(2), + ReadyReplicas: int32(2), + AvailableReplicas: int32(2), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -617,10 +641,14 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { WithVersion("v1.22.0"). WithStatus(expv1.MachinePoolStatus{ // mp is not ready because we don't have 2 updated, ready and available replicas. - Replicas: int32(2), - ReadyReplicas: int32(1), - AvailableReplicas: int32(1), - UnavailableReplicas: int32(0), + Replicas: int32(2), + Deprecated: &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: int32(1), + AvailableReplicas: int32(1), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -629,10 +657,14 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { WithReplicas(2). WithVersion("v1.21.2"). WithStatus(expv1.MachinePoolStatus{ - Replicas: int32(2), - ReadyReplicas: int32(2), - AvailableReplicas: int32(2), - UnavailableReplicas: int32(0), + Replicas: int32(2), + Deprecated: &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: int32(2), + AvailableReplicas: int32(2), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -688,11 +720,15 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { WithReplicas(2). WithVersion("v1.22.0"). WithStatus(clusterv1.MachineDeploymentStatus{ - Replicas: int32(2), - UpdatedReplicas: int32(2), - ReadyReplicas: int32(2), - AvailableReplicas: int32(2), - UnavailableReplicas: int32(0), + Replicas: int32(2), + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: int32(2), + ReadyReplicas: int32(2), + AvailableReplicas: int32(2), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -701,11 +737,15 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { WithReplicas(2). WithVersion("v1.21.2"). WithStatus(clusterv1.MachineDeploymentStatus{ - Replicas: int32(2), - UpdatedReplicas: int32(2), - ReadyReplicas: int32(2), - AvailableReplicas: int32(2), - UnavailableReplicas: int32(0), + Replicas: int32(2), + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: int32(2), + ReadyReplicas: int32(2), + AvailableReplicas: int32(2), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -750,10 +790,14 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { WithReplicas(2). WithVersion("v1.22.0"). WithStatus(expv1.MachinePoolStatus{ - Replicas: int32(2), - ReadyReplicas: int32(2), - AvailableReplicas: int32(2), - UnavailableReplicas: int32(0), + Replicas: int32(2), + Deprecated: &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: int32(2), + AvailableReplicas: int32(2), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -762,10 +806,14 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { WithReplicas(2). WithVersion("v1.21.2"). WithStatus(expv1.MachinePoolStatus{ - Replicas: int32(2), - ReadyReplicas: int32(2), - AvailableReplicas: int32(2), - UnavailableReplicas: int32(0), + Replicas: int32(2), + Deprecated: &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: int32(2), + AvailableReplicas: int32(2), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -810,11 +858,15 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { WithReplicas(2). WithVersion("v1.22.0"). WithStatus(clusterv1.MachineDeploymentStatus{ - Replicas: int32(1), - UpdatedReplicas: int32(1), - ReadyReplicas: int32(1), - AvailableReplicas: int32(1), - UnavailableReplicas: int32(0), + Replicas: int32(1), + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: int32(1), + ReadyReplicas: int32(1), + AvailableReplicas: int32(1), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -823,11 +875,15 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { WithReplicas(2). WithVersion("v1.22.0"). WithStatus(clusterv1.MachineDeploymentStatus{ - Replicas: int32(2), - UpdatedReplicas: int32(2), - ReadyReplicas: int32(2), - AvailableReplicas: int32(2), - UnavailableReplicas: int32(0), + Replicas: int32(2), + Deprecated: &clusterv1.MachineDeploymentDeprecatedStatus{ + V1Beta1: &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{ + UpdatedReplicas: int32(2), + ReadyReplicas: int32(2), + AvailableReplicas: int32(2), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -838,10 +894,14 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { WithReplicas(2). WithVersion("v1.22.0"). WithStatus(expv1.MachinePoolStatus{ - Replicas: int32(1), - ReadyReplicas: int32(1), - AvailableReplicas: int32(1), - UnavailableReplicas: int32(0), + Replicas: int32(1), + Deprecated: &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: int32(1), + AvailableReplicas: int32(1), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, @@ -850,10 +910,14 @@ func TestReconcileTopologyReconciledCondition(t *testing.T) { WithReplicas(2). WithVersion("v1.22.0"). WithStatus(expv1.MachinePoolStatus{ - Replicas: int32(2), - ReadyReplicas: int32(2), - AvailableReplicas: int32(2), - UnavailableReplicas: int32(0), + Replicas: int32(2), + Deprecated: &expv1.MachinePoolDeprecatedStatus{ + V1Beta1: &expv1.MachinePoolV1Beta1DeprecatedStatus{ + ReadyReplicas: int32(2), + AvailableReplicas: int32(2), + UnavailableReplicas: int32(0), + }, + }, }). Build(), }, diff --git a/internal/controllers/topology/cluster/reconcile_state_test.go b/internal/controllers/topology/cluster/reconcile_state_test.go index d2eb13bc69d2..1e7f03fb2090 100644 --- a/internal/controllers/topology/cluster/reconcile_state_test.go +++ b/internal/controllers/topology/cluster/reconcile_state_test.go @@ -348,10 +348,14 @@ func TestReconcile_callAfterControlPlaneInitialized(t *testing.T) { InfrastructureRef: &corev1.ObjectReference{}, }, Status: clusterv1.ClusterStatus{ - Conditions: clusterv1.Conditions{ - clusterv1.Condition{ - Type: clusterv1.ControlPlaneInitializedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + clusterv1.Condition{ + Type: clusterv1.ControlPlaneInitializedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, }, @@ -376,10 +380,14 @@ func TestReconcile_callAfterControlPlaneInitialized(t *testing.T) { InfrastructureRef: &corev1.ObjectReference{}, }, Status: clusterv1.ClusterStatus{ - Conditions: clusterv1.Conditions{ - clusterv1.Condition{ - Type: clusterv1.ControlPlaneInitializedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + clusterv1.Condition{ + Type: clusterv1.ControlPlaneInitializedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, }, @@ -404,10 +412,14 @@ func TestReconcile_callAfterControlPlaneInitialized(t *testing.T) { InfrastructureRef: &corev1.ObjectReference{}, }, Status: clusterv1.ClusterStatus{ - Conditions: clusterv1.Conditions{ - clusterv1.Condition{ - Type: clusterv1.ControlPlaneInitializedCondition, - Status: corev1.ConditionFalse, + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + clusterv1.Condition{ + Type: clusterv1.ControlPlaneInitializedCondition, + Status: corev1.ConditionFalse, + }, + }, }, }, }, @@ -429,10 +441,14 @@ func TestReconcile_callAfterControlPlaneInitialized(t *testing.T) { InfrastructureRef: &corev1.ObjectReference{}, }, Status: clusterv1.ClusterStatus{ - Conditions: clusterv1.Conditions{ - clusterv1.Condition{ - Type: clusterv1.ControlPlaneInitializedCondition, - Status: corev1.ConditionTrue, + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + clusterv1.Condition{ + Type: clusterv1.ControlPlaneInitializedCondition, + Status: corev1.ConditionTrue, + }, + }, }, }, }, diff --git a/internal/util/tree/tree.go b/internal/util/tree/tree.go index 1f5155edceb2..5a95206aa1db 100644 --- a/internal/util/tree/tree.go +++ b/internal/util/tree/tree.go @@ -528,27 +528,25 @@ func newV1beta2RowDescriptor(obj ctrlclient.Object) v1beta2RowDescriptor { case *clusterv1.Cluster: // If the object is a cluster, returns all the replica counters (CP and worker replicas are summed for sake of simplicity); // also, pick the available condition as the condition to show for this object in case not all the conditions are visualized. - if obj.Status.V1Beta2 != nil { - cp := obj.Status.V1Beta2.ControlPlane - if cp == nil { - cp = &clusterv1.ClusterControlPlaneStatus{} - } - w := obj.Status.V1Beta2.Workers - if w == nil { - w = &clusterv1.WorkersStatus{} - } - if cp.DesiredReplicas != nil || w.DesiredReplicas != nil || cp.Replicas != nil || w.Replicas != nil { - v.replicas = fmt.Sprintf("%d/%d", ptr.Deref(cp.Replicas, 0)+ptr.Deref(w.Replicas, 0), ptr.Deref(cp.DesiredReplicas, 0)+ptr.Deref(w.DesiredReplicas, 0)) - } - if cp.AvailableReplicas != nil || w.AvailableReplicas != nil { - v.availableCounters = fmt.Sprintf("%d", ptr.Deref(cp.AvailableReplicas, 0)+ptr.Deref(w.AvailableReplicas, 0)) - } - if cp.ReadyReplicas != nil || w.ReadyReplicas != nil { - v.readyCounters = fmt.Sprintf("%d", ptr.Deref(cp.ReadyReplicas, 0)+ptr.Deref(w.ReadyReplicas, 0)) - } - if cp.UpToDateReplicas != nil || w.UpToDateReplicas != nil { - v.upToDateCounters = fmt.Sprintf("%d", ptr.Deref(cp.UpToDateReplicas, 0)+ptr.Deref(w.UpToDateReplicas, 0)) - } + cp := obj.Status.ControlPlane + if cp == nil { + cp = &clusterv1.ClusterControlPlaneStatus{} + } + w := obj.Status.Workers + if w == nil { + w = &clusterv1.WorkersStatus{} + } + if cp.DesiredReplicas != nil || w.DesiredReplicas != nil || cp.Replicas != nil || w.Replicas != nil { + v.replicas = fmt.Sprintf("%d/%d", ptr.Deref(cp.Replicas, 0)+ptr.Deref(w.Replicas, 0), ptr.Deref(cp.DesiredReplicas, 0)+ptr.Deref(w.DesiredReplicas, 0)) + } + if cp.AvailableReplicas != nil || w.AvailableReplicas != nil { + v.availableCounters = fmt.Sprintf("%d", ptr.Deref(cp.AvailableReplicas, 0)+ptr.Deref(w.AvailableReplicas, 0)) + } + if cp.ReadyReplicas != nil || w.ReadyReplicas != nil { + v.readyCounters = fmt.Sprintf("%d", ptr.Deref(cp.ReadyReplicas, 0)+ptr.Deref(w.ReadyReplicas, 0)) + } + if cp.UpToDateReplicas != nil || w.UpToDateReplicas != nil { + v.upToDateCounters = fmt.Sprintf("%d", ptr.Deref(cp.UpToDateReplicas, 0)+ptr.Deref(w.UpToDateReplicas, 0)) } if available := tree.GetAvailableV1Beta2Condition(obj); available != nil { @@ -564,16 +562,14 @@ func newV1beta2RowDescriptor(obj ctrlclient.Object) v1beta2RowDescriptor { if obj.Spec.Replicas != nil { v.replicas = fmt.Sprintf("%d/%d", *obj.Spec.Replicas, obj.Status.Replicas) } - if obj.Status.V1Beta2 != nil { - if obj.Status.V1Beta2.ReadyReplicas != nil { - v.availableCounters = fmt.Sprintf("%d", *obj.Status.V1Beta2.AvailableReplicas) - } - if obj.Status.V1Beta2.ReadyReplicas != nil { - v.readyCounters = fmt.Sprintf("%d", *obj.Status.V1Beta2.ReadyReplicas) - } - if obj.Status.V1Beta2.UpToDateReplicas != nil { - v.upToDateCounters = fmt.Sprintf("%d", *obj.Status.V1Beta2.UpToDateReplicas) - } + if obj.Status.ReadyReplicas != nil { + v.availableCounters = fmt.Sprintf("%d", *obj.Status.AvailableReplicas) + } + if obj.Status.ReadyReplicas != nil { + v.readyCounters = fmt.Sprintf("%d", *obj.Status.ReadyReplicas) + } + if obj.Status.UpToDateReplicas != nil { + v.upToDateCounters = fmt.Sprintf("%d", *obj.Status.UpToDateReplicas) } if available := tree.GetAvailableV1Beta2Condition(obj); available != nil { @@ -590,16 +586,14 @@ func newV1beta2RowDescriptor(obj ctrlclient.Object) v1beta2RowDescriptor { if obj.Spec.Replicas != nil { v.replicas = fmt.Sprintf("%d/%d", *obj.Spec.Replicas, obj.Status.Replicas) } - if obj.Status.V1Beta2 != nil { - if obj.Status.V1Beta2.ReadyReplicas != nil { - v.availableCounters = fmt.Sprintf("%d", *obj.Status.V1Beta2.AvailableReplicas) - } - if obj.Status.V1Beta2.ReadyReplicas != nil { - v.readyCounters = fmt.Sprintf("%d", *obj.Status.V1Beta2.ReadyReplicas) - } - if obj.Status.V1Beta2.UpToDateReplicas != nil { - v.upToDateCounters = fmt.Sprintf("%d", *obj.Status.V1Beta2.UpToDateReplicas) - } + if obj.Status.ReadyReplicas != nil { + v.availableCounters = fmt.Sprintf("%d", *obj.Status.AvailableReplicas) + } + if obj.Status.ReadyReplicas != nil { + v.readyCounters = fmt.Sprintf("%d", *obj.Status.ReadyReplicas) + } + if obj.Status.UpToDateReplicas != nil { + v.upToDateCounters = fmt.Sprintf("%d", *obj.Status.UpToDateReplicas) } case *clusterv1.Machine: diff --git a/test/framework/control_plane.go b/test/framework/control_plane.go index b0792e72ddbd..05411eeb76bb 100644 --- a/test/framework/control_plane.go +++ b/test/framework/control_plane.go @@ -44,6 +44,11 @@ func WaitForControlPlaneToBeUpToDate(ctx context.Context, input WaitForControlPl if err := input.Getter.Get(ctx, key, controlplane); err != nil { return 0, err } - return controlplane.Status.UpdatedReplicas, nil + // TODO (v1beta2) + updatedReplicas := int32(0) + if controlplane.Status.Deprecated != nil && controlplane.Status.Deprecated.V1Beta1 != nil { + updatedReplicas = controlplane.Status.Deprecated.V1Beta1.UpdatedReplicas + } + return updatedReplicas, nil }, intervals...).Should(Equal(*input.ControlPlane.Spec.Replicas), "Timed waiting for all control plane replicas to be updated") } diff --git a/test/framework/controlplane_helpers.go b/test/framework/controlplane_helpers.go index 3a5aa3795b6f..21fdb5d24fac 100644 --- a/test/framework/controlplane_helpers.go +++ b/test/framework/controlplane_helpers.go @@ -174,9 +174,15 @@ func WaitForControlPlaneToBeReady(ctx context.Context, input WaitForControlPlane desiredReplicas := controlplane.Spec.Replicas statusReplicas := controlplane.Status.Replicas - updatedReplicas := controlplane.Status.UpdatedReplicas - readyReplicas := controlplane.Status.ReadyReplicas - unavailableReplicas := controlplane.Status.UnavailableReplicas + // TODO (v1beta2) + updatedReplicas := int32(0) + readyReplicas := int32(0) + unavailableReplicas := int32(0) + if controlplane.Status.Deprecated != nil && controlplane.Status.Deprecated.V1Beta1 != nil { + updatedReplicas = controlplane.Status.Deprecated.V1Beta1.UpdatedReplicas + readyReplicas = controlplane.Status.Deprecated.V1Beta1.ReadyReplicas + unavailableReplicas = controlplane.Status.Deprecated.V1Beta1.UnavailableReplicas + } // Control plane is still rolling out (and thus not ready) if: // * .spec.replicas, .status.replicas, .status.updatedReplicas, diff --git a/test/framework/machinedeployment_helpers.go b/test/framework/machinedeployment_helpers.go index f6337fd07ef9..786cc9d74170 100644 --- a/test/framework/machinedeployment_helpers.go +++ b/test/framework/machinedeployment_helpers.go @@ -341,8 +341,10 @@ func UpgradeMachineDeploymentInfrastructureRefAndWait(ctx context.Context, input // MachineSet should be rolled out. g.Expect(newMachineSet.Spec.Replicas).To(Equal(deployment.Spec.Replicas)) g.Expect(*newMachineSet.Spec.Replicas).To(Equal(newMachineSet.Status.Replicas)) - g.Expect(*newMachineSet.Spec.Replicas).To(Equal(newMachineSet.Status.ReadyReplicas)) - g.Expect(*newMachineSet.Spec.Replicas).To(Equal(newMachineSet.Status.AvailableReplicas)) + g.Expect(*newMachineSet.Status.Deprecated).ToNot(BeNil()) + g.Expect(*newMachineSet.Status.Deprecated.V1Beta1).ToNot(BeNil()) + g.Expect(*newMachineSet.Spec.Replicas).To(Equal(newMachineSet.Status.Deprecated.V1Beta1.ReadyReplicas)) + g.Expect(*newMachineSet.Spec.Replicas).To(Equal(newMachineSet.Status.Deprecated.V1Beta1.AvailableReplicas)) // MachineSet should have the same infrastructureRef as the MachineDeployment. g.Expect(newMachineSet.Spec.Template.Spec.InfrastructureRef).To(BeComparableTo(deployment.Spec.Template.Spec.InfrastructureRef)) diff --git a/test/framework/machinepool_helpers.go b/test/framework/machinepool_helpers.go index 44e0e1830310..d7bb0874355d 100644 --- a/test/framework/machinepool_helpers.go +++ b/test/framework/machinepool_helpers.go @@ -87,7 +87,12 @@ func WaitForMachinePoolNodesToExist(ctx context.Context, input WaitForMachinePoo return 0, err } - return int(input.MachinePool.Status.ReadyReplicas), nil + // TODO (v1beta2) + readyReplicas := 0 + if input.MachinePool.Status.Deprecated != nil && input.MachinePool.Status.Deprecated.V1Beta1 != nil { + readyReplicas = int(input.MachinePool.Status.Deprecated.V1Beta1.ReadyReplicas) + } + return readyReplicas, nil }, intervals...).Should(Equal(int(*input.MachinePool.Spec.Replicas)), "Timed out waiting for %v ready replicas for MachinePool %s", *input.MachinePool.Spec.Replicas, klog.KObj(input.MachinePool)) } diff --git a/util/collections/machine_filters_test.go b/util/collections/machine_filters_test.go index 81edd5c0f37f..b7bcece778c9 100644 --- a/util/collections/machine_filters_test.go +++ b/util/collections/machine_filters_test.go @@ -456,10 +456,15 @@ func TestHasUnhealthyControlPlaneComponentCondition(t *testing.T) { machine.Status.NodeRef = &corev1.ObjectReference{ Name: "node1", } - machine.Status.Conditions = clusterv1.Conditions{ - *conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), + // TODO (v1beta2) + machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), + }, + }, } g.Expect(collections.HasUnhealthyControlPlaneComponents(false)(machine)).To(BeFalse()) }) @@ -470,11 +475,16 @@ func TestHasUnhealthyControlPlaneComponentCondition(t *testing.T) { machine.Status.NodeRef = &corev1.ObjectReference{ Name: "node1", } - machine.Status.Conditions = clusterv1.Conditions{ - *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), - *conditions.FalseCondition(controlplanev1.MachineAPIServerPodHealthyCondition, "", - clusterv1.ConditionSeverityWarning, ""), + // TODO (v1beta2) + machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), + *conditions.FalseCondition(controlplanev1.MachineAPIServerPodHealthyCondition, "", + clusterv1.ConditionSeverityWarning, ""), + }, + }, } g.Expect(collections.HasUnhealthyControlPlaneComponents(false)(machine)).To(BeTrue()) }) @@ -485,14 +495,19 @@ func TestHasUnhealthyControlPlaneComponentCondition(t *testing.T) { machine.Status.NodeRef = &corev1.ObjectReference{ Name: "node1", } - machine.Status.Conditions = clusterv1.Conditions{ - *conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), - *conditions.FalseCondition(controlplanev1.MachineEtcdPodHealthyCondition, "", - clusterv1.ConditionSeverityWarning, ""), - *conditions.FalseCondition(controlplanev1.MachineEtcdMemberHealthyCondition, "", - clusterv1.ConditionSeverityWarning, ""), + // TODO (v1beta2) + machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), + *conditions.FalseCondition(controlplanev1.MachineEtcdPodHealthyCondition, "", + clusterv1.ConditionSeverityWarning, ""), + *conditions.FalseCondition(controlplanev1.MachineEtcdMemberHealthyCondition, "", + clusterv1.ConditionSeverityWarning, ""), + }, + }, } g.Expect(collections.HasUnhealthyControlPlaneComponents(false)(machine)).To(BeFalse()) }) @@ -503,14 +518,19 @@ func TestHasUnhealthyControlPlaneComponentCondition(t *testing.T) { machine.Status.NodeRef = &corev1.ObjectReference{ Name: "node1", } - machine.Status.Conditions = clusterv1.Conditions{ - *conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), - *conditions.FalseCondition(controlplanev1.MachineEtcdPodHealthyCondition, "", - clusterv1.ConditionSeverityWarning, ""), - *conditions.FalseCondition(controlplanev1.MachineEtcdMemberHealthyCondition, "", - clusterv1.ConditionSeverityWarning, ""), + // TODO (v1beta2) + machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), + *conditions.FalseCondition(controlplanev1.MachineEtcdPodHealthyCondition, "", + clusterv1.ConditionSeverityWarning, ""), + *conditions.FalseCondition(controlplanev1.MachineEtcdMemberHealthyCondition, "", + clusterv1.ConditionSeverityWarning, ""), + }, + }, } g.Expect(collections.HasUnhealthyControlPlaneComponents(true)(machine)).To(BeTrue()) }) @@ -521,12 +541,17 @@ func TestHasUnhealthyControlPlaneComponentCondition(t *testing.T) { machine.Status.NodeRef = &corev1.ObjectReference{ Name: "node1", } - machine.Status.Conditions = clusterv1.Conditions{ - *conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineEtcdPodHealthyCondition), - *conditions.TrueCondition(controlplanev1.MachineEtcdMemberHealthyCondition), + // TODO (v1beta2) + machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{ + V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + *conditions.TrueCondition(controlplanev1.MachineAPIServerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineControllerManagerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineSchedulerPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineEtcdPodHealthyCondition), + *conditions.TrueCondition(controlplanev1.MachineEtcdMemberHealthyCondition), + }, + }, } g.Expect(collections.HasUnhealthyControlPlaneComponents(true)(machine)).To(BeFalse()) }) diff --git a/util/conditions/patch_test.go b/util/conditions/patch_test.go index ef7ee776939e..fc1e0d44a673 100644 --- a/util/conditions/patch_test.go +++ b/util/conditions/patch_test.go @@ -318,11 +318,16 @@ func TestApplyDoesNotAlterLastTransitionTime(t *testing.T) { before := &clusterv1.Cluster{} after := &clusterv1.Cluster{ Status: clusterv1.ClusterStatus{ - Conditions: clusterv1.Conditions{ - clusterv1.Condition{ - Type: "foo", - Status: corev1.ConditionTrue, - LastTransitionTime: metav1.NewTime(time.Now().UTC().Truncate(time.Second)), + // TODO (v1beta2) + Deprecated: &clusterv1.ClusterDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ + Conditions: clusterv1.Conditions{ + clusterv1.Condition{ + Type: "foo", + Status: corev1.ConditionTrue, + LastTransitionTime: metav1.NewTime(time.Now().UTC().Truncate(time.Second)), + }, + }, }, }, }, diff --git a/util/conditions/unstructured_test.go b/util/conditions/unstructured_test.go index 8dfc0b72d62d..ec2d8d544396 100644 --- a/util/conditions/unstructured_test.go +++ b/util/conditions/unstructured_test.go @@ -32,17 +32,23 @@ func TestUnstructuredGetConditions(t *testing.T) { g := NewWithT(t) // GetConditions should return conditions from an unstructured object - c := &clusterv1.Cluster{} - c.SetConditions(conditionList(true1)) - u := &unstructured.Unstructured{} - g.Expect(scheme.Scheme.Convert(c, u, nil)).To(Succeed()) + u := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "status": map[string]interface{}{ + "conditions": []interface{}{ + map[string]interface{}{ + "type": "true1", + "status": "True", + }, + }, + }, + }, + } g.Expect(UnstructuredGetter(u).GetConditions()).To(haveSameConditionsOf(conditionList(true1))) // GetConditions should return nil for an unstructured object with empty conditions - c = &clusterv1.Cluster{} u = &unstructured.Unstructured{} - g.Expect(scheme.Scheme.Convert(c, u, nil)).To(Succeed()) g.Expect(UnstructuredGetter(u).GetConditions()).To(BeNil()) diff --git a/util/patch/patch_test.go b/util/patch/patch_test.go index c1ffcf4b164a..fe5165500609 100644 --- a/util/patch/patch_test.go +++ b/util/patch/patch_test.go @@ -213,8 +213,8 @@ func TestPatchHelper(t *testing.T) { if err := env.Get(ctx, key, objAfter); err != nil { return clusterv1.Conditions{} } - return objAfter.Status.Conditions - }, timeout).Should(conditions.MatchConditions(obj.Status.Conditions)) + return objAfter.Status.Deprecated.V1Beta1.Conditions + }, timeout).Should(conditions.MatchConditions(obj.Status.Deprecated.V1Beta1.Conditions)) }) t.Run("should recover if there is a resolvable conflict", func(t *testing.T) { @@ -403,8 +403,8 @@ func TestPatchHelper(t *testing.T) { return false } - for _, afterCondition := range objAfter.Status.Conditions { - ok, err := conditions.MatchCondition(objCopy.Status.Conditions[0]).Match(afterCondition) + for _, afterCondition := range objAfter.Status.Deprecated.V1Beta1.Conditions { + ok, err := conditions.MatchCondition(objCopy.Status.Deprecated.V1Beta1.Conditions[0]).Match(afterCondition) if err == nil && ok { return true } @@ -869,8 +869,8 @@ func TestPatchHelper(t *testing.T) { obj.Spec.Replicas = ptr.To[int32](10) t.Log("Updating the object status") - obj.Status.AvailableReplicas = 6 - obj.Status.ReadyReplicas = 6 + obj.Status.AvailableReplicas = ptr.To[int32](6) + obj.Status.ReadyReplicas = ptr.To[int32](6) t.Log("Updating the object metadata") obj.ObjectMeta.Annotations = map[string]string{ diff --git a/util/test/builder/builders.go b/util/test/builder/builders.go index b97323d95c40..a2a3202edada 100644 --- a/util/test/builder/builders.go +++ b/util/test/builder/builders.go @@ -491,10 +491,15 @@ func (c *ClusterClassBuilder) Build() *clusterv1.ClusterClass { Patches: c.patches, }, Status: clusterv1.ClusterClassStatus{ - Conditions: c.conditions, - Variables: c.statusVariables, + Variables: c.statusVariables, }, } + // TODO (v1beta2) + if c.conditions != nil { + obj.Status.Deprecated = &clusterv1.ClusterClassDeprecatedStatus{ + V1Beta1: &clusterv1.ClusterClassV1Beta1DeprecatedStatus{Conditions: c.conditions}, + } + } if c.infrastructureClusterTemplate != nil { obj.Spec.Infrastructure = clusterv1.LocalObjectTemplate{ Ref: objToRef(c.infrastructureClusterTemplate), From 29f3146b3d9a4e3ce44f2f135978ee247e051874 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Tue, 8 Apr 2025 15:03:19 +0200 Subject: [PATCH 05/11] Address feedback --- api/addons/v1beta1/conversion.go | 4 +- api/addons/v1beta1/conversion_test.go | 9 ++-- api/v1beta1/conversion.go | 44 +++++++++--------- api/v1beta1/conversion_test.go | 45 ++++++++++--------- bootstrap/kubeadm/api/v1beta1/conversion.go | 4 +- .../kubeadm/api/v1beta1/conversion_test.go | 4 +- .../types/upstreamv1beta2/conversion_test.go | 2 +- .../types/upstreamv1beta3/conversion_test.go | 4 +- .../bases/cluster.x-k8s.io_machinepools.yaml | 13 +++--- .../kubeadm/api/v1beta1/conversion.go | 4 +- .../kubeadm/api/v1beta1/conversion_test.go | 4 +- exp/api/v1beta1/conversion.go | 14 +++--- exp/api/v1beta1/conversion_test.go | 7 +-- exp/api/v1beta2/machinepool_types.go | 6 +++ .../machinepool_controller_noderef.go | 2 +- .../machinepool_controller_phases.go | 2 +- exp/ipam/api/v1alpha1/conversion.go | 4 +- exp/ipam/api/v1alpha1/conversion_test.go | 5 ++- exp/ipam/api/v1beta1/conversion.go | 8 ++-- exp/ipam/api/v1beta1/conversion_test.go | 7 +-- internal/apis/addons/v1alpha3/conversion.go | 4 +- .../apis/addons/v1alpha3/conversion_test.go | 5 ++- internal/apis/addons/v1alpha4/conversion.go | 4 +- .../apis/addons/v1alpha4/conversion_test.go | 5 ++- .../bootstrap/kubeadm/v1alpha3/conversion.go | 4 +- .../kubeadm/v1alpha3/conversion_test.go | 2 +- .../bootstrap/kubeadm/v1alpha4/conversion.go | 4 +- .../kubeadm/v1alpha4/conversion_test.go | 2 +- .../kubeadm/v1alpha3/conversion.go | 4 +- .../kubeadm/v1alpha3/conversion_test.go | 2 +- .../kubeadm/v1alpha4/conversion.go | 4 +- .../kubeadm/v1alpha4/conversion_test.go | 4 +- internal/apis/core/exp/v1alpha3/conversion.go | 4 +- .../apis/core/exp/v1alpha3/conversion_test.go | 4 +- internal/apis/core/exp/v1alpha4/conversion.go | 4 +- .../apis/core/exp/v1alpha4/conversion_test.go | 2 +- internal/apis/core/v1alpha3/conversion.go | 16 +++---- .../apis/core/v1alpha3/conversion_test.go | 23 ++++++---- internal/apis/core/v1alpha4/conversion.go | 26 +++++------ .../apis/core/v1alpha4/conversion_test.go | 17 +++---- .../machinedeployment_rolling.go | 4 +- .../machinedeployment_sync.go | 2 +- .../machinedeployment/mdutil/util.go | 6 +-- .../machineset/machineset_controller.go | 6 +-- test/framework/control_plane.go | 2 +- test/framework/controlplane_helpers.go | 2 +- test/framework/machinepool_helpers.go | 2 +- util/collections/machine_filters_test.go | 10 ++--- util/conditions/patch_test.go | 2 +- util/test/builder/builders.go | 2 +- 50 files changed, 199 insertions(+), 171 deletions(-) diff --git a/api/addons/v1beta1/conversion.go b/api/addons/v1beta1/conversion.go index c22e69c4a4b4..4f6bb29a67ea 100644 --- a/api/addons/v1beta1/conversion.go +++ b/api/addons/v1beta1/conversion.go @@ -61,7 +61,7 @@ func Convert_v1beta2_ClusterResourceSetStatus_To_v1beta1_ClusterResourceSetStatu // Retrieve legacy conditions (v1beta1) from the deprecated field. if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { if in.Deprecated.V1Beta1.Conditions != nil { - clusterv1beta1.Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + clusterv1beta1.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) } } @@ -100,7 +100,7 @@ func Convert_v1beta1_ClusterResourceSetStatus_To_v1beta2_ClusterResourceSetStatu out.Deprecated.V1Beta1 = &addonsv1.ClusterResourceSetV1Beta1DeprecatedStatus{} } if in.Conditions != nil { - clusterv1beta1.Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + clusterv1beta1.Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) } return nil } diff --git a/api/addons/v1beta1/conversion_test.go b/api/addons/v1beta1/conversion_test.go index 04314c0c5013..6114954b95ae 100644 --- a/api/addons/v1beta1/conversion_test.go +++ b/api/addons/v1beta1/conversion_test.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "reflect" "testing" fuzz "github.com/google/gofuzz" @@ -51,20 +52,20 @@ func ClusterResourceSetFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} } func hubClusterResourceSetStatus(in *addonsv1.ClusterResourceSetStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &addonsv1.ClusterResourceSetV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } } func spokeClusterResourceSetStatus(in *ClusterResourceSetStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { - if in.V1Beta2.Conditions == nil { + if reflect.DeepEqual(in.V1Beta2, &ClusterResourceSetV1Beta2Status{}) { in.V1Beta2 = nil } } diff --git a/api/v1beta1/conversion.go b/api/v1beta1/conversion.go index d3c4b5584708..a2cdc3b88330 100644 --- a/api/v1beta1/conversion.go +++ b/api/v1beta1/conversion.go @@ -110,7 +110,7 @@ func Convert_v1beta2_ClusterClassStatus_To_v1beta1_ClusterClassStatus(in *cluste // Retrieve legacy conditions (v1beta1) from the deprecated field. if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { if in.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) } } @@ -149,7 +149,7 @@ func Convert_v1beta1_ClusterClassStatus_To_v1beta2_ClusterClassStatus(in *Cluste out.Deprecated.V1Beta1 = &clusterv1.ClusterClassV1Beta1DeprecatedStatus{} } if in.Conditions != nil { - Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) } return nil } @@ -166,7 +166,7 @@ func Convert_v1beta2_ClusterStatus_To_v1beta1_ClusterStatus(in *clusterv1.Cluste // Retrieve legacy conditions (v1beta1) from the deprecated field. if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { if in.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) } out.FailureReason = in.Deprecated.V1Beta1.FailureReason out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage @@ -243,7 +243,7 @@ func Convert_v1beta1_ClusterStatus_To_v1beta2_ClusterStatus(in *ClusterStatus, o out.Deprecated.V1Beta1 = &clusterv1.ClusterV1Beta1DeprecatedStatus{} } if in.Conditions != nil { - Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) } out.Deprecated.V1Beta1.FailureReason = in.FailureReason out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage @@ -267,7 +267,7 @@ func Convert_v1beta2_MachineDeploymentStatus_To_v1beta1_MachineDeploymentStatus( // Retrieve legacy conditions (v1beta1) and replica counters from the deprecated field. if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { if in.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) } out.AvailableReplicas = in.Deprecated.V1Beta1.AvailableReplicas out.UnavailableReplicas = in.Deprecated.V1Beta1.UnavailableReplicas @@ -317,7 +317,7 @@ func Convert_v1beta1_MachineDeploymentStatus_To_v1beta2_MachineDeploymentStatus( out.Deprecated.V1Beta1 = &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{} } if in.Conditions != nil { - Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) } out.Deprecated.V1Beta1.AvailableReplicas = in.AvailableReplicas out.Deprecated.V1Beta1.UnavailableReplicas = in.UnavailableReplicas @@ -338,7 +338,7 @@ func Convert_v1beta2_MachineHealthCheckStatus_To_v1beta1_MachineHealthCheckStatu // Retrieve legacy conditions (v1beta1) from the deprecated field. if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { if in.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) } } @@ -377,7 +377,7 @@ func Convert_v1beta1_MachineHealthCheckStatus_To_v1beta2_MachineHealthCheckStatu out.Deprecated.V1Beta1 = &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{} } if in.Conditions != nil { - Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) } return nil } @@ -396,10 +396,10 @@ func Convert_v1beta2_MachineSetStatus_To_v1beta1_MachineSetStatus(in *clusterv1. out.AvailableReplicas = 0 out.ReadyReplicas = 0 - // Retrieve legacy conditions (v1beta1) and replica counters from the deprecated field. + // Retrieve legacy conditions (v1beta1), failureReason, failureMessage, and replica counters from the deprecated field. if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { if in.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) } out.AvailableReplicas = in.Deprecated.V1Beta1.AvailableReplicas out.FullyLabeledReplicas = in.Deprecated.V1Beta1.FullyLabeledReplicas @@ -434,7 +434,7 @@ func Convert_v1beta1_MachineSetStatus_To_v1beta2_MachineSetStatus(in *MachineSet out.AvailableReplicas = nil out.ReadyReplicas = nil - // Retrieve new conditions (v1beta2) from the v1beta2 field. + // Retrieve new conditions (v1beta2) and replica counters from the v1beta2 field. if in.V1Beta2 != nil { out.Conditions = in.V1Beta2.Conditions out.ReadyReplicas = in.V1Beta2.ReadyReplicas @@ -442,7 +442,7 @@ func Convert_v1beta1_MachineSetStatus_To_v1beta2_MachineSetStatus(in *MachineSet out.UpToDateReplicas = in.V1Beta2.UpToDateReplicas } - // Move legacy conditions (v1beta1) to the deprecated field. + // Move legacy conditions (v1beta1), failureReason, failureMessage, and replica counters to the deprecated field. if out.Deprecated == nil { out.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} } @@ -450,7 +450,7 @@ func Convert_v1beta1_MachineSetStatus_To_v1beta2_MachineSetStatus(in *MachineSet out.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} } if in.Conditions != nil { - Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) } out.Deprecated.V1Beta1.AvailableReplicas = in.AvailableReplicas out.Deprecated.V1Beta1.FullyLabeledReplicas = in.FullyLabeledReplicas @@ -469,11 +469,13 @@ func Convert_v1beta2_MachineStatus_To_v1beta1_MachineStatus(in *clusterv1.Machin // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). out.Conditions = nil - // Retrieve legacy conditions (v1beta1) from the deprecated field. + // Retrieve legacy conditions (v1beta1), failureReason and failureMessage from the deprecated field. if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { if in.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) } + out.FailureReason = in.Deprecated.V1Beta1.FailureReason + out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage } // Move new conditions (v1beta2) to the v1beta2 field. @@ -499,8 +501,8 @@ func Convert_v1beta1_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, o out.Conditions = in.V1Beta2.Conditions } - // Move legacy conditions (v1beta1) to the deprecated field. - if in.Conditions == nil { + // Move legacy conditions (v1beta1), failureReason and failureMessage to the deprecated field. + if in.Conditions == nil && in.FailureReason == nil && in.FailureMessage == nil { return nil } @@ -511,19 +513,21 @@ func Convert_v1beta1_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, o out.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} } if in.Conditions != nil { - Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) } + out.Deprecated.V1Beta1.FailureReason = in.FailureReason + out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage return nil } -func Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(in *clusterv1.Conditions, out *Conditions) { +func Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(in *clusterv1.Conditions, out *Conditions) { *out = make(Conditions, len(*in)) for i := range *in { (*out)[i] = *(*Condition)(unsafe.Pointer(&(*in)[i])) //nolint:gosec } } -func Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(in *Conditions, out *clusterv1.Conditions) { +func Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(in *Conditions, out *clusterv1.Conditions) { *out = make(clusterv1.Conditions, len(*in)) for i := range *in { (*out)[i] = *(*clusterv1.Condition)(unsafe.Pointer(&(*in)[i])) //nolint:gosec diff --git a/api/v1beta1/conversion_test.go b/api/v1beta1/conversion_test.go index d692e2c20f4b..37780fb70016 100644 --- a/api/v1beta1/conversion_test.go +++ b/api/v1beta1/conversion_test.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "reflect" "strconv" "testing" @@ -75,20 +76,20 @@ func ClusterFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubClusterStatus(in *clusterv1.ClusterStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || (in.Deprecated.V1Beta1.Conditions == nil && in.Deprecated.V1Beta1.FailureReason == nil && in.Deprecated.V1Beta1.FailureMessage == nil) { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &clusterv1.ClusterV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } } func spokeClusterStatus(in *ClusterStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { - if in.V1Beta2.Conditions == nil && in.V1Beta2.ControlPlane == nil && in.V1Beta2.Workers == nil { + if reflect.DeepEqual(in.V1Beta2, &ClusterV1Beta2Status{}) { in.V1Beta2 = nil } } @@ -104,10 +105,10 @@ func ClusterClassFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubClusterClassStatus(in *clusterv1.ClusterClassStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &clusterv1.ClusterClassV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } @@ -157,10 +158,10 @@ func hubJSONSchemaProps(in *clusterv1.JSONSchemaProps, c fuzz.Continue) { } func spokeClusterClassStatus(in *ClusterClassStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { - if in.V1Beta2.Conditions == nil { + if reflect.DeepEqual(in.V1Beta2, &ClusterClassV1Beta2Status{}) { in.V1Beta2 = nil } } @@ -217,20 +218,20 @@ func MachineFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubMachineStatus(in *clusterv1.MachineStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || (in.Deprecated.V1Beta1.Conditions == nil && in.Deprecated.V1Beta1.FailureReason == nil && in.Deprecated.V1Beta1.FailureMessage == nil) { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &clusterv1.MachineV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } } func spokeMachineStatus(in *MachineStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { - if in.V1Beta2.Conditions == nil { + if reflect.DeepEqual(in.V1Beta2, &MachineV1Beta2Status{}) { in.V1Beta2 = nil } } @@ -244,7 +245,7 @@ func MachineSetFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubMachineSetStatus(in *clusterv1.MachineSetStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} @@ -255,10 +256,10 @@ func hubMachineSetStatus(in *clusterv1.MachineSetStatus, c fuzz.Continue) { } func spokeMachineSetStatus(in *MachineSetStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { - if in.V1Beta2.Conditions == nil && in.V1Beta2.ReadyReplicas == nil && in.V1Beta2.AvailableReplicas == nil && in.V1Beta2.UpToDateReplicas == nil { + if reflect.DeepEqual(in.V1Beta2, &MachineSetV1Beta2Status{}) { in.V1Beta2 = nil } } @@ -272,7 +273,7 @@ func MachineDeploymentFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} } func hubMachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &clusterv1.MachineDeploymentDeprecatedStatus{} @@ -283,10 +284,10 @@ func hubMachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, c fuzz.Co } func spokeMachineDeploymentStatus(in *MachineDeploymentStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { - if in.V1Beta2.Conditions == nil && in.V1Beta2.ReadyReplicas == nil && in.V1Beta2.AvailableReplicas == nil && in.V1Beta2.UpToDateReplicas == nil { + if reflect.DeepEqual(in.V1Beta2, &MachineDeploymentV1Beta2Status{}) { in.V1Beta2 = nil } } @@ -300,20 +301,20 @@ func MachineHealthCheckFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} } func hubMachineHealthCheckStatus(in *clusterv1.MachineHealthCheckStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } } func spokeMachineHealthCheckStatus(in *MachineHealthCheckStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { - if in.V1Beta2.Conditions == nil { + if reflect.DeepEqual(in.V1Beta2, &MachineHealthCheckV1Beta2Status{}) { in.V1Beta2 = nil } } diff --git a/bootstrap/kubeadm/api/v1beta1/conversion.go b/bootstrap/kubeadm/api/v1beta1/conversion.go index 3c70b90d7ae5..74e67d94ae15 100644 --- a/bootstrap/kubeadm/api/v1beta1/conversion.go +++ b/bootstrap/kubeadm/api/v1beta1/conversion.go @@ -62,7 +62,7 @@ func Convert_v1beta2_KubeadmConfigStatus_To_v1beta1_KubeadmConfigStatus(in *boot // Retrieve legacy conditions (v1beta1), failureReason and failureMessage from the deprecated field. if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { if in.Deprecated.V1Beta1.Conditions != nil { - clusterv1beta1.Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + clusterv1beta1.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) } out.FailureReason = in.Deprecated.V1Beta1.FailureReason out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage @@ -99,7 +99,7 @@ func Convert_v1beta1_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in *Kube out.Deprecated.V1Beta1 = &bootstrapv1.KubeadmConfigV1Beta1DeprecatedStatus{} } if in.Conditions != nil { - clusterv1beta1.Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + clusterv1beta1.Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) } out.Deprecated.V1Beta1.FailureReason = in.FailureReason out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage diff --git a/bootstrap/kubeadm/api/v1beta1/conversion_test.go b/bootstrap/kubeadm/api/v1beta1/conversion_test.go index 4671132eeffa..668ad3222060 100644 --- a/bootstrap/kubeadm/api/v1beta1/conversion_test.go +++ b/bootstrap/kubeadm/api/v1beta1/conversion_test.go @@ -51,7 +51,7 @@ func KubeadmConfigFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubKubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} @@ -62,7 +62,7 @@ func hubKubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, c fuzz.Continue } func spokeKubeadmConfigStatus(in *KubeadmConfigStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { if in.V1Beta2.Conditions == nil { diff --git a/bootstrap/kubeadm/types/upstreamv1beta2/conversion_test.go b/bootstrap/kubeadm/types/upstreamv1beta2/conversion_test.go index 292a8a0f7edc..0b5c567c6bab 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta2/conversion_test.go +++ b/bootstrap/kubeadm/types/upstreamv1beta2/conversion_test.go @@ -93,7 +93,7 @@ func dnsFuzzer(obj *DNS, c fuzz.Continue) { } func initConfigurationFuzzer(obj *InitConfiguration, c fuzz.Continue) { - c.Fuzz(obj) + c.FuzzNoCustom(obj) obj.CertificateKey = "" } diff --git a/bootstrap/kubeadm/types/upstreamv1beta3/conversion_test.go b/bootstrap/kubeadm/types/upstreamv1beta3/conversion_test.go index 8ff39d1730f6..830b654e7cf4 100644 --- a/bootstrap/kubeadm/types/upstreamv1beta3/conversion_test.go +++ b/bootstrap/kubeadm/types/upstreamv1beta3/conversion_test.go @@ -83,14 +83,14 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { // - When fields do not exist in cabpk v1beta1 types, pinning it to avoid kubeadm v1beta3 --> cabpk v1beta1 --> kubeadm v1beta3 round trip errors. func initConfigurationFuzzer(obj *InitConfiguration, c fuzz.Continue) { - c.Fuzz(obj) + c.FuzzNoCustom(obj) obj.CertificateKey = "" obj.SkipPhases = nil } func joinConfigurationFuzzer(obj *JoinConfiguration, c fuzz.Continue) { - c.Fuzz(obj) + c.FuzzNoCustom(obj) obj.SkipPhases = nil } diff --git a/config/crd/bases/cluster.x-k8s.io_machinepools.yaml b/config/crd/bases/cluster.x-k8s.io_machinepools.yaml index ae0a00bd843c..7eef5764aede 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinepools.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinepools.yaml @@ -2032,8 +2032,10 @@ spec: and will be removed when support for v1beta1 will be dropped. properties: availableReplicas: - description: availableReplicas is the number of available - replicas (ready for at least minReadySeconds) for this MachinePool. + description: |- + availableReplicas is the number of available replicas (ready for at least minReadySeconds) for this MachinePool. + + Deprecated: This field 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. format: int32 type: integer conditions: @@ -2109,9 +2111,10 @@ spec: Deprecated: This field 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. type: string readyReplicas: - description: readyReplicas is the number of ready replicas - for this MachinePool. A machine is considered ready when - the node has been created and is "Ready". + description: |- + readyReplicas is the number of ready replicas for this MachinePool. A machine is considered ready when the node has been created and is "Ready". + + Deprecated: This field 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. format: int32 type: integer unavailableReplicas: diff --git a/controlplane/kubeadm/api/v1beta1/conversion.go b/controlplane/kubeadm/api/v1beta1/conversion.go index a5a51e4d792f..b5543cf5686b 100644 --- a/controlplane/kubeadm/api/v1beta1/conversion.go +++ b/controlplane/kubeadm/api/v1beta1/conversion.go @@ -68,7 +68,7 @@ func Convert_v1beta2_KubeadmControlPlaneStatus_To_v1beta1_KubeadmControlPlaneSta // Retrieve legacy conditions (v1beta1), failureReason, failureMessage and replica counters from the deprecated field. if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { if in.Deprecated.V1Beta1.Conditions != nil { - clusterv1beta1.Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + clusterv1beta1.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) } out.FailureReason = in.Deprecated.V1Beta1.FailureReason out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage @@ -118,7 +118,7 @@ func Convert_v1beta1_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneSta out.Deprecated.V1Beta1 = &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{} } if in.Conditions != nil { - clusterv1beta1.Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + clusterv1beta1.Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) } out.Deprecated.V1Beta1.FailureReason = in.FailureReason out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage diff --git a/controlplane/kubeadm/api/v1beta1/conversion_test.go b/controlplane/kubeadm/api/v1beta1/conversion_test.go index 2d7debf1c5b8..f6b36331631c 100644 --- a/controlplane/kubeadm/api/v1beta1/conversion_test.go +++ b/controlplane/kubeadm/api/v1beta1/conversion_test.go @@ -51,7 +51,7 @@ func KubeadmControlPlaneFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{ } func hubKubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} @@ -62,7 +62,7 @@ func hubKubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus, } func spokeKubeadmControlPlaneStatus(in *KubeadmControlPlaneStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { if in.V1Beta2.Conditions == nil && in.V1Beta2.AvailableReplicas == nil && in.V1Beta2.ReadyReplicas == nil && in.V1Beta2.UpToDateReplicas == nil { diff --git a/exp/api/v1beta1/conversion.go b/exp/api/v1beta1/conversion.go index 9a063807cfe5..1876a06a9e4a 100644 --- a/exp/api/v1beta1/conversion.go +++ b/exp/api/v1beta1/conversion.go @@ -52,10 +52,10 @@ func Convert_v1beta2_MachinePoolStatus_To_v1beta1_MachinePoolStatus(in *expv1.Ma out.ReadyReplicas = 0 out.AvailableReplicas = 0 - // Retrieve legacy conditions (v1beta1), failureReason and failureMessage from the deprecated field. + // Retrieve legacy conditions (v1beta1), failureReason, failureMessage and replica counters from the deprecated field. if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { if in.Deprecated.V1Beta1.Conditions != nil { - clusterv1beta1.Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + clusterv1beta1.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) } out.FailureReason = in.Deprecated.V1Beta1.FailureReason out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage @@ -64,8 +64,8 @@ func Convert_v1beta2_MachinePoolStatus_To_v1beta1_MachinePoolStatus(in *expv1.Ma out.UnavailableReplicas = in.Deprecated.V1Beta1.UnavailableReplicas } - // Move new conditions (v1beta2) to the v1beta2 field. - if in.Conditions == nil { + // Move new conditions (v1beta2) and replica counters to the v1beta2 field. + if in.Conditions == nil && in.ReadyReplicas == nil && in.AvailableReplicas == nil && in.UpToDateReplicas == nil { return nil } out.V1Beta2 = &MachinePoolV1Beta2Status{} @@ -90,7 +90,7 @@ func Convert_v1beta1_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachineP out.ReadyReplicas = nil out.AvailableReplicas = nil - // Retrieve new conditions (v1beta2) from the v1beta2 field. + // Retrieve new conditions (v1beta2) and replica counters from the v1beta2 field. if in.V1Beta2 != nil { out.Conditions = in.V1Beta2.Conditions out.ReadyReplicas = in.V1Beta2.ReadyReplicas @@ -98,7 +98,7 @@ func Convert_v1beta1_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachineP out.UpToDateReplicas = in.V1Beta2.UpToDateReplicas } - // Move legacy conditions (v1beta1), failureReason and failureMessage to the deprecated field. + // Move legacy conditions (v1beta1), failureReason, failureMessage and replica counters to the deprecated field. if out.Deprecated == nil { out.Deprecated = &expv1.MachinePoolDeprecatedStatus{} } @@ -106,7 +106,7 @@ func Convert_v1beta1_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachineP out.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} } if in.Conditions != nil { - clusterv1beta1.Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + clusterv1beta1.Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) } out.Deprecated.V1Beta1.FailureReason = in.FailureReason out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage diff --git a/exp/api/v1beta1/conversion_test.go b/exp/api/v1beta1/conversion_test.go index 5b8eea2bdd38..6168cc8ebb60 100644 --- a/exp/api/v1beta1/conversion_test.go +++ b/exp/api/v1beta1/conversion_test.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "reflect" "testing" fuzz "github.com/google/gofuzz" @@ -47,7 +48,7 @@ func MachinePoolFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubMachinePoolStatus(in *expv1.MachinePoolStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &expv1.MachinePoolDeprecatedStatus{} @@ -58,10 +59,10 @@ func hubMachinePoolStatus(in *expv1.MachinePoolStatus, c fuzz.Continue) { } func spokeMachinePoolStatus(in *MachinePoolStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { - if in.V1Beta2.Conditions == nil && in.V1Beta2.AvailableReplicas == nil && in.V1Beta2.ReadyReplicas == nil && in.V1Beta2.UpToDateReplicas == nil { + if reflect.DeepEqual(in.V1Beta2, &MachinePoolV1Beta2Status{}) { in.V1Beta2 = nil } } diff --git a/exp/api/v1beta2/machinepool_types.go b/exp/api/v1beta2/machinepool_types.go index 29e558debadf..754da82d1ab7 100644 --- a/exp/api/v1beta2/machinepool_types.go +++ b/exp/api/v1beta2/machinepool_types.go @@ -166,10 +166,16 @@ type MachinePoolV1Beta1DeprecatedStatus struct { FailureMessage *string `json:"failureMessage,omitempty"` // readyReplicas is the number of ready replicas for this MachinePool. A machine is considered ready when the node has been created and is "Ready". + // + // Deprecated: This field 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. + // // +optional ReadyReplicas int32 `json:"readyReplicas,omitempty"` // availableReplicas is the number of available replicas (ready for at least minReadySeconds) for this MachinePool. + // + // Deprecated: This field 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. + // // +optional AvailableReplicas int32 `json:"availableReplicas,omitempty"` diff --git a/exp/internal/controllers/machinepool_controller_noderef.go b/exp/internal/controllers/machinepool_controller_noderef.go index 60cf557efcba..88e8c3897213 100644 --- a/exp/internal/controllers/machinepool_controller_noderef.go +++ b/exp/internal/controllers/machinepool_controller_noderef.go @@ -64,7 +64,7 @@ func (r *MachinePoolReconciler) reconcileNodeRefs(ctx context.Context, s *scope) // Check that the Machine doesn't already have a NodeRefs. // Return early if there is no work to do. - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters readyReplicas := int32(0) if mp.Status.Deprecated != nil && mp.Status.Deprecated.V1Beta1 != nil { readyReplicas = mp.Status.Deprecated.V1Beta1.ReadyReplicas diff --git a/exp/internal/controllers/machinepool_controller_phases.go b/exp/internal/controllers/machinepool_controller_phases.go index d640be6b522e..e7b7f4394f92 100644 --- a/exp/internal/controllers/machinepool_controller_phases.go +++ b/exp/internal/controllers/machinepool_controller_phases.go @@ -69,7 +69,7 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) { } // Set the phase to "running" if the number of ready replicas is equal to desired replicas. - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters readyReplicas := int32(0) if mp.Status.Deprecated != nil && mp.Status.Deprecated.V1Beta1 != nil { readyReplicas = mp.Status.Deprecated.V1Beta1.ReadyReplicas diff --git a/exp/ipam/api/v1alpha1/conversion.go b/exp/ipam/api/v1alpha1/conversion.go index 85024f83eaa0..4bcc2dff0ee4 100644 --- a/exp/ipam/api/v1alpha1/conversion.go +++ b/exp/ipam/api/v1alpha1/conversion.go @@ -49,7 +49,7 @@ func (src *IPAddressClaim) ConvertTo(dstRaw conversion.Hub) error { if src.Status.Conditions != nil { dst.Status.Deprecated = &ipamv1.IPAddressClaimDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &ipamv1.IPAddressClaimV1Beta1DeprecatedStatus{} - clusterv1beta1.Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + clusterv1beta1.Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } if src.ObjectMeta.Labels != nil { @@ -89,7 +89,7 @@ func (dst *IPAddressClaim) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - clusterv1beta1.Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + clusterv1beta1.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } } } diff --git a/exp/ipam/api/v1alpha1/conversion_test.go b/exp/ipam/api/v1alpha1/conversion_test.go index 982d4b8a1f55..501534a75375 100644 --- a/exp/ipam/api/v1alpha1/conversion_test.go +++ b/exp/ipam/api/v1alpha1/conversion_test.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha1 import ( + "reflect" "testing" fuzz "github.com/google/gofuzz" @@ -50,10 +51,10 @@ func IPAddressClaimFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubIPAddressClaimStatus(in *ipamv1.IPAddressClaimStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &ipamv1.IPAddressClaimV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } diff --git a/exp/ipam/api/v1beta1/conversion.go b/exp/ipam/api/v1beta1/conversion.go index b87a00c6e74e..93176531220d 100644 --- a/exp/ipam/api/v1beta1/conversion.go +++ b/exp/ipam/api/v1beta1/conversion.go @@ -58,10 +58,10 @@ func Convert_v1beta2_IPAddressClaimStatus_To_v1beta1_IPAddressClaimStatus(in *ip // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1beta1). out.Conditions = nil - // Retrieve legacy conditions (v1beta1), failureReason and failureMessage from the deprecated field. + // Retrieve legacy conditions (v1beta1) from the deprecated field. if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { if in.Deprecated.V1Beta1.Conditions != nil { - clusterv1beta1.Convert_v1beta2_Conditions_To_Deprecated_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) + clusterv1beta1.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1beta1_Conditions(&in.Deprecated.V1Beta1.Conditions, &out.Conditions) } } @@ -88,7 +88,7 @@ func Convert_v1beta1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus(in *IP out.Conditions = in.V1Beta2.Conditions } - // Move legacy conditions (v1beta1), failureReason and failureMessage to the deprecated field. + // Move legacy conditions (v1beta1) to the deprecated field. if out.Deprecated == nil { out.Deprecated = &ipamv1.IPAddressClaimDeprecatedStatus{} } @@ -96,7 +96,7 @@ func Convert_v1beta1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus(in *IP out.Deprecated.V1Beta1 = &ipamv1.IPAddressClaimV1Beta1DeprecatedStatus{} } if in.Conditions != nil { - clusterv1beta1.Convert_Deprecated_v1beta1_Conditions_To_v1beta2_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) + clusterv1beta1.Convert_v1beta1_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&in.Conditions, &out.Deprecated.V1Beta1.Conditions) } return nil } diff --git a/exp/ipam/api/v1beta1/conversion_test.go b/exp/ipam/api/v1beta1/conversion_test.go index 32929da5d661..8c3772a1ab42 100644 --- a/exp/ipam/api/v1beta1/conversion_test.go +++ b/exp/ipam/api/v1beta1/conversion_test.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "reflect" "testing" fuzz "github.com/google/gofuzz" @@ -51,7 +52,7 @@ func IPAddressClaimFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubIPAddressClaimStatus(in *ipamv1.IPAddressClaimStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &ipamv1.IPAddressClaimDeprecatedStatus{} @@ -62,10 +63,10 @@ func hubIPAddressClaimStatus(in *ipamv1.IPAddressClaimStatus, c fuzz.Continue) { } func spokeIPAddressClaimStatus(in *IPAddressClaimStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { - if in.V1Beta2.Conditions == nil { + if reflect.DeepEqual(in.V1Beta2, &IPAddressClaimV1Beta2Status{}) { in.V1Beta2 = nil } } diff --git a/internal/apis/addons/v1alpha3/conversion.go b/internal/apis/addons/v1alpha3/conversion.go index eddd71600f74..5396b31d1531 100644 --- a/internal/apis/addons/v1alpha3/conversion.go +++ b/internal/apis/addons/v1alpha3/conversion.go @@ -38,7 +38,7 @@ func (src *ClusterResourceSet) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &addonsv1.ClusterResourceSetDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &addonsv1.ClusterResourceSetV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - clusterv1alpha3.Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + clusterv1alpha3.Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } } @@ -67,7 +67,7 @@ func (dst *ClusterResourceSet) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - clusterv1alpha3.Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + clusterv1alpha3.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } } } diff --git a/internal/apis/addons/v1alpha3/conversion_test.go b/internal/apis/addons/v1alpha3/conversion_test.go index e6b870d579f1..45bf62877393 100644 --- a/internal/apis/addons/v1alpha3/conversion_test.go +++ b/internal/apis/addons/v1alpha3/conversion_test.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha3 import ( + "reflect" "testing" fuzz "github.com/google/gofuzz" @@ -50,10 +51,10 @@ func ClusterResourceSetFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} } func hubClusterResourceSetStatus(in *addonsv1.ClusterResourceSetStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &addonsv1.ClusterResourceSetV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } diff --git a/internal/apis/addons/v1alpha4/conversion.go b/internal/apis/addons/v1alpha4/conversion.go index 99835a66f85c..936170402699 100644 --- a/internal/apis/addons/v1alpha4/conversion.go +++ b/internal/apis/addons/v1alpha4/conversion.go @@ -39,7 +39,7 @@ func (src *ClusterResourceSet) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &addonsv1.ClusterResourceSetDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &addonsv1.ClusterResourceSetV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - clusterv1alpha4.Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + clusterv1alpha4.Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } } @@ -68,7 +68,7 @@ func (dst *ClusterResourceSet) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - clusterv1alpha4.Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + clusterv1alpha4.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } } } diff --git a/internal/apis/addons/v1alpha4/conversion_test.go b/internal/apis/addons/v1alpha4/conversion_test.go index f45fc0fbef5c..9f14e7a8e72b 100644 --- a/internal/apis/addons/v1alpha4/conversion_test.go +++ b/internal/apis/addons/v1alpha4/conversion_test.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha4 import ( + "reflect" "testing" fuzz "github.com/google/gofuzz" @@ -50,10 +51,10 @@ func ClusterResourceSetFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} } func hubClusterResourceSetStatus(in *addonsv1.ClusterResourceSetStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &addonsv1.ClusterResourceSetV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } diff --git a/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go b/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go index ff1b0d5739fb..c26a16ed74c9 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go @@ -38,7 +38,7 @@ func (src *KubeadmConfig) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &bootstrapv1.KubeadmConfigV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - clusterv1alpha3.Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + clusterv1alpha3.Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage @@ -138,7 +138,7 @@ func (dst *KubeadmConfig) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - clusterv1alpha3.Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + clusterv1alpha3.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage diff --git a/internal/apis/bootstrap/kubeadm/v1alpha3/conversion_test.go b/internal/apis/bootstrap/kubeadm/v1alpha3/conversion_test.go index d4a3abf40021..2e644d0d33fc 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha3/conversion_test.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha3/conversion_test.go @@ -67,7 +67,7 @@ func KubeadmConfigFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubKubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} diff --git a/internal/apis/bootstrap/kubeadm/v1alpha4/conversion.go b/internal/apis/bootstrap/kubeadm/v1alpha4/conversion.go index de6a57d18256..b4a804f92fa8 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha4/conversion.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha4/conversion.go @@ -37,7 +37,7 @@ func (src *KubeadmConfig) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &bootstrapv1.KubeadmConfigV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - clusterv1alpha4.Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + clusterv1alpha4.Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage @@ -135,7 +135,7 @@ func (dst *KubeadmConfig) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - clusterv1alpha4.Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + clusterv1alpha4.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage diff --git a/internal/apis/bootstrap/kubeadm/v1alpha4/conversion_test.go b/internal/apis/bootstrap/kubeadm/v1alpha4/conversion_test.go index bcf57837e9f9..fb836e14937b 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha4/conversion_test.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha4/conversion_test.go @@ -56,7 +56,7 @@ func KubeadmConfigFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubKubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} diff --git a/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go b/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go index c4fdd8b16f07..2d6792bc45d2 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go +++ b/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go @@ -39,7 +39,7 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - clusterv1alpha3.Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + clusterv1alpha3.Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage @@ -100,7 +100,7 @@ func (dst *KubeadmControlPlane) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - clusterv1alpha3.Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + clusterv1alpha3.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage diff --git a/internal/apis/controlplane/kubeadm/v1alpha3/conversion_test.go b/internal/apis/controlplane/kubeadm/v1alpha3/conversion_test.go index b63dbda2c52c..06bd3ad39db4 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha3/conversion_test.go +++ b/internal/apis/controlplane/kubeadm/v1alpha3/conversion_test.go @@ -62,7 +62,7 @@ func KubeadmControlPlaneFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{ } func hubKubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} diff --git a/internal/apis/controlplane/kubeadm/v1alpha4/conversion.go b/internal/apis/controlplane/kubeadm/v1alpha4/conversion.go index a6c6ed88ebbb..7cd270bb73d2 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha4/conversion.go +++ b/internal/apis/controlplane/kubeadm/v1alpha4/conversion.go @@ -40,7 +40,7 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - clusterv1alpha4.Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + clusterv1alpha4.Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage @@ -98,7 +98,7 @@ func (dst *KubeadmControlPlane) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - clusterv1alpha4.Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + clusterv1alpha4.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage diff --git a/internal/apis/controlplane/kubeadm/v1alpha4/conversion_test.go b/internal/apis/controlplane/kubeadm/v1alpha4/conversion_test.go index 2b51206b662d..2abe02b19a1e 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha4/conversion_test.go +++ b/internal/apis/controlplane/kubeadm/v1alpha4/conversion_test.go @@ -74,7 +74,7 @@ func KubeadmControlPlaneFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{ } func hubKubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} @@ -113,7 +113,7 @@ func spokeBootstrapTokenString(in *bootstrapv1alpha4.BootstrapTokenString, _ fuz } func spokeKubeadmControlPlaneTemplateResource(in *KubeadmControlPlaneTemplateResource, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Fields have been dropped in KCPTemplate. in.Spec.Replicas = nil diff --git a/internal/apis/core/exp/v1alpha3/conversion.go b/internal/apis/core/exp/v1alpha3/conversion.go index e1a172556eea..37e8a46de853 100644 --- a/internal/apis/core/exp/v1alpha3/conversion.go +++ b/internal/apis/core/exp/v1alpha3/conversion.go @@ -74,7 +74,7 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - clusterv1alpha3.Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + clusterv1alpha3.Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage @@ -118,7 +118,7 @@ func (dst *MachinePool) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - clusterv1alpha3.Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + clusterv1alpha3.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage diff --git a/internal/apis/core/exp/v1alpha3/conversion_test.go b/internal/apis/core/exp/v1alpha3/conversion_test.go index d4a9d374dd0d..95517ef82883 100644 --- a/internal/apis/core/exp/v1alpha3/conversion_test.go +++ b/internal/apis/core/exp/v1alpha3/conversion_test.go @@ -50,7 +50,7 @@ func MachinePoolFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubMachinePoolStatus(in *expv1.MachinePoolStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &expv1.MachinePoolDeprecatedStatus{} @@ -79,7 +79,7 @@ func spokeObjectMeta(in *clusterv1alpha3.ObjectMeta, c fuzz.Continue) { } func spokeMachinePoolSpec(in *MachinePoolSpec, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // These fields have been removed in v1beta1 // data is going to be lost, so we're forcing zero values here. diff --git a/internal/apis/core/exp/v1alpha4/conversion.go b/internal/apis/core/exp/v1alpha4/conversion.go index d97f8137c0d8..ac0867d112ab 100644 --- a/internal/apis/core/exp/v1alpha4/conversion.go +++ b/internal/apis/core/exp/v1alpha4/conversion.go @@ -38,7 +38,7 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - clusterv1alpha4.Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + clusterv1alpha4.Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage @@ -82,7 +82,7 @@ func (dst *MachinePool) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - clusterv1alpha4.Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + clusterv1alpha4.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage diff --git a/internal/apis/core/exp/v1alpha4/conversion_test.go b/internal/apis/core/exp/v1alpha4/conversion_test.go index 781fff5b92c8..edc7dc28990b 100644 --- a/internal/apis/core/exp/v1alpha4/conversion_test.go +++ b/internal/apis/core/exp/v1alpha4/conversion_test.go @@ -46,7 +46,7 @@ func MachinePoolFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubMachinePoolStatus(in *expv1.MachinePoolStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &expv1.MachinePoolDeprecatedStatus{} diff --git a/internal/apis/core/v1alpha3/conversion.go b/internal/apis/core/v1alpha3/conversion.go index fd8d6e37edc3..861236f6a259 100644 --- a/internal/apis/core/v1alpha3/conversion.go +++ b/internal/apis/core/v1alpha3/conversion.go @@ -40,7 +40,7 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &clusterv1.ClusterDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.ClusterV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage @@ -85,7 +85,7 @@ func (dst *Cluster) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage @@ -117,7 +117,7 @@ func (src *Machine) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage @@ -155,7 +155,7 @@ func (dst *Machine) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage @@ -327,7 +327,7 @@ func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &clusterv1.MachineHealthCheckDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } } @@ -360,7 +360,7 @@ func (dst *MachineHealthCheck) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } } } @@ -467,14 +467,14 @@ func Convert_v1alpha3_Condition_To_v1_Condition(_ *Condition, _ *metav1.Conditio return nil } -func Convert_v1beta2_Conditions_To_Deprecated_v1alpha3_Conditions(in *clusterv1.Conditions, out *Conditions) { +func Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha3_Conditions(in *clusterv1.Conditions, out *Conditions) { *out = make(Conditions, len(*in)) for i := range *in { (*out)[i] = *(*Condition)(unsafe.Pointer(&(*in)[i])) } } -func Convert_Deprecated_v1alpha3_Conditions_To_v1beta2_Conditions(in *Conditions, out *clusterv1.Conditions) { +func Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(in *Conditions, out *clusterv1.Conditions) { *out = make(clusterv1.Conditions, len(*in)) for i := range *in { (*out)[i] = *(*clusterv1.Condition)(unsafe.Pointer(&(*in)[i])) diff --git a/internal/apis/core/v1alpha3/conversion_test.go b/internal/apis/core/v1alpha3/conversion_test.go index 888c55e52ddf..e003462d87f4 100644 --- a/internal/apis/core/v1alpha3/conversion_test.go +++ b/internal/apis/core/v1alpha3/conversion_test.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha3 import ( + "reflect" "testing" fuzz "github.com/google/gofuzz" @@ -75,10 +76,10 @@ func MachineFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { } func hubMachineStatus(in *clusterv1.MachineStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &clusterv1.MachineV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } @@ -101,7 +102,7 @@ func MachineSetFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { } func hubMachineSetStatus(in *clusterv1.MachineSetStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} @@ -109,6 +110,9 @@ func hubMachineSetStatus(in *clusterv1.MachineSetStatus, c fuzz.Continue) { if in.Deprecated.V1Beta1 == nil { in.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} } + + // conditions do not exist in v1beta3. + in.Deprecated.V1Beta1.Conditions = nil } func MachineDeploymentFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { @@ -120,7 +124,7 @@ func MachineDeploymentFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { } func hubMachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &clusterv1.MachineDeploymentDeprecatedStatus{} @@ -128,6 +132,9 @@ func hubMachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, c fuzz.Co if in.Deprecated.V1Beta1 == nil { in.Deprecated.V1Beta1 = &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{} } + + // conditions do not exist in v1beta3. + in.Deprecated.V1Beta1.Conditions = nil } func spokeObjectMeta(in *ObjectMeta, c fuzz.Continue) { @@ -178,10 +185,10 @@ func ClusterFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubClusterStatus(in *clusterv1.ClusterStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &clusterv1.ClusterV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } @@ -201,10 +208,10 @@ func MachineHealthCheckFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} } func hubMachineHealthCheckStatus(in *clusterv1.MachineHealthCheckStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } diff --git a/internal/apis/core/v1alpha4/conversion.go b/internal/apis/core/v1alpha4/conversion.go index 2750c4028971..b2a5572ddd35 100644 --- a/internal/apis/core/v1alpha4/conversion.go +++ b/internal/apis/core/v1alpha4/conversion.go @@ -39,7 +39,7 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &clusterv1.ClusterDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.ClusterV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage @@ -118,7 +118,7 @@ func (dst *Cluster) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage @@ -201,7 +201,7 @@ func (src *Machine) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage @@ -238,7 +238,7 @@ func (dst *Machine) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage @@ -264,7 +264,7 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } dst.Status.Deprecated.V1Beta1.FailureReason = src.Status.FailureReason dst.Status.Deprecated.V1Beta1.FailureMessage = src.Status.FailureMessage @@ -313,7 +313,7 @@ func (dst *MachineSet) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } dst.Status.FailureReason = src.Status.Deprecated.V1Beta1.FailureReason dst.Status.FailureMessage = src.Status.Deprecated.V1Beta1.FailureMessage @@ -338,7 +338,7 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &clusterv1.MachineDeploymentDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } dst.Status.Deprecated.V1Beta1.ReadyReplicas = src.Status.ReadyReplicas dst.Status.Deprecated.V1Beta1.AvailableReplicas = src.Status.AvailableReplicas @@ -384,7 +384,7 @@ func (dst *MachineDeployment) ConvertFrom(srcRaw conversion.Hub) error { // Reset conditions from autogenerated conversions // NOTE: v1beta2 conditions should not be automatically be converted into legacy conditions (v1alpha4). dst.Status.Conditions = nil - + // Reset replica counters from autogenerated conversions // NOTE: replica counters with a new semantic should not be automatically be converted into old replica counters. dst.Status.AvailableReplicas = 0 @@ -394,7 +394,7 @@ func (dst *MachineDeployment) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } dst.Status.ReadyReplicas = src.Status.Deprecated.V1Beta1.ReadyReplicas dst.Status.AvailableReplicas = src.Status.Deprecated.V1Beta1.AvailableReplicas @@ -419,7 +419,7 @@ func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error { dst.Status.Deprecated = &clusterv1.MachineHealthCheckDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{} if src.Status.Conditions != nil { - Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) + Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } } @@ -448,7 +448,7 @@ func (dst *MachineHealthCheck) ConvertFrom(srcRaw conversion.Hub) error { if src.Status.Deprecated != nil { if src.Status.Deprecated.V1Beta1 != nil { if src.Status.Deprecated.V1Beta1.Conditions != nil { - Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) + Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha4_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions) } } } @@ -595,14 +595,14 @@ func Convert_v1alpha4_Condition_To_v1_Condition(_ *Condition, _ *metav1.Conditio return nil } -func Convert_v1beta2_Conditions_To_Deprecated_v1alpha4_Conditions(in *clusterv1.Conditions, out *Conditions) { +func Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha4_Conditions(in *clusterv1.Conditions, out *Conditions) { *out = make(Conditions, len(*in)) for i := range *in { (*out)[i] = *(*Condition)(unsafe.Pointer(&(*in)[i])) } } -func Convert_Deprecated_v1alpha4_Conditions_To_v1beta2_Conditions(in *Conditions, out *clusterv1.Conditions) { +func Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(in *Conditions, out *clusterv1.Conditions) { *out = make(clusterv1.Conditions, len(*in)) for i := range *in { (*out)[i] = *(*clusterv1.Condition)(unsafe.Pointer(&(*in)[i])) diff --git a/internal/apis/core/v1alpha4/conversion_test.go b/internal/apis/core/v1alpha4/conversion_test.go index 39854b8e112c..e583b11be70a 100644 --- a/internal/apis/core/v1alpha4/conversion_test.go +++ b/internal/apis/core/v1alpha4/conversion_test.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha4 import ( + "reflect" "strconv" "testing" @@ -75,10 +76,10 @@ func MachineFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { } func hubMachineStatus(in *clusterv1.MachineStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &clusterv1.MachineV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } @@ -100,10 +101,10 @@ func ClusterFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubClusterStatus(in *clusterv1.ClusterStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &clusterv1.ClusterV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } @@ -180,7 +181,7 @@ func MachineSetFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { } func hubMachineSetStatus(in *clusterv1.MachineSetStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} @@ -197,7 +198,7 @@ func MachineDeploymentFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} } func hubMachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Always create struct with at least one mandatory fields. if in.Deprecated == nil { in.Deprecated = &clusterv1.MachineDeploymentDeprecatedStatus{} @@ -214,10 +215,10 @@ func MachineHealthCheckFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} } func hubMachineHealthCheckStatus(in *clusterv1.MachineHealthCheckStatus, c fuzz.Continue) { - c.Fuzz(in) + c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.Deprecated != nil { - if in.Deprecated.V1Beta1 == nil || in.Deprecated.V1Beta1.Conditions == nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{}) { in.Deprecated = nil } } diff --git a/internal/controllers/machinedeployment/machinedeployment_rolling.go b/internal/controllers/machinedeployment/machinedeployment_rolling.go index 96147a829b04..2d3db1ceb7c0 100644 --- a/internal/controllers/machinedeployment/machinedeployment_rolling.go +++ b/internal/controllers/machinedeployment/machinedeployment_rolling.go @@ -157,7 +157,7 @@ func (r *Reconciler) reconcileOldMachineSets(ctx context.Context, allMSs []*clus // * The new MachineSet created must start with 0 replicas because allMachinesCount is already at 13. // * However, newMSMachinesUnavailable would also be 0, so the 2 old MachineSets could be scaled down by 5 (13 - 8 - 0), which would then // allow the new MachineSet to be scaled up by 5. - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters availableReplicas := int32(0) if newMS.Status.Deprecated != nil && newMS.Status.Deprecated.V1Beta1 != nil { availableReplicas = newMS.Status.Deprecated.V1Beta1.AvailableReplicas @@ -218,7 +218,7 @@ func (r *Reconciler) cleanupUnhealthyReplicas(ctx context.Context, oldMSs []*clu continue } - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters oldMSAvailableReplicas := int32(0) if targetMS.Status.Deprecated != nil && targetMS.Status.Deprecated.V1Beta1 != nil { oldMSAvailableReplicas = targetMS.Status.Deprecated.V1Beta1.AvailableReplicas diff --git a/internal/controllers/machinedeployment/machinedeployment_sync.go b/internal/controllers/machinedeployment/machinedeployment_sync.go index a00c68926f8a..539214c5f836 100644 --- a/internal/controllers/machinedeployment/machinedeployment_sync.go +++ b/internal/controllers/machinedeployment/machinedeployment_sync.go @@ -525,7 +525,7 @@ func calculateStatus(allMSs []*clusterv1.MachineSet, newMS *clusterv1.MachineSet // Calculate the label selector. We check the error in the MD reconcile function, ignore here. selector, _ := metav1.LabelSelectorAsSelector(&deployment.Spec.Selector) - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters var conditions clusterv1.Conditions if deployment.Status.Deprecated != nil && deployment.Status.Deprecated.V1Beta1 != nil { conditions = deployment.Status.Deprecated.V1Beta1.Conditions diff --git a/internal/controllers/machinedeployment/mdutil/util.go b/internal/controllers/machinedeployment/mdutil/util.go index 83af18152708..51f24a80232c 100644 --- a/internal/controllers/machinedeployment/mdutil/util.go +++ b/internal/controllers/machinedeployment/mdutil/util.go @@ -570,7 +570,7 @@ func GetReadyReplicaCountForMachineSets(machineSets []*clusterv1.MachineSet) int totalReadyReplicas := int32(0) for _, ms := range machineSets { if ms != nil { - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters readyReplicas := int32(0) if ms.Status.Deprecated != nil && ms.Status.Deprecated.V1Beta1 != nil { readyReplicas = ms.Status.Deprecated.V1Beta1.ReadyReplicas @@ -640,7 +640,7 @@ func IsRollingUpdate(deployment *clusterv1.MachineDeployment) bool { // DeploymentComplete considers a deployment to be complete once all of its desired replicas // are updated and available, and no old machines are running. func DeploymentComplete(deployment *clusterv1.MachineDeployment, newStatus *clusterv1.MachineDeploymentStatus) bool { - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters updatedReplicas := int32(0) if newStatus.Deprecated != nil && newStatus.Deprecated.V1Beta1 != nil { updatedReplicas = newStatus.Deprecated.V1Beta1.UpdatedReplicas @@ -709,7 +709,7 @@ func IsSaturated(deployment *clusterv1.MachineDeployment, ms *clusterv1.MachineS if err != nil { return false } - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters availableReplicas := int32(0) if ms.Status.Deprecated != nil && ms.Status.Deprecated.V1Beta1 != nil { availableReplicas = ms.Status.Deprecated.V1Beta1.AvailableReplicas diff --git a/internal/controllers/machineset/machineset_controller.go b/internal/controllers/machineset/machineset_controller.go index 0bc4b59499c6..5efadbd9bfc2 100644 --- a/internal/controllers/machineset/machineset_controller.go +++ b/internal/controllers/machineset/machineset_controller.go @@ -1212,7 +1212,7 @@ func (r *Reconciler) reconcileStatus(ctx context.Context, s *scope) error { } newStatus.Replicas = int32(len(filteredMachines)) - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters newStatus.Deprecated = &clusterv1.MachineSetDeprecatedStatus{ V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{}, } @@ -1260,7 +1260,7 @@ func (r *Reconciler) reconcileStatus(ctx context.Context, s *scope) error { // Make sure last resize operation is marked as completed. // NOTE: we are checking the number of machines ready so we report resize completed only when the machines // are actually provisioned (vs reporting completed immediately after the last machine object is created). This convention is also used by KCP. - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters if newStatus.Deprecated.V1Beta1.ReadyReplicas == newStatus.Replicas { if conditions.IsFalse(ms, clusterv1.ResizedCondition) { log.Info("All the replicas are ready", "replicas", newStatus.Deprecated.V1Beta1.ReadyReplicas) @@ -1288,7 +1288,7 @@ func shouldRequeueForReplicaCountersRefresh(s *scope) ctrl.Result { // exceeds MinReadySeconds could be incorrect. // To avoid an available replica stuck in the ready state, we force a reconcile after MinReadySeconds, // at which point it should confirm any available replica to be available. - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters if s.machineSet.Spec.MinReadySeconds > 0 && s.machineSet.Status.Deprecated.V1Beta1.ReadyReplicas == replicas && s.machineSet.Status.Deprecated.V1Beta1.AvailableReplicas != replicas { diff --git a/test/framework/control_plane.go b/test/framework/control_plane.go index 05411eeb76bb..c3635bfab60f 100644 --- a/test/framework/control_plane.go +++ b/test/framework/control_plane.go @@ -44,7 +44,7 @@ func WaitForControlPlaneToBeUpToDate(ctx context.Context, input WaitForControlPl if err := input.Getter.Get(ctx, key, controlplane); err != nil { return 0, err } - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters updatedReplicas := int32(0) if controlplane.Status.Deprecated != nil && controlplane.Status.Deprecated.V1Beta1 != nil { updatedReplicas = controlplane.Status.Deprecated.V1Beta1.UpdatedReplicas diff --git a/test/framework/controlplane_helpers.go b/test/framework/controlplane_helpers.go index 21fdb5d24fac..42fa046c7460 100644 --- a/test/framework/controlplane_helpers.go +++ b/test/framework/controlplane_helpers.go @@ -174,7 +174,7 @@ func WaitForControlPlaneToBeReady(ctx context.Context, input WaitForControlPlane desiredReplicas := controlplane.Spec.Replicas statusReplicas := controlplane.Status.Replicas - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters updatedReplicas := int32(0) readyReplicas := int32(0) unavailableReplicas := int32(0) diff --git a/test/framework/machinepool_helpers.go b/test/framework/machinepool_helpers.go index d7bb0874355d..35637b91bb83 100644 --- a/test/framework/machinepool_helpers.go +++ b/test/framework/machinepool_helpers.go @@ -87,7 +87,7 @@ func WaitForMachinePoolNodesToExist(ctx context.Context, input WaitForMachinePoo return 0, err } - // TODO (v1beta2) + // TODO (v1beta2) Use new replica counters readyReplicas := 0 if input.MachinePool.Status.Deprecated != nil && input.MachinePool.Status.Deprecated.V1Beta1 != nil { readyReplicas = int(input.MachinePool.Status.Deprecated.V1Beta1.ReadyReplicas) diff --git a/util/collections/machine_filters_test.go b/util/collections/machine_filters_test.go index b7bcece778c9..697354e090ae 100644 --- a/util/collections/machine_filters_test.go +++ b/util/collections/machine_filters_test.go @@ -456,7 +456,7 @@ func TestHasUnhealthyControlPlaneComponentCondition(t *testing.T) { machine.Status.NodeRef = &corev1.ObjectReference{ Name: "node1", } - // TODO (v1beta2) + // TODO (v1beta2) Use new conditions machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{ V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ Conditions: clusterv1.Conditions{ @@ -475,7 +475,7 @@ func TestHasUnhealthyControlPlaneComponentCondition(t *testing.T) { machine.Status.NodeRef = &corev1.ObjectReference{ Name: "node1", } - // TODO (v1beta2) + // TODO (v1beta2) Use new conditions machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{ V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ Conditions: clusterv1.Conditions{ @@ -495,7 +495,7 @@ func TestHasUnhealthyControlPlaneComponentCondition(t *testing.T) { machine.Status.NodeRef = &corev1.ObjectReference{ Name: "node1", } - // TODO (v1beta2) + // TODO (v1beta2) Use new conditions machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{ V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ Conditions: clusterv1.Conditions{ @@ -518,7 +518,7 @@ func TestHasUnhealthyControlPlaneComponentCondition(t *testing.T) { machine.Status.NodeRef = &corev1.ObjectReference{ Name: "node1", } - // TODO (v1beta2) + // TODO (v1beta2) Use new conditions machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{ V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ Conditions: clusterv1.Conditions{ @@ -541,7 +541,7 @@ func TestHasUnhealthyControlPlaneComponentCondition(t *testing.T) { machine.Status.NodeRef = &corev1.ObjectReference{ Name: "node1", } - // TODO (v1beta2) + // TODO (v1beta2) Use new conditions machine.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{ V1Beta1: &clusterv1.MachineV1Beta1DeprecatedStatus{ Conditions: clusterv1.Conditions{ diff --git a/util/conditions/patch_test.go b/util/conditions/patch_test.go index fc1e0d44a673..c288d7136b3d 100644 --- a/util/conditions/patch_test.go +++ b/util/conditions/patch_test.go @@ -318,7 +318,7 @@ func TestApplyDoesNotAlterLastTransitionTime(t *testing.T) { before := &clusterv1.Cluster{} after := &clusterv1.Cluster{ Status: clusterv1.ClusterStatus{ - // TODO (v1beta2) + // TODO (v1beta2) Use new conditions Deprecated: &clusterv1.ClusterDeprecatedStatus{ V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{ Conditions: clusterv1.Conditions{ diff --git a/util/test/builder/builders.go b/util/test/builder/builders.go index a2a3202edada..282ff27e1198 100644 --- a/util/test/builder/builders.go +++ b/util/test/builder/builders.go @@ -494,7 +494,7 @@ func (c *ClusterClassBuilder) Build() *clusterv1.ClusterClass { Variables: c.statusVariables, }, } - // TODO (v1beta2) + // TODO (v1beta2) Use new conditions if c.conditions != nil { obj.Status.Deprecated = &clusterv1.ClusterClassDeprecatedStatus{ V1Beta1: &clusterv1.ClusterClassV1Beta1DeprecatedStatus{Conditions: c.conditions}, From f8181ad54c8dad3eedae9ca7cd2d2031a6995639 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Tue, 8 Apr 2025 15:08:02 +0200 Subject: [PATCH 06/11] Handle contract version for control plane replica counters --- cmd/clusterctl/client/tree/annotations.go | 13 ++ cmd/clusterctl/client/tree/discovery.go | 7 ++ cmd/clusterctl/client/tree/discovery_test.go | 3 + cmd/clusterctl/internal/test/fake_objects.go | 7 +- internal/contract/controlplane.go | 93 +++++++++----- internal/contract/controlplane_test.go | 116 +++++++++++++----- internal/contract/types.go | 35 ++---- .../controllers/cluster/cluster_controller.go | 6 +- .../cluster/cluster_controller_status.go | 20 ++- .../cluster/cluster_controller_status_test.go | 8 +- internal/util/tree/tree.go | 10 +- test/e2e/clusterclass_changes.go | 11 +- 12 files changed, 226 insertions(+), 103 deletions(-) diff --git a/cmd/clusterctl/client/tree/annotations.go b/cmd/clusterctl/client/tree/annotations.go index a4c76be7d0d7..b8c2fa88bc1c 100644 --- a/cmd/clusterctl/client/tree/annotations.go +++ b/cmd/clusterctl/client/tree/annotations.go @@ -60,6 +60,10 @@ const ( // Note: Currently this annotation is applied only to control plane objects. ObjectContractAnnotation = "tree.cluster.x-k8s.io.io/object-contract" + // ObjectContractVersionAnnotation is added to unstructured objects to track which Cluster API contract version those objects abide to. + // Note: Currently this annotation is applied only to control plane objects. + ObjectContractVersionAnnotation = "tree.cluster.x-k8s.io.io/object-contract-version" + // GroupItemsSeparator is the separator used in the GroupItemsAnnotation. GroupItemsSeparator = ", " @@ -149,6 +153,15 @@ func GetObjectContract(obj client.Object) string { return "" } +// GetObjectContractVersion returns which Cluster API contract version an unstructured object abides to. +// Note: Currently this annotation is applied only to control plane objects. +func GetObjectContractVersion(obj client.Object) string { + if val, ok := getAnnotation(obj, ObjectContractVersionAnnotation); ok { + return val + } + return "" +} + // GetZOrder return the zOrder of the object. Objects with no zOrder have a default zOrder of 0. func GetZOrder(obj client.Object) int { if val, ok := getAnnotation(obj, ObjectZOrderAnnotation); ok { diff --git a/cmd/clusterctl/client/tree/discovery.go b/cmd/clusterctl/client/tree/discovery.go index 299736c984d3..f3cf5875c7bd 100644 --- a/cmd/clusterctl/client/tree/discovery.go +++ b/cmd/clusterctl/client/tree/discovery.go @@ -30,6 +30,7 @@ import ( "sigs.k8s.io/cluster-api/controllers/external" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta2" "sigs.k8s.io/cluster-api/util" + utilconversion "sigs.k8s.io/cluster-api/util/conversion" ) // DiscoverOptions define options for the discovery process. @@ -103,7 +104,13 @@ func Discovery(ctx context.Context, c client.Client, namespace, name string, opt // Keep track that this objects abides to the Cluster API control plane contract, // so the consumers of the ObjectTree will know which info are available on this unstructured object // and how to extract them. + contractVersion, err := utilconversion.GetContractVersion(ctx, c, controlPlane.GroupVersionKind()) + if err != nil { + return nil, err + } + addAnnotation(controlPlane, ObjectContractAnnotation, "ControlPlane") + addAnnotation(controlPlane, ObjectContractVersionAnnotation, contractVersion) addControlPlane(cluster, controlPlane, tree, options) } diff --git a/cmd/clusterctl/client/tree/discovery_test.go b/cmd/clusterctl/client/tree/discovery_test.go index c03ccfa28c65..5a34bb9d1e72 100644 --- a/cmd/clusterctl/client/tree/discovery_test.go +++ b/cmd/clusterctl/client/tree/discovery_test.go @@ -842,6 +842,9 @@ func Test_Discovery(t *testing.T) { t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) + for _, crd := range test.FakeCRDList() { + tt.args.objs = append(tt.args.objs, crd) + } client, err := test.NewFakeProxy().WithObjs(tt.args.objs...).NewClient(context.Background()) g.Expect(client).ToNot(BeNil()) g.Expect(err).ToNot(HaveOccurred()) diff --git a/cmd/clusterctl/internal/test/fake_objects.go b/cmd/clusterctl/internal/test/fake_objects.go index 3da61a8e30a5..9a411a3be2ae 100644 --- a/cmd/clusterctl/internal/test/fake_objects.go +++ b/cmd/clusterctl/internal/test/fake_objects.go @@ -39,7 +39,9 @@ import ( fakeexternal "sigs.k8s.io/cluster-api/cmd/clusterctl/internal/test/providers/external" fakeinfrastructure "sigs.k8s.io/cluster-api/cmd/clusterctl/internal/test/providers/infrastructure" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta2" + "sigs.k8s.io/cluster-api/internal/contract" "sigs.k8s.io/cluster-api/util" + contractutil "sigs.k8s.io/cluster-api/util/contract" "sigs.k8s.io/cluster-api/util/test/builder" ) @@ -1415,9 +1417,10 @@ func fakeCRD(group string, kind string, versions []string) *apiextensionsv1.Cust APIVersion: "CustomResourceDefinition", }, ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s.%s", strings.ToLower(kind), group), // NB. this technically should use plural(kind), but for the sake of test what really matters is to generate a unique name + Name: contractutil.CalculateCRDName(group, kind), Labels: map[string]string{ - clusterctlv1.ClusterctlLabel: "", + clusterctlv1.ClusterctlLabel: "", + fmt.Sprintf("%s/%s", clusterv1.GroupVersion.Group, contract.Version): strings.Join(versions, "_"), }, }, Spec: apiextensionsv1.CustomResourceDefinitionSpec{ // NB. the spec contains only what is strictly required by the move test diff --git a/internal/contract/controlplane.go b/internal/contract/controlplane.go index 5ac1f4f882c4..4ea0a10e69e7 100644 --- a/internal/contract/controlplane.go +++ b/internal/contract/controlplane.go @@ -101,53 +101,86 @@ func (c *ControlPlaneContract) StatusReplicas() *Int64 { } // UpdatedReplicas provide access to the status.updatedReplicas field in a ControlPlane object, if any. Applies to implementations using replicas. -func (c *ControlPlaneContract) UpdatedReplicas() *Int64 { +// TODO (v1beta2): Rename to V1Beta1DeprecatedUpdatedReplicas and make sure we are only using this method for compatibility with old contracts. +func (c *ControlPlaneContract) UpdatedReplicas(contractVersion string) *Int64 { + if contractVersion == "v1beta1" { + return &Int64{ + path: []string{"status", "updatedReplicas"}, + } + } + return &Int64{ - path: []string{"status", "updatedReplicas"}, + path: []string{"status", "deprecated", "v1beta1", "updatedReplicas"}, } } // ReadyReplicas provide access to the status.readyReplicas field in a ControlPlane object, if any. Applies to implementations using replicas. -func (c *ControlPlaneContract) ReadyReplicas() *Int64 { +// TODO (v1beta2): Rename to V1Beta1DeprecatedReadyReplicas and make sure we are only using this method for compatibility with old contracts. +func (c *ControlPlaneContract) ReadyReplicas(contractVersion string) *Int64 { + if contractVersion == "v1beta1" { + return &Int64{ + path: []string{"status", "readyReplicas"}, + } + } + return &Int64{ - path: []string{"status", "readyReplicas"}, + path: []string{"status", "deprecated", "v1beta1", "readyReplicas"}, } } // UnavailableReplicas provide access to the status.unavailableReplicas field in a ControlPlane object, if any. Applies to implementations using replicas. -func (c *ControlPlaneContract) UnavailableReplicas() *Int64 { +// TODO (v1beta2): Rename to V1Beta1DeprecatedUnavailableReplicas and make sure we are only using this method for compatibility with old contracts. +func (c *ControlPlaneContract) UnavailableReplicas(contractVersion string) *Int64 { + if contractVersion == "v1beta1" { + return &Int64{ + path: []string{"status", "unavailableReplicas"}, + } + } + return &Int64{ - path: []string{"status", "unavailableReplicas"}, + path: []string{"status", "deprecated", "v1beta1", "unavailableReplicas"}, } } -// V1Beta2ReadyReplicas provide access to readyReplicas field in a ControlPlane object, if any. Applies to implementations using replicas. -func (c *ControlPlaneContract) V1Beta2ReadyReplicas() *Int32 { +// V1Beta2ReadyReplicas provide access to the status.readyReplicas field in a ControlPlane object, if any. Applies to implementations using replicas. +// TODO (v1beta2): Drop V1Beta2 prefix.. +func (c *ControlPlaneContract) V1Beta2ReadyReplicas(contractVersion string) *Int32 { + if contractVersion == "v1beta1" { + return &Int32{ + path: []string{"status", "v1beta2", "readyReplicas"}, + } + } + return &Int32{ - paths: []Path{ - []string{"status", "v1beta2", "readyReplicas"}, - []string{"status", "readyReplicas"}, - }, + path: []string{"status", "readyReplicas"}, } } -// V1Beta2AvailableReplicas provide access to the availableReplicas field in a ControlPlane object, if any. Applies to implementations using replicas. -func (c *ControlPlaneContract) V1Beta2AvailableReplicas() *Int32 { +// V1Beta2AvailableReplicas provide access to the status.availableReplicas field in a ControlPlane object, if any. Applies to implementations using replicas. +// TODO (v1beta2): Drop V1Beta2 prefix.x. +func (c *ControlPlaneContract) V1Beta2AvailableReplicas(contractVersion string) *Int32 { + if contractVersion == "v1beta1" { + return &Int32{ + path: []string{"status", "v1beta2", "availableReplicas"}, + } + } + return &Int32{ - paths: []Path{ - []string{"status", "v1beta2", "availableReplicas"}, - []string{"status", "availableReplicas"}, - }, + path: []string{"status", "availableReplicas"}, } } -// V1Beta2UpToDateReplicas provide access to the upToDateReplicas field in a ControlPlane object, if any. Applies to implementations using replicas. -func (c *ControlPlaneContract) V1Beta2UpToDateReplicas() *Int32 { +// V1Beta2UpToDateReplicas provide access to the status.upToDateReplicas field in a ControlPlane object, if any. Applies to implementations using replicas. +// TODO (v1beta2): Drop V1Beta2 prefix.ix. +func (c *ControlPlaneContract) V1Beta2UpToDateReplicas(contractVersion string) *Int32 { + if contractVersion == "v1beta1" { + return &Int32{ + path: []string{"status", "v1beta2", "upToDateReplicas"}, + } + } + return &Int32{ - paths: []Path{ - []string{"status", "v1beta2", "upToDateReplicas"}, - []string{"status", "upToDateReplicas"}, - }, + path: []string{"status", "upToDateReplicas"}, } } @@ -249,12 +282,16 @@ func (c *ControlPlaneContract) IsUpgrading(obj *unstructured.Unstructured) (bool // - spec.replicas != status.updatedReplicas. // - spec.replicas != status.readyReplicas. // - status.unavailableReplicas > 0. -func (c *ControlPlaneContract) IsScaling(obj *unstructured.Unstructured) (bool, error) { +func (c *ControlPlaneContract) IsScaling(obj *unstructured.Unstructured, contractVersion string) (bool, error) { desiredReplicas, err := c.Replicas().Get(obj) if err != nil { return false, errors.Wrap(err, "failed to get control plane spec replicas") } + // TODO (v1beta2): Add a new code path using v1beta2 replica counters + // note: currently we are still always using v1beta1 counters no matter if they are moved under deprecated + // but we should stop doing this ASAP + statusReplicas, err := c.StatusReplicas().Get(obj) if err != nil { if errors.Is(err, ErrFieldNotFound) { @@ -266,7 +303,7 @@ func (c *ControlPlaneContract) IsScaling(obj *unstructured.Unstructured) (bool, return false, errors.Wrap(err, "failed to get control plane status replicas") } - updatedReplicas, err := c.UpdatedReplicas().Get(obj) + updatedReplicas, err := c.UpdatedReplicas(contractVersion).Get(obj) if err != nil { if errors.Is(err, ErrFieldNotFound) { // If updatedReplicas is not set on the control plane @@ -277,7 +314,7 @@ func (c *ControlPlaneContract) IsScaling(obj *unstructured.Unstructured) (bool, return false, errors.Wrap(err, "failed to get control plane status updatedReplicas") } - readyReplicas, err := c.ReadyReplicas().Get(obj) + readyReplicas, err := c.ReadyReplicas(contractVersion).Get(obj) if err != nil { if errors.Is(err, ErrFieldNotFound) { // If readyReplicas is not set on the control plane @@ -288,7 +325,7 @@ func (c *ControlPlaneContract) IsScaling(obj *unstructured.Unstructured) (bool, return false, errors.Wrap(err, "failed to get control plane status readyReplicas") } - unavailableReplicas, err := c.UnavailableReplicas().Get(obj) + unavailableReplicas, err := c.UnavailableReplicas(contractVersion).Get(obj) if err != nil { if !errors.Is(err, ErrFieldNotFound) { return false, errors.Wrap(err, "failed to get control plane status unavailableReplicas") diff --git a/internal/contract/controlplane_test.go b/internal/contract/controlplane_test.go index 4622283972fc..e669ffecab48 100644 --- a/internal/contract/controlplane_test.go +++ b/internal/contract/controlplane_test.go @@ -111,46 +111,97 @@ func TestControlPlane(t *testing.T) { t.Run("Manages status.updatedreplicas", func(t *testing.T) { g := NewWithT(t) - g.Expect(ControlPlane().UpdatedReplicas().Path()).To(Equal(Path{"status", "updatedReplicas"})) + g.Expect(ControlPlane().UpdatedReplicas("v1beta1").Path()).To(Equal(Path{"status", "updatedReplicas"})) - err := ControlPlane().UpdatedReplicas().Set(obj, int64(3)) + err := ControlPlane().UpdatedReplicas("v1beta1").Set(obj, int64(3)) g.Expect(err).ToNot(HaveOccurred()) - got, err := ControlPlane().UpdatedReplicas().Get(obj) + got, err := ControlPlane().UpdatedReplicas("v1beta1").Get(obj) g.Expect(err).ToNot(HaveOccurred()) g.Expect(got).ToNot(BeNil()) g.Expect(*got).To(Equal(int64(3))) + + g.Expect(ControlPlane().UpdatedReplicas("v1beta2").Path()).To(Equal(Path{"status", "deprecated", "v1beta1", "updatedReplicas"})) + + obj := &unstructured.Unstructured{Object: map[string]interface{}{ + "status": map[string]interface{}{ + "deprecated": map[string]interface{}{ + "v1beta1": map[string]interface{}{ + "updatedReplicas": int64(5), + }, + }, + }, + }} + + got, err = ControlPlane().UpdatedReplicas("v1beta2").Get(obj) + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(got).ToNot(BeNil()) + g.Expect(*got).To(Equal(int64(5))) }) t.Run("Manages status.readyReplicas", func(t *testing.T) { g := NewWithT(t) - g.Expect(ControlPlane().ReadyReplicas().Path()).To(Equal(Path{"status", "readyReplicas"})) + g.Expect(ControlPlane().ReadyReplicas("v1beta1").Path()).To(Equal(Path{"status", "readyReplicas"})) - err := ControlPlane().ReadyReplicas().Set(obj, int64(3)) + err := ControlPlane().ReadyReplicas("v1beta1").Set(obj, int64(3)) g.Expect(err).ToNot(HaveOccurred()) - got, err := ControlPlane().ReadyReplicas().Get(obj) + got, err := ControlPlane().ReadyReplicas("v1beta1").Get(obj) g.Expect(err).ToNot(HaveOccurred()) g.Expect(got).ToNot(BeNil()) g.Expect(*got).To(Equal(int64(3))) + + g.Expect(ControlPlane().ReadyReplicas("v1beta2").Path()).To(Equal(Path{"status", "deprecated", "v1beta1", "readyReplicas"})) + + obj := &unstructured.Unstructured{Object: map[string]interface{}{ + "status": map[string]interface{}{ + "deprecated": map[string]interface{}{ + "v1beta1": map[string]interface{}{ + "readyReplicas": int64(5), + }, + }, + }, + }} + + got, err = ControlPlane().ReadyReplicas("v1beta2").Get(obj) + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(got).ToNot(BeNil()) + g.Expect(*got).To(Equal(int64(5))) }) t.Run("Manages status.unavailableReplicas", func(t *testing.T) { g := NewWithT(t) - g.Expect(ControlPlane().UnavailableReplicas().Path()).To(Equal(Path{"status", "unavailableReplicas"})) + g.Expect(ControlPlane().UnavailableReplicas("v1beta1").Path()).To(Equal(Path{"status", "unavailableReplicas"})) - err := ControlPlane().UnavailableReplicas().Set(obj, int64(3)) + err := ControlPlane().UnavailableReplicas("v1beta1").Set(obj, int64(3)) g.Expect(err).ToNot(HaveOccurred()) - got, err := ControlPlane().UnavailableReplicas().Get(obj) + got, err := ControlPlane().UnavailableReplicas("v1beta1").Get(obj) g.Expect(err).ToNot(HaveOccurred()) g.Expect(got).ToNot(BeNil()) g.Expect(*got).To(Equal(int64(3))) + + g.Expect(ControlPlane().UnavailableReplicas("v1beta2").Path()).To(Equal(Path{"status", "deprecated", "v1beta1", "unavailableReplicas"})) + + obj := &unstructured.Unstructured{Object: map[string]interface{}{ + "status": map[string]interface{}{ + "deprecated": map[string]interface{}{ + "v1beta1": map[string]interface{}{ + "unavailableReplicas": int64(5), + }, + }, + }, + }} + + got, err = ControlPlane().UnavailableReplicas("v1beta2").Get(obj) + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(got).ToNot(BeNil()) + g.Expect(*got).To(Equal(int64(5))) }) t.Run("Manages status.readyReplicas for v1beta2 status", func(t *testing.T) { g := NewWithT(t) - g.Expect(ControlPlane().V1Beta2ReadyReplicas().Path()).To(Equal([]Path{{"status", "v1beta2", "readyReplicas"}, {"status", "readyReplicas"}})) + g.Expect(ControlPlane().V1Beta2ReadyReplicas("v1beta1").Path()).To(Equal(Path{"status", "v1beta2", "readyReplicas"})) obj := &unstructured.Unstructured{Object: map[string]interface{}{ "status": map[string]interface{}{ @@ -161,18 +212,17 @@ func TestControlPlane(t *testing.T) { }, }} - got, err := ControlPlane().V1Beta2ReadyReplicas().Get(obj) + got, err := ControlPlane().V1Beta2ReadyReplicas("v1beta1").Get(obj) g.Expect(err).ToNot(HaveOccurred()) g.Expect(got).ToNot(BeNil()) g.Expect(*got).To(Equal(int32(5))) - obj = &unstructured.Unstructured{Object: map[string]interface{}{ - "status": map[string]interface{}{ - "readyReplicas": int64(3), - }, - }} + g.Expect(ControlPlane().V1Beta2ReadyReplicas("v1beta2").Path()).To(Equal(Path{"status", "readyReplicas"})) + + err = ControlPlane().V1Beta2ReadyReplicas("v1beta2").Set(obj, 3) + g.Expect(err).ToNot(HaveOccurred()) - got, err = ControlPlane().V1Beta2ReadyReplicas().Get(obj) + got, err = ControlPlane().V1Beta2ReadyReplicas("v1beta2").Get(obj) g.Expect(err).ToNot(HaveOccurred()) g.Expect(got).ToNot(BeNil()) g.Expect(*got).To(Equal(int32(3))) @@ -180,7 +230,7 @@ func TestControlPlane(t *testing.T) { t.Run("Manages status.availableReplicas for v1beta2 status", func(t *testing.T) { g := NewWithT(t) - g.Expect(ControlPlane().V1Beta2AvailableReplicas().Path()).To(Equal([]Path{{"status", "v1beta2", "availableReplicas"}, {"status", "availableReplicas"}})) + g.Expect(ControlPlane().V1Beta2AvailableReplicas("v1beta1").Path()).To(Equal(Path{"status", "v1beta2", "availableReplicas"})) obj := &unstructured.Unstructured{Object: map[string]interface{}{ "status": map[string]interface{}{ @@ -191,18 +241,17 @@ func TestControlPlane(t *testing.T) { }, }} - got, err := ControlPlane().V1Beta2AvailableReplicas().Get(obj) + got, err := ControlPlane().V1Beta2AvailableReplicas("v1beta1").Get(obj) g.Expect(err).ToNot(HaveOccurred()) g.Expect(got).ToNot(BeNil()) g.Expect(*got).To(Equal(int32(5))) - obj = &unstructured.Unstructured{Object: map[string]interface{}{ - "status": map[string]interface{}{ - "availableReplicas": int64(3), - }, - }} + g.Expect(ControlPlane().V1Beta2AvailableReplicas("v1beta2").Path()).To(Equal(Path{"status", "availableReplicas"})) + + err = ControlPlane().V1Beta2AvailableReplicas("v1beta2").Set(obj, 3) + g.Expect(err).ToNot(HaveOccurred()) - got, err = ControlPlane().V1Beta2AvailableReplicas().Get(obj) + got, err = ControlPlane().V1Beta2AvailableReplicas("v1beta2").Get(obj) g.Expect(err).ToNot(HaveOccurred()) g.Expect(got).ToNot(BeNil()) g.Expect(*got).To(Equal(int32(3))) @@ -210,7 +259,7 @@ func TestControlPlane(t *testing.T) { t.Run("Manages status.upToDateReplicas for v1beta2 status", func(t *testing.T) { g := NewWithT(t) - g.Expect(ControlPlane().V1Beta2UpToDateReplicas().Path()).To(Equal([]Path{{"status", "v1beta2", "upToDateReplicas"}, {"status", "upToDateReplicas"}})) + g.Expect(ControlPlane().V1Beta2UpToDateReplicas("v1beta1").Path()).To(Equal(Path{"status", "v1beta2", "upToDateReplicas"})) obj := &unstructured.Unstructured{Object: map[string]interface{}{ "status": map[string]interface{}{ @@ -221,18 +270,17 @@ func TestControlPlane(t *testing.T) { }, }} - got, err := ControlPlane().V1Beta2UpToDateReplicas().Get(obj) + got, err := ControlPlane().V1Beta2UpToDateReplicas("v1beta1").Get(obj) g.Expect(err).ToNot(HaveOccurred()) g.Expect(got).ToNot(BeNil()) g.Expect(*got).To(Equal(int32(5))) - obj = &unstructured.Unstructured{Object: map[string]interface{}{ - "status": map[string]interface{}{ - "upToDateReplicas": int64(3), - }, - }} + g.Expect(ControlPlane().V1Beta2UpToDateReplicas("v1beta2").Path()).To(Equal(Path{"status", "upToDateReplicas"})) + + err = ControlPlane().V1Beta2UpToDateReplicas("v1beta2").Set(obj, 3) + g.Expect(err).ToNot(HaveOccurred()) - got, err = ControlPlane().V1Beta2UpToDateReplicas().Get(obj) + got, err = ControlPlane().V1Beta2UpToDateReplicas("v1beta2").Get(obj) g.Expect(err).ToNot(HaveOccurred()) g.Expect(got).ToNot(BeNil()) g.Expect(*got).To(Equal(int32(3))) @@ -625,7 +673,7 @@ func TestControlPlaneIsScaling(t *testing.T) { t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) - actual, err := ControlPlane().IsScaling(tt.obj) + actual, err := ControlPlane().IsScaling(tt.obj, "v1beta1") g.Expect(err).ToNot(HaveOccurred()) g.Expect(actual).To(Equal(tt.wantScaling)) }) diff --git a/internal/contract/types.go b/internal/contract/types.go index fa0b9d000ddf..eeaf809ac055 100644 --- a/internal/contract/types.go +++ b/internal/contract/types.go @@ -104,41 +104,32 @@ func (i *Int64) Set(obj *unstructured.Unstructured, value int64) error { // Int32 represents an accessor to an int32 path value. type Int32 struct { - paths []Path + path Path } // Path returns the path to the int32 value. -func (i *Int32) Path() []Path { - return i.paths +func (i *Int32) Path() Path { + return i.path } // Get gets the int32 value. -// If more than one path is defined, path are checked in order and the first value reported is used -// (e.g. in case when we are reading from a preferred location first, and then from one or more fallback locations). func (i *Int32) Get(obj *unstructured.Unstructured) (*int32, error) { - paths := []string{} - for _, path := range i.paths { - value, ok, err := unstructured.NestedInt64(obj.UnstructuredContent(), path...) - if err != nil { - return nil, errors.Wrapf(err, "failed to get %s from object", "."+strings.Join(path, ".")) - } - if !ok { - paths = append(paths, "."+strings.Join(path, ".")) - continue - } - int32Value := int32(value) - return &int32Value, nil + value, ok, err := unstructured.NestedInt64(obj.UnstructuredContent(), i.path...) + if err != nil { + return nil, errors.Wrapf(err, "failed to get %s from object", "."+strings.Join(i.path, ".")) + } + if !ok { + return nil, errors.Wrapf(ErrFieldNotFound, "path %s", "."+strings.Join(i.path, ".")) } - return nil, errors.Wrapf(ErrFieldNotFound, "path %s", strings.Join(paths, ", ")) + int32Value := int32(value) + return &int32Value, nil } // Set sets the int32 value in the path. -// If more than one path is defined, only the first path will be set. -// (the first path is considered the preferred location). // Note: Cluster API should never Set values on external objects owner by providers; however this method is useful for writing tests. func (i *Int32) Set(obj *unstructured.Unstructured, value int64) error { - if err := unstructured.SetNestedField(obj.UnstructuredContent(), value, i.paths[0]...); err != nil { - return errors.Wrapf(err, "failed to set path %s of object %v", "."+strings.Join(i.paths[0], "."), obj.GroupVersionKind()) + if err := unstructured.SetNestedField(obj.UnstructuredContent(), value, i.path...); err != nil { + return errors.Wrapf(err, "failed to set path %s of object %v", "."+strings.Join(i.path, "."), obj.GroupVersionKind()) } return nil } diff --git a/internal/controllers/cluster/cluster_controller.go b/internal/controllers/cluster/cluster_controller.go index b9c5b8d3c54c..82fa596f9200 100644 --- a/internal/controllers/cluster/cluster_controller.go +++ b/internal/controllers/cluster/cluster_controller.go @@ -181,7 +181,11 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (retRes ct defer func() { // Always reconcile the Status. - r.updateStatus(ctx, s) + if err := r.updateStatus(ctx, s); err != nil { + retRes = ctrl.Result{} + reterr = kerrors.NewAggregate([]error{reterr, err}) + return + } // Always attempt to Patch the Cluster object and status after each reconciliation. // Patch ObservedGeneration only if the reconciliation completed successfully diff --git a/internal/controllers/cluster/cluster_controller_status.go b/internal/controllers/cluster/cluster_controller_status.go index 6830c05009c0..c9325f2723b8 100644 --- a/internal/controllers/cluster/cluster_controller_status.go +++ b/internal/controllers/cluster/cluster_controller_status.go @@ -36,13 +36,19 @@ import ( "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/cluster-api/util/collections" v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2" + utilconversion "sigs.k8s.io/cluster-api/util/conversion" clog "sigs.k8s.io/cluster-api/util/log" ) -func (r *Reconciler) updateStatus(ctx context.Context, s *scope) { +func (r *Reconciler) updateStatus(ctx context.Context, s *scope) error { // Always reconcile the Status.Phase field. r.reconcilePhase(ctx, s.cluster) + controlPlaneContractVersion, err := utilconversion.GetContractVersion(ctx, r.Client, s.controlPlane.GroupVersionKind()) + if err != nil { + return err + } + // TODO: "expv1.MachinePoolList{}" below should be replaced through "s.descendants.machinePools" once replica counters // and Available, ScalingUp and ScalingDown conditions have been implemented for MachinePools. @@ -57,7 +63,7 @@ func (r *Reconciler) updateStatus(ctx context.Context, s *scope) { unhealthyMachines := s.descendants.unhealthyMachines.Filter(collections.Not(isMachinePoolMachine)) // replica counters - setControlPlaneReplicas(ctx, s.cluster, s.controlPlane, s.descendants.controlPlaneMachines, s.controlPlaneIsNotFound, s.getDescendantsSucceeded) + setControlPlaneReplicas(ctx, s.cluster, s.controlPlane, controlPlaneContractVersion, s.descendants.controlPlaneMachines, s.controlPlaneIsNotFound, s.getDescendantsSucceeded) setWorkersReplicas(ctx, s.cluster, expv1.MachinePoolList{}, s.descendants.machineDeployments, s.descendants.machineSets, workerMachines, s.getDescendantsSucceeded) // conditions @@ -75,9 +81,11 @@ func (r *Reconciler) updateStatus(ctx context.Context, s *scope) { setRemediatingCondition(ctx, s.cluster, machinesToBeRemediated, unhealthyMachines, s.getDescendantsSucceeded) setDeletingCondition(ctx, s.cluster, s.deletingReason, s.deletingMessage) setAvailableCondition(ctx, s.cluster, s.clusterClass) + + return nil } -func setControlPlaneReplicas(_ context.Context, cluster *clusterv1.Cluster, controlPlane *unstructured.Unstructured, controlPlaneMachines collections.Machines, controlPlaneIsNotFound bool, getDescendantsSucceeded bool) { +func setControlPlaneReplicas(_ context.Context, cluster *clusterv1.Cluster, controlPlane *unstructured.Unstructured, controlPlaneContractVersion string, controlPlaneMachines collections.Machines, controlPlaneIsNotFound bool, getDescendantsSucceeded bool) { if cluster.Status.ControlPlane == nil { cluster.Status.ControlPlane = &clusterv1.ClusterControlPlaneStatus{} } @@ -102,13 +110,13 @@ func setControlPlaneReplicas(_ context.Context, cluster *clusterv1.Cluster, cont if replicas, err := contract.ControlPlane().StatusReplicas().Get(controlPlane); err == nil && replicas != nil { cluster.Status.ControlPlane.Replicas = ptr.To(int32(*replicas)) } - if replicas, err := contract.ControlPlane().V1Beta2ReadyReplicas().Get(controlPlane); err == nil && replicas != nil { + if replicas, err := contract.ControlPlane().V1Beta2ReadyReplicas(controlPlaneContractVersion).Get(controlPlane); err == nil && replicas != nil { cluster.Status.ControlPlane.ReadyReplicas = replicas } - if replicas, err := contract.ControlPlane().V1Beta2AvailableReplicas().Get(controlPlane); err == nil && replicas != nil { + if replicas, err := contract.ControlPlane().V1Beta2AvailableReplicas(controlPlaneContractVersion).Get(controlPlane); err == nil && replicas != nil { cluster.Status.ControlPlane.AvailableReplicas = replicas } - if replicas, err := contract.ControlPlane().V1Beta2UpToDateReplicas().Get(controlPlane); err == nil && replicas != nil { + if replicas, err := contract.ControlPlane().V1Beta2UpToDateReplicas(controlPlaneContractVersion).Get(controlPlane); err == nil && replicas != nil { cluster.Status.ControlPlane.UpToDateReplicas = replicas } return diff --git a/internal/controllers/cluster/cluster_controller_status_test.go b/internal/controllers/cluster/cluster_controller_status_test.go index 24ea168f69cf..eb5f95ce4ee0 100644 --- a/internal/controllers/cluster/cluster_controller_status_test.go +++ b/internal/controllers/cluster/cluster_controller_status_test.go @@ -106,7 +106,7 @@ func TestSetControlPlaneReplicas(t *testing.T) { t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) - setControlPlaneReplicas(ctx, tt.cluster, tt.controlPlane, tt.machines, tt.controlPlaneIsNotFound, tt.getDescendantsSucceeded) + setControlPlaneReplicas(ctx, tt.cluster, tt.controlPlane, contract.Version, tt.machines, tt.controlPlaneIsNotFound, tt.getDescendantsSucceeded) g.Expect(tt.cluster.Status.ControlPlane).ToNot(BeNil()) g.Expect(tt.cluster.Status.ControlPlane.DesiredReplicas).To(Equal(tt.expectDesiredReplicas)) @@ -2968,7 +2968,7 @@ func (r currentReplicas) ApplyToMachineSet(ms *clusterv1.MachineSet) { type v1beta2ReadyReplicas int32 func (r v1beta2ReadyReplicas) ApplyToControlPlane(cp *unstructured.Unstructured) { - _ = contract.ControlPlane().V1Beta2ReadyReplicas().Set(cp, int64(r)) + _ = contract.ControlPlane().V1Beta2ReadyReplicas(contract.Version).Set(cp, int64(r)) } func (r v1beta2ReadyReplicas) ApplyToMachinePool(mp *expv1.MachinePool) { @@ -2986,7 +2986,7 @@ func (r v1beta2ReadyReplicas) ApplyToMachineSet(ms *clusterv1.MachineSet) { type v1beta2AvailableReplicas int32 func (r v1beta2AvailableReplicas) ApplyToControlPlane(cp *unstructured.Unstructured) { - _ = contract.ControlPlane().V1Beta2AvailableReplicas().Set(cp, int64(r)) + _ = contract.ControlPlane().V1Beta2AvailableReplicas(contract.Version).Set(cp, int64(r)) } func (r v1beta2AvailableReplicas) ApplyToMachinePool(mp *expv1.MachinePool) { @@ -3004,7 +3004,7 @@ func (r v1beta2AvailableReplicas) ApplyToMachineSet(ms *clusterv1.MachineSet) { type v1beta2UpToDateReplicas int32 func (r v1beta2UpToDateReplicas) ApplyToControlPlane(cp *unstructured.Unstructured) { - _ = contract.ControlPlane().V1Beta2UpToDateReplicas().Set(cp, int64(r)) + _ = contract.ControlPlane().V1Beta2UpToDateReplicas(contract.Version).Set(cp, int64(r)) } func (r v1beta2UpToDateReplicas) ApplyToMachinePool(mp *expv1.MachinePool) { diff --git a/internal/util/tree/tree.go b/internal/util/tree/tree.go index 5a95206aa1db..b80879eacb9e 100644 --- a/internal/util/tree/tree.go +++ b/internal/util/tree/tree.go @@ -562,7 +562,7 @@ func newV1beta2RowDescriptor(obj ctrlclient.Object) v1beta2RowDescriptor { if obj.Spec.Replicas != nil { v.replicas = fmt.Sprintf("%d/%d", *obj.Spec.Replicas, obj.Status.Replicas) } - if obj.Status.ReadyReplicas != nil { + if obj.Status.AvailableReplicas != nil { v.availableCounters = fmt.Sprintf("%d", *obj.Status.AvailableReplicas) } if obj.Status.ReadyReplicas != nil { @@ -641,19 +641,21 @@ func newV1beta2RowDescriptor(obj ctrlclient.Object) v1beta2RowDescriptor { } if tree.GetObjectContract(obj) == "ControlPlane" { + contractVersion := tree.GetObjectContractVersion(obj) + if current, err := contract.ControlPlane().StatusReplicas().Get(obj); err == nil && current != nil { if desired, err := contract.ControlPlane().Replicas().Get(obj); err == nil && desired != nil { v.replicas = fmt.Sprintf("%d/%d", *current, *desired) } } - if c, err := contract.ControlPlane().V1Beta2AvailableReplicas().Get(obj); err == nil && c != nil { + if c, err := contract.ControlPlane().V1Beta2AvailableReplicas(contractVersion).Get(obj); err == nil && c != nil { v.availableCounters = fmt.Sprintf("%d", *c) } - if c, err := contract.ControlPlane().V1Beta2ReadyReplicas().Get(obj); err == nil && c != nil { + if c, err := contract.ControlPlane().V1Beta2ReadyReplicas(contractVersion).Get(obj); err == nil && c != nil { v.readyCounters = fmt.Sprintf("%d", *c) } - if c, err := contract.ControlPlane().V1Beta2UpToDateReplicas().Get(obj); err == nil && c != nil { + if c, err := contract.ControlPlane().V1Beta2UpToDateReplicas(contractVersion).Get(obj); err == nil && c != nil { v.upToDateCounters = fmt.Sprintf("%d", *c) } } diff --git a/test/e2e/clusterclass_changes.go b/test/e2e/clusterclass_changes.go index 6bcd0bd78007..deffe6db889e 100644 --- a/test/e2e/clusterclass_changes.go +++ b/test/e2e/clusterclass_changes.go @@ -40,6 +40,7 @@ import ( "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/cluster-api/util" + utilconversion "sigs.k8s.io/cluster-api/util/conversion" "sigs.k8s.io/cluster-api/util/patch" ) @@ -347,6 +348,9 @@ func modifyControlPlaneViaClusterClassAndWait(ctx context.Context, input modifyC controlPlane, err := external.Get(ctx, mgmtClient, controlPlaneRef) g.Expect(err).ToNot(HaveOccurred()) + contractVersion, err := utilconversion.GetContractVersion(ctx, mgmtClient, controlPlane.GroupVersionKind()) + g.Expect(err).ToNot(HaveOccurred()) + // Verify that the fields from Cluster topology are set on the control plane. assertControlPlaneTopologyFields(g, controlPlane, controlPlaneTopology) @@ -365,7 +369,7 @@ func modifyControlPlaneViaClusterClassAndWait(ctx context.Context, input modifyC if ok { g.Expect(controlPlane.GetGeneration()).To(BeComparableTo(observedGeneration)) } - scaling, err := contract.ControlPlane().IsScaling(controlPlane) + scaling, err := contract.ControlPlane().IsScaling(controlPlane, contractVersion) g.Expect(err).ToNot(HaveOccurred()) g.Expect(scaling).To(BeFalse()) @@ -843,6 +847,9 @@ func rebaseClusterClassAndWait(ctx context.Context, input rebaseClusterClassAndW g.Expect(controlPlane.GetGeneration()).ToNot(Equal(beforeControlPlane.GetGeneration()), "ControlPlane generation should be incremented during the rebase because ControlPlane expected to be changed.") + contractVersion, err := utilconversion.GetContractVersion(ctx, mgmtClient, controlPlane.GroupVersionKind()) + g.Expect(err).ToNot(HaveOccurred()) + // Ensure KCP recognized the change and finished scaling. // Note: This is to ensure to not hit https://github.com/kubernetes-sigs/cluster-api/issues/11772 observedGeneration, ok, err := unstructured.NestedInt64(controlPlane.Object, "status", "observedGeneration") @@ -851,7 +858,7 @@ func rebaseClusterClassAndWait(ctx context.Context, input rebaseClusterClassAndW g.Expect(controlPlane.GetGeneration()).To(BeComparableTo(observedGeneration)) } - scaling, err := contract.ControlPlane().IsScaling(controlPlane) + scaling, err := contract.ControlPlane().IsScaling(controlPlane, contractVersion) g.Expect(err).ToNot(HaveOccurred()) g.Expect(scaling).To(BeFalse()) }, input.WaitForControlPlaneIntervals...).Should(Succeed()) From 23cc14bfe2d1055c07c770fbafbf757a8b87dd7a Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Tue, 8 Apr 2025 16:13:09 +0200 Subject: [PATCH 07/11] More feedback --- exp/ipam/api/v1beta1/conversion.go | 3 + exp/ipam/api/v1beta1/conversion_test.go | 11 ++- internal/apis/addons/v1alpha3/conversion.go | 4 +- internal/apis/addons/v1alpha4/conversion.go | 4 +- .../bootstrap/kubeadm/v1alpha3/conversion.go | 10 ++- .../kubeadm/v1alpha3/conversion.go | 10 ++- internal/apis/core/exp/v1alpha3/conversion.go | 72 ++----------------- internal/apis/core/v1alpha3/conversion.go | 4 +- internal/apis/core/v1alpha4/conversion.go | 20 +----- .../cluster/cluster_controller_phases.go | 6 +- 10 files changed, 29 insertions(+), 115 deletions(-) diff --git a/exp/ipam/api/v1beta1/conversion.go b/exp/ipam/api/v1beta1/conversion.go index 93176531220d..ac7f8e3853e1 100644 --- a/exp/ipam/api/v1beta1/conversion.go +++ b/exp/ipam/api/v1beta1/conversion.go @@ -89,6 +89,9 @@ func Convert_v1beta1_IPAddressClaimStatus_To_v1beta2_IPAddressClaimStatus(in *IP } // Move legacy conditions (v1beta1) to the deprecated field. + if in.Conditions == nil { + return nil + } if out.Deprecated == nil { out.Deprecated = &ipamv1.IPAddressClaimDeprecatedStatus{} } diff --git a/exp/ipam/api/v1beta1/conversion_test.go b/exp/ipam/api/v1beta1/conversion_test.go index 8c3772a1ab42..d609ca5b2239 100644 --- a/exp/ipam/api/v1beta1/conversion_test.go +++ b/exp/ipam/api/v1beta1/conversion_test.go @@ -53,12 +53,11 @@ func IPAddressClaimFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} { func hubIPAddressClaimStatus(in *ipamv1.IPAddressClaimStatus, c fuzz.Continue) { c.FuzzNoCustom(in) - // Always create struct with at least one mandatory fields. - if in.Deprecated == nil { - in.Deprecated = &ipamv1.IPAddressClaimDeprecatedStatus{} - } - if in.Deprecated.V1Beta1 == nil { - in.Deprecated.V1Beta1 = &ipamv1.IPAddressClaimV1Beta1DeprecatedStatus{} + // Drop empty structs with only omit empty fields. + if in.Deprecated != nil { + if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &ipamv1.IPAddressClaimV1Beta1DeprecatedStatus{}) { + in.Deprecated = nil + } } } diff --git a/internal/apis/addons/v1alpha3/conversion.go b/internal/apis/addons/v1alpha3/conversion.go index 5396b31d1531..c3f3ec5683ea 100644 --- a/internal/apis/addons/v1alpha3/conversion.go +++ b/internal/apis/addons/v1alpha3/conversion.go @@ -37,9 +37,7 @@ func (src *ClusterResourceSet) ConvertTo(dstRaw conversion.Hub) error { if src.Status.Conditions != nil { dst.Status.Deprecated = &addonsv1.ClusterResourceSetDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &addonsv1.ClusterResourceSetV1Beta1DeprecatedStatus{} - if src.Status.Conditions != nil { - clusterv1alpha3.Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) - } + clusterv1alpha3.Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } // Manually restore data. diff --git a/internal/apis/addons/v1alpha4/conversion.go b/internal/apis/addons/v1alpha4/conversion.go index 936170402699..e014901c17de 100644 --- a/internal/apis/addons/v1alpha4/conversion.go +++ b/internal/apis/addons/v1alpha4/conversion.go @@ -38,9 +38,7 @@ func (src *ClusterResourceSet) ConvertTo(dstRaw conversion.Hub) error { if src.Status.Conditions != nil { dst.Status.Deprecated = &addonsv1.ClusterResourceSetDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &addonsv1.ClusterResourceSetV1Beta1DeprecatedStatus{} - if src.Status.Conditions != nil { - clusterv1alpha4.Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) - } + clusterv1alpha4.Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } // Manually restore data. diff --git a/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go b/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go index c26a16ed74c9..5f8675f0e2e8 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go @@ -255,12 +255,10 @@ func Convert_v1beta2_KubeadmConfigStatus_To_v1alpha3_KubeadmConfigStatus(in *boo // Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) -func Convert_v1_Condition_To_v1alpha3_Condition(_ *metav1.Condition, _ *clusterv1alpha3.Condition, _ apimachineryconversion.Scope) error { - // NOTE: v1beta2 conditions should not be automatically converted into v1beta1 conditions. - return nil +func Convert_v1_Condition_To_v1alpha3_Condition(in *metav1.Condition, out *clusterv1alpha3.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha3.Convert_v1_Condition_To_v1alpha3_Condition(in, out, s) } -func Convert_v1alpha3_Condition_To_v1_Condition(_ *clusterv1alpha3.Condition, _ *metav1.Condition, _ apimachineryconversion.Scope) error { - // NOTE: v1beta1 conditions should not be automatically converted into v1beta2 conditions. - return nil +func Convert_v1alpha3_Condition_To_v1_Condition(in *clusterv1alpha3.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha3.Convert_v1alpha3_Condition_To_v1_Condition(in, out, s) } diff --git a/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go b/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go index 2d6792bc45d2..16fd2a09dfeb 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go +++ b/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go @@ -144,14 +144,12 @@ func Convert_v1alpha3_KubeadmControlPlaneStatus_To_v1beta2_KubeadmControlPlaneSt // Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) -func Convert_v1_Condition_To_v1alpha3_Condition(_ *metav1.Condition, _ *clusterv1alpha3.Condition, _ apimachineryconversion.Scope) error { - // NOTE: v1beta2 conditions should not be automatically converted into v1beta1 conditions. - return nil +func Convert_v1_Condition_To_v1alpha3_Condition(in *metav1.Condition, out *clusterv1alpha3.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha3.Convert_v1_Condition_To_v1alpha3_Condition(in, out, s) } -func Convert_v1alpha3_Condition_To_v1_Condition(_ *clusterv1alpha3.Condition, _ *metav1.Condition, _ apimachineryconversion.Scope) error { - // NOTE: v1beta1 conditions should not be automatically converted into v1beta2 conditions. - return nil +func Convert_v1alpha3_Condition_To_v1_Condition(in *clusterv1alpha3.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha3.Convert_v1alpha3_Condition_To_v1_Condition(in, out, s) } func Convert_v1beta2_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in *bootstrapv1.KubeadmConfigSpec, out *bootstrapv1alpha3.KubeadmConfigSpec, s apimachineryconversion.Scope) error { diff --git a/internal/apis/core/exp/v1alpha3/conversion.go b/internal/apis/core/exp/v1alpha3/conversion.go index 37e8a46de853..e8372a206221 100644 --- a/internal/apis/core/exp/v1alpha3/conversion.go +++ b/internal/apis/core/exp/v1alpha3/conversion.go @@ -17,8 +17,6 @@ limitations under the License. package v1alpha3 import ( - "unsafe" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" apimachineryconversion "k8s.io/apimachinery/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" @@ -140,77 +138,19 @@ func Convert_v1beta2_MachineTemplateSpec_To_v1alpha3_MachineTemplateSpec(in *clu } func Convert_v1beta2_MachinePoolStatus_To_v1alpha3_MachinePoolStatus(in *expv1.MachinePoolStatus, out *MachinePoolStatus, s apimachineryconversion.Scope) error { - // V1Beta2 was added in v1beta1 - if err := autoConvert_v1beta2_MachinePoolStatus_To_v1alpha3_MachinePoolStatus(in, out, s); err != nil { - return err - } - - // undo autogenerated conversion conditions - // NOTE: v1beta2 conditions should not be automatically converted into v1beta1 conditions. - out.Conditions = nil - - // v1beta1 conditions, failureReason, failureMessage moved to deprecated. - if in.Deprecated != nil && in.Deprecated.V1Beta1 != nil { - out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage - out.FailureReason = in.Deprecated.V1Beta1.FailureReason - if in.Deprecated.V1Beta1.Conditions != nil { - in, out := &in.Deprecated.V1Beta1.Conditions, &out.Conditions - *out = make(clusterv1alpha3.Conditions, len(*in)) - for i := range *in { - (*out)[i] = *(*clusterv1alpha3.Condition)(unsafe.Pointer(&(*in)[i])) - } - } else { - out.Conditions = nil - } - } - - return nil + return autoConvert_v1beta2_MachinePoolStatus_To_v1alpha3_MachinePoolStatus(in, out, s) } func Convert_v1alpha3_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in *MachinePoolStatus, out *expv1.MachinePoolStatus, s apimachineryconversion.Scope) error { - // V1Beta2 was added in v1beta1 - if err := autoConvert_v1alpha3_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in, out, s); err != nil { - return err - } - - // undo autogenerated conversion conditions - // NOTE: v1beta1 conditions should not be automatically converted into v1beta2 conditions. - out.Conditions = nil - - // v1beta1 conditions, failureReason, failureMessage moved to deprecated. - if in.Conditions == nil && in.FailureReason == nil && in.FailureMessage == nil { - return nil - } - if out.Deprecated == nil { - out.Deprecated = &expv1.MachinePoolDeprecatedStatus{} - } - if out.Deprecated.V1Beta1 == nil { - out.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} - } - - if in.Conditions != nil { - in, out := &in.Conditions, &out.Deprecated.V1Beta1.Conditions - *out = make(clusterv1.Conditions, len(*in)) - for i := range *in { - (*out)[i] = *(*clusterv1.Condition)(unsafe.Pointer(&(*in)[i])) - } - } else { - out.Deprecated.V1Beta1.Conditions = nil - } - - out.Deprecated.V1Beta1.FailureReason = in.FailureReason - out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage - return nil + return autoConvert_v1alpha3_MachinePoolStatus_To_v1beta2_MachinePoolStatus(in, out, s) } // Implement local conversion func because conversion-gen is not aware of conversion func in other packages (see https://github.com/kubernetes/code-generator/issues/94) -func Convert_v1_Condition_To_v1alpha3_Condition(_ *metav1.Condition, _ *clusterv1alpha3.Condition, _ apimachineryconversion.Scope) error { - // NOTE: v1beta2 conditions should not be automatically converted into v1beta1 conditions. - return nil +func Convert_v1_Condition_To_v1alpha3_Condition(in *metav1.Condition, out *clusterv1alpha3.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha3.Convert_v1_Condition_To_v1alpha3_Condition(in, out, s) } -func Convert_v1alpha3_Condition_To_v1_Condition(_ *clusterv1alpha3.Condition, _ *metav1.Condition, _ apimachineryconversion.Scope) error { - // NOTE: v1beta1 conditions should not be automatically converted into v1beta2 conditions. - return nil +func Convert_v1alpha3_Condition_To_v1_Condition(in *clusterv1alpha3.Condition, out *metav1.Condition, s apimachineryconversion.Scope) error { + return clusterv1alpha3.Convert_v1alpha3_Condition_To_v1_Condition(in, out, s) } diff --git a/internal/apis/core/v1alpha3/conversion.go b/internal/apis/core/v1alpha3/conversion.go index 861236f6a259..8c5d51645fba 100644 --- a/internal/apis/core/v1alpha3/conversion.go +++ b/internal/apis/core/v1alpha3/conversion.go @@ -326,9 +326,7 @@ func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error { if src.Status.Conditions != nil { dst.Status.Deprecated = &clusterv1.MachineHealthCheckDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{} - if src.Status.Conditions != nil { - Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) - } + Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } // Manually restore data. diff --git a/internal/apis/core/v1alpha4/conversion.go b/internal/apis/core/v1alpha4/conversion.go index b2a5572ddd35..4ee2f3f456c6 100644 --- a/internal/apis/core/v1alpha4/conversion.go +++ b/internal/apis/core/v1alpha4/conversion.go @@ -418,9 +418,7 @@ func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error { if src.Status.Conditions != nil { dst.Status.Deprecated = &clusterv1.MachineHealthCheckDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineHealthCheckV1Beta1DeprecatedStatus{} - if src.Status.Conditions != nil { - Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) - } + Convert_v1alpha4_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions) } // Manually restore data. @@ -460,22 +458,6 @@ func (dst *MachineHealthCheck) ConvertFrom(srcRaw conversion.Hub) error { func Convert_v1alpha4_MachineStatus_To_v1beta2_MachineStatus(in *MachineStatus, out *clusterv1.MachineStatus, s apimachineryconversion.Scope) error { // Status.version has been removed in v1beta1, thus requiring custom conversion function. the information will be dropped. return autoConvert_v1alpha4_MachineStatus_To_v1beta2_MachineStatus(in, out, s) - - // v1beta1 conditions, failureReason, failureMessage moved to deprecated. - if in.Conditions == nil && in.FailureReason == nil && in.FailureMessage == nil { - return nil - } - if out.Deprecated == nil { - out.Deprecated = &clusterv1.MachineDeprecatedStatus{} - } - if out.Deprecated.V1Beta1 == nil { - out.Deprecated.V1Beta1 = &clusterv1.MachineV1Beta1DeprecatedStatus{} - } - - out.Deprecated.V1Beta1.Conditions = *(*clusterv1.Conditions)(unsafe.Pointer(&in.Conditions)) - out.Deprecated.V1Beta1.FailureReason = in.FailureReason - out.Deprecated.V1Beta1.FailureMessage = in.FailureMessage - return nil } func Convert_v1beta2_ClusterClassSpec_To_v1alpha4_ClusterClassSpec(in *clusterv1.ClusterClassSpec, out *ClusterClassSpec, s apimachineryconversion.Scope) error { diff --git a/internal/controllers/cluster/cluster_controller_phases.go b/internal/controllers/cluster/cluster_controller_phases.go index 476c2c43d30d..32a6b1092ee7 100644 --- a/internal/controllers/cluster/cluster_controller_phases.go +++ b/internal/controllers/cluster/cluster_controller_phases.go @@ -62,10 +62,10 @@ func (r *Reconciler) reconcilePhase(_ context.Context, cluster *clusterv1.Cluste cluster.Status.SetTypedPhase(clusterv1.ClusterPhaseProvisioned) } - failedMessage := "" + failureMessage := "" if cluster.Status.Deprecated != nil && cluster.Status.Deprecated.V1Beta1 != nil && (cluster.Status.Deprecated.V1Beta1.FailureReason != nil || cluster.Status.Deprecated.V1Beta1.FailureMessage != nil) { cluster.Status.SetTypedPhase(clusterv1.ClusterPhaseFailed) - failedMessage = ptr.Deref(cluster.Status.Deprecated.V1Beta1.FailureMessage, "unknown") + failureMessage = ptr.Deref(cluster.Status.Deprecated.V1Beta1.FailureMessage, "unknown") } if !cluster.DeletionTimestamp.IsZero() { @@ -76,7 +76,7 @@ func (r *Reconciler) reconcilePhase(_ context.Context, cluster *clusterv1.Cluste if preReconcilePhase != cluster.Status.GetTypedPhase() { // Failed clusters should get a Warning event if cluster.Status.GetTypedPhase() == clusterv1.ClusterPhaseFailed { - r.recorder.Eventf(cluster, corev1.EventTypeWarning, string(cluster.Status.GetTypedPhase()), "Cluster %s is %s: %s", cluster.Name, string(cluster.Status.GetTypedPhase()), failedMessage) + r.recorder.Eventf(cluster, corev1.EventTypeWarning, string(cluster.Status.GetTypedPhase()), "Cluster %s is %s: %s", cluster.Name, string(cluster.Status.GetTypedPhase()), failureMessage) } else { r.recorder.Eventf(cluster, corev1.EventTypeNormal, string(cluster.Status.GetTypedPhase()), "Cluster %s is %s", cluster.Name, string(cluster.Status.GetTypedPhase())) } From 7a09c1909e51f59b1f071d80346d6098d38fe5b5 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Tue, 8 Apr 2025 16:27:44 +0200 Subject: [PATCH 08/11] Fix unit test --- .../controllers/cluster/cluster_controller_status.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/controllers/cluster/cluster_controller_status.go b/internal/controllers/cluster/cluster_controller_status.go index c9325f2723b8..0179622053f2 100644 --- a/internal/controllers/cluster/cluster_controller_status.go +++ b/internal/controllers/cluster/cluster_controller_status.go @@ -44,9 +44,13 @@ func (r *Reconciler) updateStatus(ctx context.Context, s *scope) error { // Always reconcile the Status.Phase field. r.reconcilePhase(ctx, s.cluster) - controlPlaneContractVersion, err := utilconversion.GetContractVersion(ctx, r.Client, s.controlPlane.GroupVersionKind()) - if err != nil { - return err + controlPlaneContractVersion := "" + if s.controlPlane != nil { + var err error + controlPlaneContractVersion, err = utilconversion.GetContractVersion(ctx, r.Client, s.controlPlane.GroupVersionKind()) + if err != nil { + return err + } } // TODO: "expv1.MachinePoolList{}" below should be replaced through "s.descendants.machinePools" once replica counters From c166a2318949f5970037d068eadbfd58997e5942 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Tue, 8 Apr 2025 19:41:34 +0200 Subject: [PATCH 09/11] More feedback --- api/v1beta2/machinedeployment_types.go | 6 ++--- api/v1beta2/machineset_types.go | 4 ++-- .../kubeadm/api/v1beta1/conversion_test.go | 3 ++- .../cluster.x-k8s.io_machinedeployments.yaml | 6 ++--- .../bases/cluster.x-k8s.io_machinesets.yaml | 4 ++-- .../kubeadm/api/v1beta1/conversion_test.go | 3 ++- .../v1beta2/kubeadm_control_plane_types.go | 6 ++--- ...cluster.x-k8s.io_kubeadmcontrolplanes.yaml | 6 ++--- exp/ipam/api/v1alpha1/conversion.go | 4 ++++ internal/apis/addons/v1alpha3/conversion.go | 4 ++++ internal/apis/addons/v1alpha4/conversion.go | 4 ++++ .../bootstrap/kubeadm/v1alpha3/conversion.go | 4 ++++ .../bootstrap/kubeadm/v1alpha4/conversion.go | 4 ++++ .../kubeadm/v1alpha3/conversion.go | 4 ++++ .../kubeadm/v1alpha4/conversion.go | 4 ++++ internal/apis/core/exp/v1alpha3/conversion.go | 4 ++++ internal/apis/core/exp/v1alpha4/conversion.go | 4 ++++ internal/apis/core/v1alpha3/conversion.go | 6 +++++ .../apis/core/v1alpha3/conversion_test.go | 6 ----- internal/apis/core/v1alpha4/conversion.go | 24 +++++++++++++++++++ .../machineset/machineset_controller.go | 7 ++++-- 21 files changed, 91 insertions(+), 26 deletions(-) diff --git a/api/v1beta2/machinedeployment_types.go b/api/v1beta2/machinedeployment_types.go index 89197ed5adec..538af62d6c30 100644 --- a/api/v1beta2/machinedeployment_types.go +++ b/api/v1beta2/machinedeployment_types.go @@ -601,9 +601,9 @@ func (md *MachineDeploymentStatus) GetTypedPhase() MachineDeploymentPhase { // +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".spec.clusterName",description="Cluster" // +kubebuilder:printcolumn:name="Desired",type=integer,JSONPath=".spec.replicas",description="Total number of machines desired by this MachineDeployment",priority=10 // +kubebuilder:printcolumn:name="Replicas",type="integer",JSONPath=".status.replicas",description="Total number of non-terminated machines targeted by this MachineDeployment" -// +kubebuilder:printcolumn:name="Ready",type="integer",JSONPath=".status.readyReplicas",description="Total number of ready machines targeted by this MachineDeployment" -// +kubebuilder:printcolumn:name="Updated",type=integer,JSONPath=".status.updatedReplicas",description="Total number of non-terminated machines targeted by this deployment that have the desired template spec" -// +kubebuilder:printcolumn:name="Unavailable",type=integer,JSONPath=".status.unavailableReplicas",description="Total number of unavailable machines targeted by this MachineDeployment" +// +kubebuilder:printcolumn:name="Ready",type="integer",JSONPath=".status.deprecated.v1beta1.readyReplicas",description="Total number of ready machines targeted by this MachineDeployment" +// +kubebuilder:printcolumn:name="Updated",type=integer,JSONPath=".status.deprecated.v1beta1.updatedReplicas",description="Total number of non-terminated machines targeted by this deployment that have the desired template spec" +// +kubebuilder:printcolumn:name="Unavailable",type=integer,JSONPath=".status.deprecated.v1beta1.unavailableReplicas",description="Total number of unavailable machines targeted by this MachineDeployment" // +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="MachineDeployment status such as ScalingUp/ScalingDown/Running/Failed/Unknown" // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of MachineDeployment" // +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.template.spec.version",description="Kubernetes version associated with this MachineDeployment" diff --git a/api/v1beta2/machineset_types.go b/api/v1beta2/machineset_types.go index 120b94dfec72..ede9c790a42e 100644 --- a/api/v1beta2/machineset_types.go +++ b/api/v1beta2/machineset_types.go @@ -436,8 +436,8 @@ func (m *MachineSet) Validate() field.ErrorList { // +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".spec.clusterName",description="Cluster" // +kubebuilder:printcolumn:name="Desired",type=integer,JSONPath=".spec.replicas",description="Total number of machines desired by this machineset",priority=10 // +kubebuilder:printcolumn:name="Replicas",type="integer",JSONPath=".status.replicas",description="Total number of non-terminated machines targeted by this machineset" -// +kubebuilder:printcolumn:name="Ready",type="integer",JSONPath=".status.readyReplicas",description="Total number of ready machines targeted by this machineset." -// +kubebuilder:printcolumn:name="Available",type="integer",JSONPath=".status.availableReplicas",description="Total number of available machines (ready for at least minReadySeconds)" +// +kubebuilder:printcolumn:name="Ready",type="integer",JSONPath=".status.deprecated.v1beta1.readyReplicas",description="Total number of ready machines targeted by this machineset." +// +kubebuilder:printcolumn:name="Available",type="integer",JSONPath=".status.deprecated.v1beta1.availableReplicas",description="Total number of available machines (ready for at least minReadySeconds)" // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of MachineSet" // +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.template.spec.version",description="Kubernetes version associated with this MachineSet" diff --git a/bootstrap/kubeadm/api/v1beta1/conversion_test.go b/bootstrap/kubeadm/api/v1beta1/conversion_test.go index 668ad3222060..2c3ef7b4b591 100644 --- a/bootstrap/kubeadm/api/v1beta1/conversion_test.go +++ b/bootstrap/kubeadm/api/v1beta1/conversion_test.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "reflect" "testing" fuzz "github.com/google/gofuzz" @@ -65,7 +66,7 @@ func spokeKubeadmConfigStatus(in *KubeadmConfigStatus, c fuzz.Continue) { c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { - if in.V1Beta2.Conditions == nil { + if reflect.DeepEqual(in.V1Beta2, &KubeadmConfigV1Beta2Status{}) { in.V1Beta2 = nil } } diff --git a/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml b/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml index 6f54d7a1be17..f8f6cc881348 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml @@ -1827,16 +1827,16 @@ spec: name: Replicas type: integer - description: Total number of ready machines targeted by this MachineDeployment - jsonPath: .status.readyReplicas + jsonPath: .status.deprecated.v1beta1.readyReplicas name: Ready type: integer - description: Total number of non-terminated machines targeted by this deployment that have the desired template spec - jsonPath: .status.updatedReplicas + jsonPath: .status.deprecated.v1beta1.updatedReplicas name: Updated type: integer - description: Total number of unavailable machines targeted by this MachineDeployment - jsonPath: .status.unavailableReplicas + jsonPath: .status.deprecated.v1beta1.unavailableReplicas name: Unavailable type: integer - description: MachineDeployment status such as ScalingUp/ScalingDown/Running/Failed/Unknown diff --git a/config/crd/bases/cluster.x-k8s.io_machinesets.yaml b/config/crd/bases/cluster.x-k8s.io_machinesets.yaml index b52b7e2a8faa..16aa0981f1d8 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinesets.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinesets.yaml @@ -1593,11 +1593,11 @@ spec: name: Replicas type: integer - description: Total number of ready machines targeted by this machineset. - jsonPath: .status.readyReplicas + jsonPath: .status.deprecated.v1beta1.readyReplicas name: Ready type: integer - description: Total number of available machines (ready for at least minReadySeconds) - jsonPath: .status.availableReplicas + jsonPath: .status.deprecated.v1beta1.availableReplicas name: Available type: integer - description: Time duration since creation of MachineSet diff --git a/controlplane/kubeadm/api/v1beta1/conversion_test.go b/controlplane/kubeadm/api/v1beta1/conversion_test.go index f6b36331631c..4ed68ce5ea43 100644 --- a/controlplane/kubeadm/api/v1beta1/conversion_test.go +++ b/controlplane/kubeadm/api/v1beta1/conversion_test.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "reflect" "testing" fuzz "github.com/google/gofuzz" @@ -65,7 +66,7 @@ func spokeKubeadmControlPlaneStatus(in *KubeadmControlPlaneStatus, c fuzz.Contin c.FuzzNoCustom(in) // Drop empty structs with only omit empty fields. if in.V1Beta2 != nil { - if in.V1Beta2.Conditions == nil && in.V1Beta2.AvailableReplicas == nil && in.V1Beta2.ReadyReplicas == nil && in.V1Beta2.UpToDateReplicas == nil { + if reflect.DeepEqual(in.V1Beta2, &KubeadmControlPlaneV1Beta2Status{}) { in.V1Beta2 = nil } } diff --git a/controlplane/kubeadm/api/v1beta2/kubeadm_control_plane_types.go b/controlplane/kubeadm/api/v1beta2/kubeadm_control_plane_types.go index afd5a3846484..5dbc94f67563 100644 --- a/controlplane/kubeadm/api/v1beta2/kubeadm_control_plane_types.go +++ b/controlplane/kubeadm/api/v1beta2/kubeadm_control_plane_types.go @@ -448,9 +448,9 @@ type LastRemediationStatus struct { // +kubebuilder:printcolumn:name="API Server Available",type=boolean,JSONPath=".status.ready",description="KubeadmControlPlane API Server is ready to receive requests" // +kubebuilder:printcolumn:name="Desired",type=integer,JSONPath=".spec.replicas",description="Total number of machines desired by this control plane",priority=10 // +kubebuilder:printcolumn:name="Replicas",type=integer,JSONPath=".status.replicas",description="Total number of non-terminated machines targeted by this control plane" -// +kubebuilder:printcolumn:name="Ready",type=integer,JSONPath=".status.readyReplicas",description="Total number of fully running and ready control plane machines" -// +kubebuilder:printcolumn:name="Updated",type=integer,JSONPath=".status.updatedReplicas",description="Total number of non-terminated machines targeted by this control plane that have the desired template spec" -// +kubebuilder:printcolumn:name="Unavailable",type=integer,JSONPath=".status.unavailableReplicas",description="Total number of unavailable machines targeted by this control plane" +// +kubebuilder:printcolumn:name="Ready",type=integer,JSONPath=".status.deprecated.v1beta1.readyReplicas",description="Total number of fully running and ready control plane machines" +// +kubebuilder:printcolumn:name="Updated",type=integer,JSONPath=".status.deprecated.v1beta1.updatedReplicas",description="Total number of non-terminated machines targeted by this control plane that have the desired template spec" +// +kubebuilder:printcolumn:name="Unavailable",type=integer,JSONPath=".status.deprecated.v1beta1.unavailableReplicas",description="Total number of unavailable machines targeted by this control plane" // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of KubeadmControlPlane" // +kubebuilder:printcolumn:name="Version",type=string,JSONPath=".spec.version",description="Kubernetes version associated with this control plane" diff --git a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml index 41e0e6daee48..dab1a6c6acec 100644 --- a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml +++ b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml @@ -4991,16 +4991,16 @@ spec: name: Replicas type: integer - description: Total number of fully running and ready control plane machines - jsonPath: .status.readyReplicas + jsonPath: .status.deprecated.v1beta1.readyReplicas name: Ready type: integer - description: Total number of non-terminated machines targeted by this control plane that have the desired template spec - jsonPath: .status.updatedReplicas + jsonPath: .status.deprecated.v1beta1.updatedReplicas name: Updated type: integer - description: Total number of unavailable machines targeted by this control plane - jsonPath: .status.unavailableReplicas + jsonPath: .status.deprecated.v1beta1.unavailableReplicas name: Unavailable type: integer - description: Time duration since creation of KubeadmControlPlane diff --git a/exp/ipam/api/v1alpha1/conversion.go b/exp/ipam/api/v1alpha1/conversion.go index 4bcc2dff0ee4..b8d4afc6147f 100644 --- a/exp/ipam/api/v1alpha1/conversion.go +++ b/exp/ipam/api/v1alpha1/conversion.go @@ -45,6 +45,10 @@ func (src *IPAddressClaim) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1beta1 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1beta1) to the deprecated field. if src.Status.Conditions != nil { dst.Status.Deprecated = &ipamv1.IPAddressClaimDeprecatedStatus{} diff --git a/internal/apis/addons/v1alpha3/conversion.go b/internal/apis/addons/v1alpha3/conversion.go index c3f3ec5683ea..8abaa60daf83 100644 --- a/internal/apis/addons/v1alpha3/conversion.go +++ b/internal/apis/addons/v1alpha3/conversion.go @@ -33,6 +33,10 @@ func (src *ClusterResourceSet) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha3 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha3) to the deprecated field. if src.Status.Conditions != nil { dst.Status.Deprecated = &addonsv1.ClusterResourceSetDeprecatedStatus{} diff --git a/internal/apis/addons/v1alpha4/conversion.go b/internal/apis/addons/v1alpha4/conversion.go index e014901c17de..04e684bfdb7e 100644 --- a/internal/apis/addons/v1alpha4/conversion.go +++ b/internal/apis/addons/v1alpha4/conversion.go @@ -34,6 +34,10 @@ func (src *ClusterResourceSet) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha4 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha4) to the deprecated field. if src.Status.Conditions != nil { dst.Status.Deprecated = &addonsv1.ClusterResourceSetDeprecatedStatus{} diff --git a/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go b/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go index 5f8675f0e2e8..ead9f7fdcce3 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha3/conversion.go @@ -34,6 +34,10 @@ func (src *KubeadmConfig) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha3 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha3), failureReason and failureMessage to the deprecated field. dst.Status.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &bootstrapv1.KubeadmConfigV1Beta1DeprecatedStatus{} diff --git a/internal/apis/bootstrap/kubeadm/v1alpha4/conversion.go b/internal/apis/bootstrap/kubeadm/v1alpha4/conversion.go index b4a804f92fa8..a024a1ac55e1 100644 --- a/internal/apis/bootstrap/kubeadm/v1alpha4/conversion.go +++ b/internal/apis/bootstrap/kubeadm/v1alpha4/conversion.go @@ -33,6 +33,10 @@ func (src *KubeadmConfig) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha4 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha4), failureReason and failureMessage to the deprecated field. dst.Status.Deprecated = &bootstrapv1.KubeadmConfigDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &bootstrapv1.KubeadmConfigV1Beta1DeprecatedStatus{} diff --git a/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go b/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go index 16fd2a09dfeb..948f3466baf9 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go +++ b/internal/apis/controlplane/kubeadm/v1alpha3/conversion.go @@ -35,6 +35,10 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha3 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha3), failureReason, failureMessage and replica counters to the deprecated field. dst.Status.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{} diff --git a/internal/apis/controlplane/kubeadm/v1alpha4/conversion.go b/internal/apis/controlplane/kubeadm/v1alpha4/conversion.go index 7cd270bb73d2..2ec1a093350a 100644 --- a/internal/apis/controlplane/kubeadm/v1alpha4/conversion.go +++ b/internal/apis/controlplane/kubeadm/v1alpha4/conversion.go @@ -36,6 +36,10 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha4 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha4), failureReason, failureMessage and replica counters to the deprecated field. dst.Status.Deprecated = &controlplanev1.KubeadmControlPlaneDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &controlplanev1.KubeadmControlPlaneV1Beta1DeprecatedStatus{} diff --git a/internal/apis/core/exp/v1alpha3/conversion.go b/internal/apis/core/exp/v1alpha3/conversion.go index e8372a206221..bc593537acd1 100644 --- a/internal/apis/core/exp/v1alpha3/conversion.go +++ b/internal/apis/core/exp/v1alpha3/conversion.go @@ -68,6 +68,10 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha4 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha3), failureReason, failureMessage and replica counters to the deprecated field. dst.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} diff --git a/internal/apis/core/exp/v1alpha4/conversion.go b/internal/apis/core/exp/v1alpha4/conversion.go index ac0867d112ab..629c798d00a9 100644 --- a/internal/apis/core/exp/v1alpha4/conversion.go +++ b/internal/apis/core/exp/v1alpha4/conversion.go @@ -34,6 +34,10 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha4 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha4), failureReason, failureMessage and replica counters to the deprecated field. dst.Status.Deprecated = &expv1.MachinePoolDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &expv1.MachinePoolV1Beta1DeprecatedStatus{} diff --git a/internal/apis/core/v1alpha3/conversion.go b/internal/apis/core/v1alpha3/conversion.go index 8c5d51645fba..8df703822828 100644 --- a/internal/apis/core/v1alpha3/conversion.go +++ b/internal/apis/core/v1alpha3/conversion.go @@ -194,6 +194,9 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Template.Spec.ReadinessGates = restored.Spec.Template.Spec.ReadinessGates dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout + if restored.Status.Deprecated != nil && restored.Status.Deprecated.V1Beta1 != nil { + dst.Status.Deprecated.V1Beta1.Conditions = restored.Status.Deprecated.V1Beta1.Conditions + } dst.Status.Conditions = restored.Status.Conditions dst.Status.AvailableReplicas = restored.Status.AvailableReplicas dst.Status.ReadyReplicas = restored.Status.ReadyReplicas @@ -277,6 +280,9 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout dst.Spec.RolloutAfter = restored.Spec.RolloutAfter + if restored.Status.Deprecated != nil && restored.Status.Deprecated.V1Beta1 != nil { + dst.Status.Deprecated.V1Beta1.Conditions = restored.Status.Deprecated.V1Beta1.Conditions + } dst.Status.Conditions = restored.Status.Conditions dst.Status.AvailableReplicas = restored.Status.AvailableReplicas dst.Status.ReadyReplicas = restored.Status.ReadyReplicas diff --git a/internal/apis/core/v1alpha3/conversion_test.go b/internal/apis/core/v1alpha3/conversion_test.go index e003462d87f4..0f7cb32c186f 100644 --- a/internal/apis/core/v1alpha3/conversion_test.go +++ b/internal/apis/core/v1alpha3/conversion_test.go @@ -110,9 +110,6 @@ func hubMachineSetStatus(in *clusterv1.MachineSetStatus, c fuzz.Continue) { if in.Deprecated.V1Beta1 == nil { in.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} } - - // conditions do not exist in v1beta3. - in.Deprecated.V1Beta1.Conditions = nil } func MachineDeploymentFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} { @@ -132,9 +129,6 @@ func hubMachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, c fuzz.Co if in.Deprecated.V1Beta1 == nil { in.Deprecated.V1Beta1 = &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{} } - - // conditions do not exist in v1beta3. - in.Deprecated.V1Beta1.Conditions = nil } func spokeObjectMeta(in *ObjectMeta, c fuzz.Continue) { diff --git a/internal/apis/core/v1alpha4/conversion.go b/internal/apis/core/v1alpha4/conversion.go index 4ee2f3f456c6..a6186d9d4287 100644 --- a/internal/apis/core/v1alpha4/conversion.go +++ b/internal/apis/core/v1alpha4/conversion.go @@ -34,6 +34,10 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha4 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha4), failureReason and failureMessage to the deprecated field. if src.Status.Conditions != nil || src.Status.FailureReason != nil || src.Status.FailureMessage != nil { dst.Status.Deprecated = &clusterv1.ClusterDeprecatedStatus{} @@ -140,6 +144,10 @@ func (src *ClusterClass) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha4 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Manually restore data. restored := &clusterv1.ClusterClass{} if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok { @@ -196,6 +204,10 @@ func (src *Machine) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha4 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha4), failureReason and failureMessage to the deprecated field. if src.Status.Conditions != nil || src.Status.FailureReason != nil || src.Status.FailureMessage != nil { dst.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} @@ -260,6 +272,10 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha4 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha4), failureReason, failureMessage and replica counters to the deprecated field. dst.Status.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} @@ -334,6 +350,10 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha4 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha4) and replica counters to the deprecated field. dst.Status.Deprecated = &clusterv1.MachineDeploymentDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{} @@ -414,6 +434,10 @@ func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha4 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha4) to the deprecated field. if src.Status.Conditions != nil { dst.Status.Deprecated = &clusterv1.MachineHealthCheckDeprecatedStatus{} diff --git a/internal/controllers/machineset/machineset_controller.go b/internal/controllers/machineset/machineset_controller.go index 5efadbd9bfc2..9d302a63c3e0 100644 --- a/internal/controllers/machineset/machineset_controller.go +++ b/internal/controllers/machineset/machineset_controller.go @@ -1213,8 +1213,11 @@ func (r *Reconciler) reconcileStatus(ctx context.Context, s *scope) error { newStatus.Replicas = int32(len(filteredMachines)) // TODO (v1beta2) Use new replica counters - newStatus.Deprecated = &clusterv1.MachineSetDeprecatedStatus{ - V1Beta1: &clusterv1.MachineSetV1Beta1DeprecatedStatus{}, + if newStatus.Deprecated == nil { + newStatus.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} + } + if newStatus.Deprecated.V1Beta1 == nil { + newStatus.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} } newStatus.Deprecated.V1Beta1.FullyLabeledReplicas = int32(fullyLabeledReplicasCount) newStatus.Deprecated.V1Beta1.ReadyReplicas = int32(readyReplicasCount) From ebbb5d5b6ec93976550351839b1f4c119a9e8e74 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Tue, 8 Apr 2025 20:19:39 +0200 Subject: [PATCH 10/11] Always reset auto converted conditions --- internal/apis/core/v1alpha3/conversion.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/internal/apis/core/v1alpha3/conversion.go b/internal/apis/core/v1alpha3/conversion.go index 8df703822828..c887f395eb4b 100644 --- a/internal/apis/core/v1alpha3/conversion.go +++ b/internal/apis/core/v1alpha3/conversion.go @@ -35,6 +35,10 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha3 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha3), failureReason and failureMessage to the deprecated field. if src.Status.Conditions != nil || src.Status.FailureReason != nil || src.Status.FailureMessage != nil { dst.Status.Deprecated = &clusterv1.ClusterDeprecatedStatus{} @@ -112,6 +116,10 @@ func (src *Machine) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha3 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha3), failureReason and failureMessage to the deprecated field. if src.Status.Conditions != nil || src.Status.FailureReason != nil || src.Status.FailureMessage != nil { dst.Status.Deprecated = &clusterv1.MachineDeprecatedStatus{} @@ -177,6 +185,10 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha3 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move failureReason, failureMessage and replica counters to the deprecated field. dst.Status.Deprecated = &clusterv1.MachineSetDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineSetV1Beta1DeprecatedStatus{} @@ -245,6 +257,10 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha3 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move replica counters to the deprecated field. dst.Status.Deprecated = &clusterv1.MachineDeploymentDeprecatedStatus{} dst.Status.Deprecated.V1Beta1 = &clusterv1.MachineDeploymentV1Beta1DeprecatedStatus{} @@ -328,6 +344,10 @@ func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error { return err } + // Reset conditions from autogenerated conversions + // NOTE: v1alpha3 conditions should not be automatically be converted into v1beta2 conditions. + dst.Status.Conditions = nil + // Move legacy conditions (v1alpha3) to the deprecated field. if src.Status.Conditions != nil { dst.Status.Deprecated = &clusterv1.MachineHealthCheckDeprecatedStatus{} From 979c7d4cc8d14b137f23e0b2abba3cb6478ecb60 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Tue, 8 Apr 2025 21:21:12 +0200 Subject: [PATCH 11/11] Move KCP to the v1beta2 contract --- controlplane/kubeadm/config/crd/kustomization.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controlplane/kubeadm/config/crd/kustomization.yaml b/controlplane/kubeadm/config/crd/kustomization.yaml index d0a35c3f749c..6f5ad889d9ce 100644 --- a/controlplane/kubeadm/config/crd/kustomization.yaml +++ b/controlplane/kubeadm/config/crd/kustomization.yaml @@ -1,6 +1,6 @@ labels: - pairs: - cluster.x-k8s.io/v1beta1: v1beta2 + cluster.x-k8s.io/v1beta2: v1beta2 # This kustomization.yaml is not intended to be run by itself, # since it depends on service name and namespace that are out of this kustomize package.