Skip to content

Commit 9ff1dff

Browse files
Add initialization to Cluster status
1 parent 296cbc0 commit 9ff1dff

File tree

47 files changed

+385
-235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+385
-235
lines changed

api/v1beta1/conversion.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ func Convert_v1beta2_ClusterStatus_To_v1beta1_ClusterStatus(in *clusterv1.Cluste
172172
out.FailureMessage = in.Deprecated.V1Beta1.FailureMessage
173173
}
174174

175+
// Move initialization to old fields
176+
if in.Initialization != nil {
177+
out.ControlPlaneReady = in.Initialization.ControlPlaneInitialized
178+
out.InfrastructureReady = in.Initialization.InfrastructureProvisioned
179+
}
180+
175181
// Move new conditions (v1beta2), controlPlane and workers counters to the v1beta2 field.
176182
if in.Conditions == nil && in.ControlPlane == nil && in.Workers == nil {
177183
return nil
@@ -231,6 +237,15 @@ func Convert_v1beta1_ClusterStatus_To_v1beta2_ClusterStatus(in *ClusterStatus, o
231237
}
232238
}
233239

240+
// Move ControlPlaneReady and InfrastructureReady to Initialization
241+
if in.ControlPlaneReady || in.InfrastructureReady {
242+
if out.Initialization == nil {
243+
out.Initialization = &clusterv1.ClusterInitializationStatus{}
244+
}
245+
out.Initialization.ControlPlaneInitialized = in.ControlPlaneReady
246+
out.Initialization.InfrastructureProvisioned = in.InfrastructureReady
247+
}
248+
234249
// Move legacy conditions (v1beta1), FailureReason and FailureMessage to the deprecated field.
235250
if in.Conditions == nil && in.FailureReason == nil && in.FailureMessage == nil {
236251
return nil

api/v1beta1/conversion_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ func hubClusterStatus(in *clusterv1.ClusterStatus, c fuzz.Continue) {
8383
in.Deprecated = nil
8484
}
8585
}
86+
87+
// Drop empty structs with only omit empty fields.
88+
if in.Initialization != nil {
89+
if reflect.DeepEqual(in.Initialization, &clusterv1.ClusterInitializationStatus{}) {
90+
in.Initialization = nil
91+
}
92+
}
8693
}
8794

8895
func spokeClusterStatus(in *ClusterStatus, c fuzz.Continue) {

api/v1beta1/zz_generated.conversion.go

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

api/v1beta2/cluster_types.go

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,11 @@ type ClusterStatus struct {
965965
// +kubebuilder:validation:MaxItems=32
966966
Conditions []metav1.Condition `json:"conditions,omitempty"`
967967

968+
// initialization provides observations of the Cluster initialization process.
969+
// NOTE: Fields in this struct are part of the Cluster API contract and are used to orchestrate initial Cluster provisioning.
970+
// +optional
971+
Initialization *ClusterInitializationStatus `json:"initialization,omitempty"`
972+
968973
// controlPlane groups all the observations about Cluster's ControlPlane current state.
969974
// +optional
970975
ControlPlane *ClusterControlPlaneStatus `json:"controlPlane,omitempty"`
@@ -982,18 +987,6 @@ type ClusterStatus struct {
982987
// +kubebuilder:validation:Enum=Pending;Provisioning;Provisioned;Deleting;Failed;Unknown
983988
Phase string `json:"phase,omitempty"`
984989

985-
// infrastructureReady is the state of the infrastructure provider.
986-
// +optional
987-
InfrastructureReady bool `json:"infrastructureReady"`
988-
989-
// controlPlaneReady denotes if the control plane became ready during initial provisioning
990-
// to receive requests.
991-
// NOTE: this field is part of the Cluster API contract and it is used to orchestrate provisioning.
992-
// The value of this field is never updated after provisioning is completed. Please use conditions
993-
// to check the operational state of the control plane.
994-
// +optional
995-
ControlPlaneReady bool `json:"controlPlaneReady"`
996-
997990
// observedGeneration is the latest generation observed by the controller.
998991
// +optional
999992
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
@@ -1003,6 +996,27 @@ type ClusterStatus struct {
1003996
Deprecated *ClusterDeprecatedStatus `json:"deprecated,omitempty"`
1004997
}
1005998

999+
// ClusterInitializationStatus provides observations of the Cluster initialization process.
1000+
// NOTE: Fields in this struct are part of the Cluster API contract and are used to orchestrate initial Cluster provisioning.
1001+
1002+
// ClusterInitializationStatus provides observations of the Cluster initialization process.
1003+
type ClusterInitializationStatus struct {
1004+
// infrastructureProvisioned is true when the infrastructure provider reports that Cluster's infrastructure is fully provisioned.
1005+
// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate provisioning.
1006+
// The value of this field is never updated after provisioning is completed.
1007+
// +optional
1008+
InfrastructureProvisioned bool `json:"infrastructureProvisioned"`
1009+
1010+
// controlPlaneInitialized denotes when the control plane is functional enough to accept requests.
1011+
// This information is usually used as a signal for starting all the provisioning operations that depends on
1012+
// a functional API server, but do not require a full HA control plane to exists, like e.g. join worker Machines,
1013+
// install core addons like CNI, CPI, CSI etc.
1014+
// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate provisioning.
1015+
// The value of this field is never updated after initialization is completed.
1016+
// +optional
1017+
ControlPlaneInitialized bool `json:"controlPlaneInitialized"`
1018+
}
1019+
10061020
// ClusterDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version.
10071021
// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.
10081022
type ClusterDeprecatedStatus struct {

api/v1beta2/zz_generated.deepcopy.go

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

api/v1beta2/zz_generated.openapi.go

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

bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (r *KubeadmConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl
139139
builder.WithPredicates(
140140
predicates.All(mgr.GetScheme(), predicateLog,
141141
predicates.ResourceIsChanged(mgr.GetScheme(), predicateLog),
142-
predicates.ClusterPausedTransitionsOrInfrastructureReady(mgr.GetScheme(), predicateLog),
142+
predicates.ClusterPausedTransitionsOrInfrastructureProvisioned(mgr.GetScheme(), predicateLog),
143143
predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue),
144144
),
145145
),
@@ -291,8 +291,8 @@ func (r *KubeadmConfigReconciler) reconcile(ctx context.Context, scope *Scope, c
291291
return ctrl.Result{}, err
292292
}
293293
switch {
294-
// Wait for the infrastructure to be ready.
295-
case !cluster.Status.InfrastructureReady:
294+
// Wait for the infrastructure to be provisioned.
295+
case (cluster.Status.Initialization == nil || !cluster.Status.Initialization.InfrastructureProvisioned):
296296
log.Info("Cluster infrastructure is not ready, waiting")
297297
v1beta1conditions.MarkFalse(config, bootstrapv1.DataSecretAvailableV1Beta1Condition, bootstrapv1.WaitingForClusterInfrastructureV1Beta1Reason, clusterv1.ConditionSeverityInfo, "")
298298
conditions.Set(scope.Config, metav1.Condition{

0 commit comments

Comments
 (0)