@@ -165,7 +165,7 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
165
165
if kustomization .Spec .Suspend {
166
166
msg := "Kustomization is suspended, skipping reconciliation"
167
167
kustomization = kustomizev1 .KustomizationNotReady (kustomization , "" , meta .SuspendedReason , msg )
168
- if err := r .Status (). Update ( ctx , & kustomization ); err != nil {
168
+ if err := r .updateStatus ( ctx , req , kustomization . Status ); err != nil {
169
169
log .Error (err , "unable to update status" )
170
170
return ctrl.Result {Requeue : true }, err
171
171
}
@@ -185,7 +185,7 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
185
185
186
186
// set the reconciliation status to progressing
187
187
kustomization = kustomizev1 .KustomizationProgressing (kustomization )
188
- if err := r .Status (). Update ( ctx , & kustomization ); err != nil {
188
+ if err := r .updateStatus ( ctx , req , kustomization . Status ); err != nil {
189
189
log .Error (err , "unable to update status to progressing" )
190
190
return ctrl.Result {Requeue : true }, err
191
191
}
@@ -197,8 +197,8 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
197
197
if apierrors .IsNotFound (err ) {
198
198
msg := "Source not found"
199
199
kustomization = kustomizev1 .KustomizationNotReady (kustomization , "" , kustomizev1 .ArtifactFailedReason , msg )
200
- if err := r .Status (). Update ( ctx , & kustomization ); err != nil {
201
- log .Error (err , "unable to update status" )
200
+ if err := r .updateStatus ( ctx , req , kustomization . Status ); err != nil {
201
+ log .Error (err , "unable to update status for source not found " )
202
202
return ctrl.Result {Requeue : true }, err
203
203
}
204
204
r .recordReadiness (kustomization , false )
@@ -214,8 +214,8 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
214
214
if source .GetArtifact () == nil {
215
215
msg := "Source is not ready, artifact not found"
216
216
kustomization = kustomizev1 .KustomizationNotReady (kustomization , "" , kustomizev1 .ArtifactFailedReason , msg )
217
- if err := r .Status (). Update ( ctx , & kustomization ); err != nil {
218
- log .Error (err , "unable to update status" )
217
+ if err := r .updateStatus ( ctx , req , kustomization . Status ); err != nil {
218
+ log .Error (err , "unable to update status for artifact not found " )
219
219
return ctrl.Result {Requeue : true }, err
220
220
}
221
221
r .recordReadiness (kustomization , false )
@@ -229,8 +229,8 @@ func (r *KustomizationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
229
229
if err := r .checkDependencies (kustomization ); err != nil {
230
230
kustomization = kustomizev1 .KustomizationNotReady (
231
231
kustomization , source .GetArtifact ().Revision , meta .DependencyNotReadyReason , err .Error ())
232
- if err := r .Status (). Update ( ctx , & kustomization ); err != nil {
233
- log .Error (err , "unable to update status" )
232
+ if err := r .updateStatus ( ctx , req , kustomization . Status ); err != nil {
233
+ log .Error (err , "unable to update status for dependency not ready " )
234
234
return ctrl.Result {Requeue : true }, err
235
235
}
236
236
// we can't rely on exponential backoff because it will prolong the execution too much,
@@ -1039,8 +1039,10 @@ func (r *KustomizationReconciler) updateStatus(ctx context.Context, req ctrl.Req
1039
1039
return err
1040
1040
}
1041
1041
1042
+ patch := client .MergeFrom (kustomization .DeepCopy ())
1042
1043
kustomization .Status = newStatus
1043
- return r .Status ().Update (ctx , & kustomization )
1044
+
1045
+ return r .Status ().Patch (ctx , & kustomization , patch )
1044
1046
}
1045
1047
1046
1048
func containsString (slice []string , s string ) bool {
0 commit comments