@@ -278,6 +278,14 @@ type Scope struct {
278
278
ControlPlane * controlplanev1.RKE2ControlPlane
279
279
}
280
280
281
+ func (s * Scope ) getDesiredVersion () string {
282
+ if s .Machine .Spec .Version != nil && bsutil .IsRKE2Version (* s .Machine .Spec .Version ) {
283
+ return * s .Machine .Spec .Version
284
+ }
285
+
286
+ return s .Config .Spec .AgentConfig .Version
287
+ }
288
+
281
289
// SetupWithManager sets up the controller with the Manager.
282
290
func (r * RKE2ConfigReconciler ) SetupWithManager (mgr ctrl.Manager ) error {
283
291
if r .RKE2InitLock == nil {
@@ -363,6 +371,7 @@ func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context,
363
371
AgentConfig : scope .Config .Spec .AgentConfig ,
364
372
Ctx : ctx ,
365
373
Client : r .Client ,
374
+ Version : scope .getDesiredVersion (),
366
375
})
367
376
if err != nil {
368
377
return ctrl.Result {}, err
@@ -417,7 +426,7 @@ func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context,
417
426
PreRKE2Commands : scope .Config .Spec .PreRKE2Commands ,
418
427
PostRKE2Commands : scope .Config .Spec .PostRKE2Commands ,
419
428
ConfigFile : initConfigFile ,
420
- RKE2Version : scope .Config . Spec . AgentConfig . Version ,
429
+ RKE2Version : scope .getDesiredVersion () ,
421
430
WriteFiles : files ,
422
431
NTPServers : ntpServers ,
423
432
AdditionalCloudInit : scope .Config .Spec .AgentConfig .AdditionalUserData .Config ,
@@ -567,6 +576,7 @@ func (r *RKE2ConfigReconciler) joinControlplane(ctx context.Context, scope *Scop
567
576
AgentConfig : scope .Config .Spec .AgentConfig ,
568
577
Ctx : ctx ,
569
578
Client : r .Client ,
579
+ Version : scope .getDesiredVersion (),
570
580
},
571
581
)
572
582
if err != nil {
@@ -627,7 +637,7 @@ func (r *RKE2ConfigReconciler) joinControlplane(ctx context.Context, scope *Scop
627
637
PreRKE2Commands : scope .Config .Spec .PreRKE2Commands ,
628
638
PostRKE2Commands : scope .Config .Spec .PostRKE2Commands ,
629
639
ConfigFile : initConfigFile ,
630
- RKE2Version : scope .Config . Spec . AgentConfig . Version ,
640
+ RKE2Version : scope .getDesiredVersion () ,
631
641
WriteFiles : files ,
632
642
NTPServers : ntpServers ,
633
643
AdditionalCloudInit : scope .Config .Spec .AgentConfig .AdditionalUserData .Config ,
@@ -700,6 +710,7 @@ func (r *RKE2ConfigReconciler) joinWorker(ctx context.Context, scope *Scope) (re
700
710
Client : r .Client ,
701
711
CloudProviderName : scope .ControlPlane .Spec .ServerConfig .CloudProviderName ,
702
712
CloudProviderConfigMap : scope .ControlPlane .Spec .ServerConfig .CloudProviderConfigMap ,
713
+ Version : scope .getDesiredVersion (),
703
714
})
704
715
if err != nil {
705
716
return ctrl.Result {}, err
@@ -738,7 +749,7 @@ func (r *RKE2ConfigReconciler) joinWorker(ctx context.Context, scope *Scope) (re
738
749
CISEnabled : scope .Config .Spec .AgentConfig .CISProfile != "" ,
739
750
PostRKE2Commands : scope .Config .Spec .PostRKE2Commands ,
740
751
ConfigFile : wkJoinConfigFile ,
741
- RKE2Version : scope .Config . Spec . AgentConfig . Version ,
752
+ RKE2Version : scope .getDesiredVersion () ,
742
753
WriteFiles : files ,
743
754
NTPServers : ntpServers ,
744
755
AdditionalCloudInit : scope .Config .Spec .AgentConfig .AdditionalUserData .Config ,
0 commit comments