@@ -98,19 +98,15 @@ func (r *Reconciler) reconcileClusterShim(ctx context.Context, s *scope.Scope) e
98
98
// creating InfrastructureCluster/ControlPlane objects and updating the Cluster with the
99
99
// references to above objects.
100
100
if s .Current .InfrastructureCluster == nil || s .Current .ControlPlane .Object == nil {
101
- // Note: we are using Patch instead of create for ensuring consistency in managedFields for the entire controller
102
- // but in this case it isn't strictly necessary given that we are not using server side apply for modifying the
103
- // object afterwards.
104
- helper , err := r .patchHelperFactory (ctx , nil , shim )
105
- if err != nil {
106
- return errors .Wrap (err , "failed to create the patch helper for the cluster shim object" )
107
- }
108
- if err := helper .Patch (ctx ); err != nil {
109
- return errors .Wrap (err , "failed to create the cluster shim object" )
110
- }
111
-
112
- if err := r .APIReader .Get (ctx , client .ObjectKeyFromObject (shim ), shim ); err != nil {
113
- return errors .Wrap (err , "get shim after creation" )
101
+ // Given that the cluster shim is a temporary object which is only modified
102
+ // by this controller, it is not necessary to use the SSA patch helper.
103
+ if err := r .Client .Create (ctx , shim ); err != nil {
104
+ if ! apierrors .IsAlreadyExists (err ) {
105
+ return errors .Wrap (err , "failed to create the cluster shim object" )
106
+ }
107
+ if err := r .Client .Get (ctx , client .ObjectKeyFromObject (shim ), shim ); err != nil {
108
+ return errors .Wrapf (err , "failed to read the cluster shim object" )
109
+ }
114
110
}
115
111
116
112
// Enforce type meta back given that it gets blanked out by Get.
@@ -656,7 +652,7 @@ func (r *Reconciler) reconcileReferencedObject(ctx context.Context, in reconcile
656
652
// If there is no current object, create it.
657
653
if in .current == nil {
658
654
log .Infof ("Creating %s" , tlog.KObj {Obj : in .desired })
659
- helper , err := r .patchHelperFactory (ctx , nil , in .desired )
655
+ helper , err := r .patchHelperFactory (ctx , nil , in .desired , structuredmerge . IgnorePaths ( in . ignorePaths ) )
660
656
if err != nil {
661
657
return errors .Wrap (createErrorWithoutObjectName (err , in .desired ), "failed to create patch helper" )
662
658
}
0 commit comments