@@ -145,23 +145,7 @@ func (s *Service) reconcileCluster(ctx context.Context) error {
145145// computeCurrentStatusVersion returns the computed current EKS cluster kubernetes version. 
146146// The computation has awareness of the fact that EKS clusters only return a major.minor kubernetes version, 
147147// and returns a compatible version for te status according to the one the user specified in the spec. 
148- func  computeCurrentStatusVersion (specV  * string , clusterV  * string ) * string  {
149- 	specVersion  :=  "" 
150- 	if  specV  !=  nil  {
151- 		specVersion  =  * specV 
152- 	}
153- 
154- 	clusterVersion  :=  "" 
155- 	if  clusterV  !=  nil  {
156- 		clusterVersion  =  * clusterV 
157- 	}
158- 
159- 	// Ignore parsing errors as these are already validated by the kubebuilder validation and the AWS API. 
160- 	// Also specVersion might not be specified in the spec.Version for AWSManagedControlPlane, this results in a "0.0.0" version. 
161- 	// Also clusterVersion might not yet be returned by the AWS EKS API, as the cluster might still be initializing, this results in a "0.0.0" version. 
162- 	specSemverVersion , _  :=  semver .ParseTolerant (specVersion )
163- 	currentSemverVersion , _  :=  semver .ParseTolerant (clusterVersion )
164- 
148+ func  computeCurrentStatusVersion (clusterV  * string , specSemverVersion  semver.Version , currentSemverVersion  semver.Version ) * string  {
165149	// If AWS EKS API is not returning a version, set the status.Version to empty string. 
166150	if  currentSemverVersion .String () ==  "0.0.0"  {
167151		return  ptr .To ("" )
@@ -185,9 +169,27 @@ func computeCurrentStatusVersion(specV *string, clusterV *string) *string {
185169	return  clusterV 
186170}
187171
172+ // parseClusterVersionString parse a version string to semver version 
173+ // If the string cannot be parsed to semver, returning 0.0.0 
174+ func  parseClusterVersionString (str  * string ) semver.Version  {
175+ 	version  :=  "" 
176+ 	if  str  !=  nil  {
177+ 		version  =  * str 
178+ 	}
179+ 
180+ 	// Ignore parsing errors as these are already validated by the kubebuilder validation and the AWS API. 
181+ 	semverVersion , _  :=  semver .ParseTolerant (version )
182+ 	return  semverVersion 
183+ }
184+ 
188185func  (s  * Service ) setStatus (cluster  * ekstypes.Cluster ) error  {
186+ 	// specSemver might not be specified in the spec.Version for AWSManagedControlPlane, this results in a "0.0.0" version. 
187+ 	specSemver  :=  parseClusterVersionString (s .scope .ControlPlane .Spec .Version )
188+ 	// clusterSemver might not yet be returned by the AWS EKS API, as the cluster might still be initializing, this results in a "0.0.0" version. 
189+ 	clusterSemver  :=  parseClusterVersionString (cluster .Version )
190+ 
189191	// Set the current Kubernetes control plane version in the status. 
190- 	s .scope .ControlPlane .Status .Version  =  computeCurrentStatusVersion (s . scope . ControlPlane . Spec . Version , cluster . Version )
192+ 	s .scope .ControlPlane .Status .Version  =  computeCurrentStatusVersion (cluster . Version , specSemver ,  clusterSemver )
191193
192194	// Set the current cluster status in the control plane status. 
193195	switch  cluster .Status  {
@@ -209,6 +211,18 @@ func (s *Service) setStatus(cluster *ekstypes.Cluster) error {
209211			conditions .MarkFalse (s .scope .ControlPlane , ekscontrolplanev1 .EKSControlPlaneUpdatingCondition , "updated" , clusterv1 .ConditionSeverityInfo , "" )
210212			record .Eventf (s .scope .ControlPlane , "SuccessfulUpdateEKSControlPlane" , "Updated EKS control plane %s" , s .scope .KubernetesClusterName ())
211213		}
214+ 		if  s .scope .ControlPlane .Spec .UpgradePolicy  ==  ekscontrolplanev1 .UpgradePolicyStandard  && 
215+ 			(specSemver .Major  <  clusterSemver .Major  ||  specSemver .Minor  <  clusterSemver .Minor ) {
216+ 			s .scope .ControlPlane .Status .Ready  =  false 
217+ 			failureMsg  :=  fmt .Sprintf (
218+ 				"EKS control plane %s was automatically upgraded to version %s because %s is out of standard support. " + 
219+ 					"This can be fixed by bumping to the actual version of the cluster" ,
220+ 				s .scope .KubernetesClusterName (),
221+ 				clusterSemver .String (),
222+ 				specSemver .String (),
223+ 			)
224+ 			s .scope .ControlPlane .Status .FailureMessage  =  & failureMsg 
225+ 		}
212226		// TODO FailureReason 
213227	case  ekstypes .ClusterStatusCreating :
214228		s .scope .ControlPlane .Status .Ready  =  false 
0 commit comments