@@ -404,6 +404,13 @@ func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context,
404404 registrationAddress = scope .ControlPlane .Spec .RegistrationAddress
405405 }
406406
407+ version , err := scope .GetDesiredVersion ()
408+ if err != nil {
409+ scope .Logger .Error (err , "RKE2 version does not seem to be set" )
410+
411+ return ctrl.Result {}, err
412+ }
413+
407414 configStruct , configFiles , err := rke2 .GenerateInitControlPlaneConfig (
408415 rke2.ServerConfigOpts {
409416 Cluster : * scope .Cluster ,
@@ -414,7 +421,7 @@ func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context,
414421 AgentConfig : scope .Config .Spec .AgentConfig ,
415422 Ctx : ctx ,
416423 Client : r .Client ,
417- Version : scope . GetDesiredVersion () ,
424+ Version : version ,
418425 })
419426 if err != nil {
420427 return ctrl.Result {}, err
@@ -476,7 +483,7 @@ func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context,
476483 PreRKE2Commands : scope .Config .Spec .PreRKE2Commands ,
477484 PostRKE2Commands : scope .Config .Spec .PostRKE2Commands ,
478485 ConfigFile : initConfigFile ,
479- RKE2Version : scope . GetDesiredVersion () ,
486+ RKE2Version : version ,
480487 WriteFiles : files ,
481488 NTPServers : ntpServers ,
482489 AdditionalCloudInit : scope .Config .Spec .AgentConfig .AdditionalUserData .Config ,
@@ -638,6 +645,13 @@ func (r *RKE2ConfigReconciler) joinControlplane(ctx context.Context, scope *Scop
638645 return ctrl.Result {RequeueAfter : DefaultRequeueAfter }, nil
639646 }
640647
648+ version , err := scope .GetDesiredVersion ()
649+ if err != nil {
650+ scope .Logger .Error (err , "RKE2 version does not seem to be set" )
651+
652+ return ctrl.Result {}, err
653+ }
654+
641655 configStruct , configFiles , err := rke2 .GenerateJoinControlPlaneConfig (
642656 rke2.ServerConfigOpts {
643657 Cluster : * scope .Cluster ,
@@ -648,7 +662,7 @@ func (r *RKE2ConfigReconciler) joinControlplane(ctx context.Context, scope *Scop
648662 AgentConfig : scope .Config .Spec .AgentConfig ,
649663 Ctx : ctx ,
650664 Client : r .Client ,
651- Version : scope . GetDesiredVersion () ,
665+ Version : version ,
652666 },
653667 )
654668 if err != nil {
@@ -713,7 +727,7 @@ func (r *RKE2ConfigReconciler) joinControlplane(ctx context.Context, scope *Scop
713727 PreRKE2Commands : scope .Config .Spec .PreRKE2Commands ,
714728 PostRKE2Commands : scope .Config .Spec .PostRKE2Commands ,
715729 ConfigFile : initConfigFile ,
716- RKE2Version : scope . GetDesiredVersion () ,
730+ RKE2Version : version ,
717731 WriteFiles : files ,
718732 NTPServers : ntpServers ,
719733 AdditionalCloudInit : scope .Config .Spec .AgentConfig .AdditionalUserData .Config ,
@@ -774,6 +788,13 @@ func (r *RKE2ConfigReconciler) joinWorker(ctx context.Context, scope *Scope) (re
774788 return ctrl.Result {RequeueAfter : DefaultRequeueAfter }, nil
775789 }
776790
791+ version , err := scope .GetDesiredVersion ()
792+ if err != nil {
793+ scope .Logger .Error (err , "RKE2 version does not seem to be set" )
794+
795+ return ctrl.Result {}, err
796+ }
797+
777798 configStruct , configFiles , err := rke2 .GenerateWorkerConfig (
778799 rke2.AgentConfigOpts {
779800 ServerURL : fmt .Sprintf (serverURLFormat , scope .ControlPlane .Status .AvailableServerIPs [0 ], registrationPort ),
@@ -783,7 +804,7 @@ func (r *RKE2ConfigReconciler) joinWorker(ctx context.Context, scope *Scope) (re
783804 Client : r .Client ,
784805 CloudProviderName : scope .ControlPlane .Spec .ServerConfig .CloudProviderName ,
785806 CloudProviderConfigMap : scope .ControlPlane .Spec .ServerConfig .CloudProviderConfigMap ,
786- Version : scope . GetDesiredVersion () ,
807+ Version : version ,
787808 })
788809 if err != nil {
789810 return ctrl.Result {}, err
@@ -826,7 +847,7 @@ func (r *RKE2ConfigReconciler) joinWorker(ctx context.Context, scope *Scope) (re
826847 CISEnabled : scope .Config .Spec .AgentConfig .CISProfile != "" ,
827848 PostRKE2Commands : scope .Config .Spec .PostRKE2Commands ,
828849 ConfigFile : wkJoinConfigFile ,
829- RKE2Version : scope . GetDesiredVersion () ,
850+ RKE2Version : version ,
830851 WriteFiles : files ,
831852 NTPServers : ntpServers ,
832853 AdditionalCloudInit : scope .Config .Spec .AgentConfig .AdditionalUserData .Config ,
0 commit comments