@@ -55,7 +55,6 @@ import (
5555	"sigs.k8s.io/cluster-api/util" 
5656	capiannotations "sigs.k8s.io/cluster-api/util/annotations" 
5757	"sigs.k8s.io/cluster-api/util/conditions" 
58- 	"sigs.k8s.io/cluster-api/util/patch" 
5958	"sigs.k8s.io/cluster-api/util/predicates" 
6059)
6160
@@ -166,24 +165,6 @@ func (r *AWSClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
166165	}
167166
168167	log  =  log .WithValues ("cluster" , klog .KObj (cluster ))
169- 	helper , err  :=  patch .NewHelper (awsCluster , r .Client )
170- 	if  err  !=  nil  {
171- 		return  reconcile.Result {}, errors .Wrap (err , "failed to init patch helper" )
172- 	}
173- 
174- 	defer  func () {
175- 		e  :=  helper .Patch (
176- 			context .TODO (),
177- 			awsCluster ,
178- 			patch.WithOwnedConditions {Conditions : []clusterv1.ConditionType {
179- 				infrav1 .PrincipalCredentialRetrievedCondition ,
180- 				infrav1 .PrincipalUsageAllowedCondition ,
181- 				infrav1 .LoadBalancerReadyCondition ,
182- 			}})
183- 		if  e  !=  nil  {
184- 			fmt .Println (e .Error ())
185- 		}
186- 	}()
187168
188169	// Create the scope. 
189170	clusterScope , err  :=  scope .NewClusterScope (scope.ClusterScopeParams {
@@ -274,10 +255,11 @@ func (r *AWSClusterReconciler) reconcileNormal(clusterScope *scope.ClusterScope)
274255	awsCluster  :=  clusterScope .AWSCluster 
275256
276257	// If the AWSCluster doesn't have our finalizer, add it. 
277- 	controllerutil .AddFinalizer (awsCluster , infrav1 .ClusterFinalizer )
278- 	// Register the finalizer immediately to avoid orphaning AWS resources on delete 
279- 	if  err  :=  clusterScope .PatchObject (); err  !=  nil  {
280- 		return  reconcile.Result {}, err 
258+ 	if  controllerutil .AddFinalizer (awsCluster , infrav1 .ClusterFinalizer ) {
259+ 		// Register the finalizer immediately to avoid orphaning AWS resources on delete 
260+ 		if  err  :=  clusterScope .PatchObject (); err  !=  nil  {
261+ 			return  reconcile.Result {}, err 
262+ 		}
281263	}
282264
283265	ec2Service  :=  r .getEC2Service (clusterScope )
0 commit comments