From aa9da94c1ff43c485b8e2308b9912bc260f6f7b4 Mon Sep 17 00:00:00 2001 From: Chris Werner Rau Date: Mon, 20 Oct 2025 16:32:37 +0200 Subject: [PATCH] chore: migrate to new CAPI contract --- api/v1alpha1/hostedcontrolplane_types.go | 11 ++++++++-- api/v1alpha1/zz_generated.deepcopy.go | 21 +++++++++++++++++++ .../lifecycle_phases_test.go | 2 +- .../apiserverresources/apiserverresources.go | 1 + pkg/reconcilers/workload/reconciler.go | 3 ++- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/api/v1alpha1/hostedcontrolplane_types.go b/api/v1alpha1/hostedcontrolplane_types.go index 9939509..67927e2 100644 --- a/api/v1alpha1/hostedcontrolplane_types.go +++ b/api/v1alpha1/hostedcontrolplane_types.go @@ -17,7 +17,7 @@ import ( //+kubebuilder:resource:path=hostedcontrolplanes,scope=Namespaced,categories=cluster-api,shortName=hcp //+kubebuilder:subresource:status //+kubebuilder:storageversion -//+kubebuilder:printcolumn:name="Initialized",type=boolean,JSONPath=`.status.initialized` +//+kubebuilder:printcolumn:name="Initialized",type=boolean,JSONPath=`.status.initialization.controlPlaneInitialized` //+kubebuilder:printcolumn:name="API Server Available",type=string,JSONPath=`.status.conditions[?(@.type == "Ready")].status` //+kubebuilder:printcolumn:name="Replicas",type=integer,JSONPath=`.spec.replicas` //+kubebuilder:printcolumn:name="Ready",type=integer,JSONPath=`.status.readyReplicas` @@ -243,6 +243,8 @@ type HostedControlPlaneStatus struct { //+kubebuilder:validation:Optional UpdatedReplicas int32 `json:"updatedReplicas,omitempty"` //+kubebuilder:validation:Optional + UpToDateReplicas int32 `json:"upToDateReplicas,omitempty"` + //+kubebuilder:validation:Optional ReadyReplicas int32 `json:"readyReplicas,omitempty"` //+kubebuilder:validation:Optional UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"` @@ -251,7 +253,7 @@ type HostedControlPlaneStatus struct { // https://cluster-api.sigs.k8s.io/developer/providers/contracts/control-plane //+kubebuilder:validation:Optional - Initialized bool `json:"initialized"` + Initialization HostedControlPlaneInitializationStatus `json:"initialization,omitempty"` //+kubebuilder:validation:Optional Ready bool `json:"ready"` //+kubebuilder:validation:Optional @@ -259,6 +261,11 @@ type HostedControlPlaneStatus struct { ExternalManagedControlPlane *bool `json:"externalManagedControlPlane"` } +type HostedControlPlaneInitializationStatus struct { + //+kubebuilder:validation:Optional + ControlPlaneInitialized *bool `json:"controlPlaneInitialized,omitempty"` +} + //+kubebuilder:object:root=true type HostedControlPlaneList struct { diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index fca7ac5..8cf7f40 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -307,6 +307,26 @@ func (in *HostedControlPlaneDeployment) DeepCopy() *HostedControlPlaneDeployment return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostedControlPlaneInitializationStatus) DeepCopyInto(out *HostedControlPlaneInitializationStatus) { + *out = *in + if in.ControlPlaneInitialized != nil { + in, out := &in.ControlPlaneInitialized, &out.ControlPlaneInitialized + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostedControlPlaneInitializationStatus. +func (in *HostedControlPlaneInitializationStatus) DeepCopy() *HostedControlPlaneInitializationStatus { + if in == nil { + return nil + } + out := new(HostedControlPlaneInitializationStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostedControlPlaneInlineSpec) DeepCopyInto(out *HostedControlPlaneInlineSpec) { *out = *in @@ -395,6 +415,7 @@ func (in *HostedControlPlaneStatus) DeepCopyInto(out *HostedControlPlaneStatus) out.ETCDVolumeUsage = in.ETCDVolumeUsage.DeepCopy() in.ETCDLastBackupTime.DeepCopyInto(&out.ETCDLastBackupTime) in.ETCDNextBackupTime.DeepCopyInto(&out.ETCDNextBackupTime) + in.Initialization.DeepCopyInto(&out.Initialization) if in.ExternalManagedControlPlane != nil { in, out := &in.ExternalManagedControlPlane, &out.ExternalManagedControlPlane *out = new(bool) diff --git a/pkg/hostedcontrolplane/lifecycle_phases_test.go b/pkg/hostedcontrolplane/lifecycle_phases_test.go index a4d22f3..86df7a4 100644 --- a/pkg/hostedcontrolplane/lifecycle_phases_test.go +++ b/pkg/hostedcontrolplane/lifecycle_phases_test.go @@ -1392,7 +1392,7 @@ func TestHostedControlPlane_FullLifecycle(t *testing.T) { return condition.Type != capiv2.PausedCondition && condition.Status != metav1.ConditionTrue })).To(BeEmpty()) g.Expect(hcp.Status.Ready).To(BeTrue()) - g.Expect(hcp.Status.Initialized).To(BeTrue()) + g.Expect(hcp.Status.Initialization.ControlPlaneInitialized).To(PointTo(BeTrue())) // Check that major conditions exist majorConditions := []string{ diff --git a/pkg/reconcilers/apiserverresources/apiserverresources.go b/pkg/reconcilers/apiserverresources/apiserverresources.go index 4546524..46c0104 100644 --- a/pkg/reconcilers/apiserverresources/apiserverresources.go +++ b/pkg/reconcilers/apiserverresources/apiserverresources.go @@ -409,6 +409,7 @@ func (arr *apiServerResourcesReconciler) reconcileAPIServerDeployment( hostedControlPlane.Status.UnavailableReplicas = deployment.Status.UnavailableReplicas hostedControlPlane.Status.ReadyReplicas = deployment.Status.ReadyReplicas hostedControlPlane.Status.UpdatedReplicas = deployment.Status.UpdatedReplicas + hostedControlPlane.Status.UpToDateReplicas = deployment.Status.UpdatedReplicas return ready, nil } }, diff --git a/pkg/reconcilers/workload/reconciler.go b/pkg/reconcilers/workload/reconciler.go index aa32a4c..4f6fccc 100644 --- a/pkg/reconcilers/workload/reconciler.go +++ b/pkg/reconcilers/workload/reconciler.go @@ -19,6 +19,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" bootstrapapi "k8s.io/cluster-bootstrap/token/api" konstants "k8s.io/kubernetes/cmd/kubeadm/app/constants" + "k8s.io/utils/ptr" capiv2 "sigs.k8s.io/cluster-api/api/core/v1beta2" "sigs.k8s.io/cluster-api/util/conditions" ) @@ -266,7 +267,7 @@ func (wr *workloadClusterReconciler) ReconcileWorkloadClusterResources( } } - hostedControlPlane.Status.Initialized = true + hostedControlPlane.Status.Initialization.ControlPlaneInitialized = ptr.To(true) return "", nil },