@@ -302,7 +302,7 @@ func newControlPlane(cluster *clusterv1.Cluster, tcp *controlplanev1.TalosContro
302
302
}
303
303
}
304
304
305
- func (r * TalosControlPlaneReconciler ) scaleDownControlPlane (ctx context.Context , cluster client.ObjectKey , cpName string , machines []clusterv1.Machine ) (ctrl.Result , error ) {
305
+ func (r * TalosControlPlaneReconciler ) scaleDownControlPlane (ctx context.Context , tcp * controlplanev1. TalosControlPlane , cluster client.ObjectKey , cpName string , machines []clusterv1.Machine ) (ctrl.Result , error ) {
306
306
if len (machines ) == 0 {
307
307
return ctrl.Result {}, fmt .Errorf ("no machines found" )
308
308
}
@@ -359,7 +359,7 @@ func (r *TalosControlPlaneReconciler) scaleDownControlPlane(ctx context.Context,
359
359
360
360
node := deleteMachine .Status .NodeRef
361
361
362
- c , err := r .talosconfigForMachines (ctx , deleteMachine )
362
+ c , err := r .talosconfigForMachines (ctx , tcp , deleteMachine )
363
363
if err != nil {
364
364
return ctrl.Result {RequeueAfter : 20 * time .Second }, err
365
365
}
@@ -525,8 +525,8 @@ func (r *TalosControlPlaneReconciler) bootControlPlane(ctx context.Context, clus
525
525
return ctrl.Result {Requeue : true }, nil
526
526
}
527
527
528
- func (r * TalosControlPlaneReconciler ) bootstrapCluster (ctx context.Context , cluster * clusterv1.Cluster , machines []clusterv1.Machine ) error {
529
- c , err := r .talosconfigForMachines (ctx , machines ... )
528
+ func (r * TalosControlPlaneReconciler ) bootstrapCluster (ctx context.Context , tcp * controlplanev1. TalosControlPlane , cluster * clusterv1.Cluster , machines []clusterv1.Machine ) error {
529
+ c , err := r .talosconfigForMachines (ctx , tcp , machines ... )
530
530
if err != nil {
531
531
return err
532
532
}
@@ -761,11 +761,11 @@ func (r *TalosControlPlaneReconciler) reconcileKubeconfig(ctx context.Context, c
761
761
func (r * TalosControlPlaneReconciler ) reconcileEtcdMembers (ctx context.Context , cluster * clusterv1.Cluster , tcp * controlplanev1.TalosControlPlane , machines []clusterv1.Machine ) (result ctrl.Result , err error ) {
762
762
var errs error
763
763
// Audit the etcd member list to remove any nodes that no longer exist
764
- if err := r .auditEtcd (ctx , util .ObjectKey (cluster ), tcp .Name ); err != nil {
764
+ if err := r .auditEtcd (ctx , tcp , util .ObjectKey (cluster ), tcp .Name ); err != nil {
765
765
errs = kerrors .NewAggregate ([]error {errs , err })
766
766
}
767
767
768
- if err := r .etcdHealthcheck (ctx , cluster , machines ); err != nil {
768
+ if err := r .etcdHealthcheck (ctx , tcp , cluster , machines ); err != nil {
769
769
conditions .MarkFalse (tcp , controlplanev1 .EtcdClusterHealthyCondition , controlplanev1 .EtcdClusterUnhealthyReason ,
770
770
clusterv1 .ConditionSeverityWarning , err .Error ())
771
771
errs = kerrors .NewAggregate ([]error {errs , err })
@@ -781,7 +781,7 @@ func (r *TalosControlPlaneReconciler) reconcileEtcdMembers(ctx context.Context,
781
781
}
782
782
783
783
func (r * TalosControlPlaneReconciler ) reconcileNodeHealth (ctx context.Context , cluster * clusterv1.Cluster , tcp * controlplanev1.TalosControlPlane , machines []clusterv1.Machine ) (result ctrl.Result , err error ) {
784
- if err := r .nodesHealthcheck (ctx , cluster , machines ); err != nil {
784
+ if err := r .nodesHealthcheck (ctx , tcp , cluster , machines ); err != nil {
785
785
reason := controlplanev1 .ControlPlaneComponentsInspectionFailedReason
786
786
787
787
if errors .Is (err , & errServiceUnhealthy {}) {
@@ -851,7 +851,7 @@ func (r *TalosControlPlaneReconciler) reconcileMachines(ctx context.Context, clu
851
851
return res , nil
852
852
}
853
853
854
- if err := r .ensureNodesBooted (ctx , cluster , machines ); err != nil {
854
+ if err := r .ensureNodesBooted (ctx , controlPlane . TCP , cluster , machines ); err != nil {
855
855
logger .Info ("waiting for all nodes to finish boot sequence" , "error" , err )
856
856
857
857
return ctrl.Result {RequeueAfter : 10 * time .Second }, nil
@@ -865,7 +865,7 @@ func (r *TalosControlPlaneReconciler) reconcileMachines(ctx context.Context, clu
865
865
866
866
logger .Info ("scaling down control plane" , "Desired" , desiredReplicas , "Existing" , numMachines )
867
867
868
- res , err = r .scaleDownControlPlane (ctx , util .ObjectKey (cluster ), controlPlane .TCP .Name , machines )
868
+ res , err = r .scaleDownControlPlane (ctx , tcp , util .ObjectKey (cluster ), controlPlane .TCP .Name , machines )
869
869
if err != nil {
870
870
if res .Requeue || res .RequeueAfter > 0 {
871
871
logger .Info ("failed to scale down control plane" , "error" , err )
@@ -876,8 +876,13 @@ func (r *TalosControlPlaneReconciler) reconcileMachines(ctx context.Context, clu
876
876
877
877
return res , err
878
878
default :
879
- if ! tcp .Status .Bootstrapped && reflect .ValueOf (tcp .Spec .ControlPlaneConfig .InitConfig ).IsZero () {
880
- if err := r .bootstrapCluster (ctx , cluster , machines ); err != nil {
879
+ if ! reflect .ValueOf (tcp .Spec .ControlPlaneConfig .InitConfig ).IsZero () {
880
+ tcp .Status .Bootstrapped = true
881
+ conditions .MarkTrue (tcp , controlplanev1 .MachinesBootstrapped )
882
+ }
883
+
884
+ if ! tcp .Status .Bootstrapped {
885
+ if err := r .bootstrapCluster (ctx , tcp , cluster , machines ); err != nil {
881
886
conditions .MarkFalse (tcp , controlplanev1 .MachinesBootstrapped , controlplanev1 .WaitingForTalosBootReason , clusterv1 .ConditionSeverityInfo , err .Error ())
882
887
883
888
logger .Info ("bootstrap failed, retrying in 20 seconds" , "error" , err )
0 commit comments