Skip to content

Commit 58ffa7d

Browse files
committed
Ensure consistent resource status if create errors
1 parent 8262f05 commit 58ffa7d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

internal/controller/appwrapper/resource_management.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,17 @@ func (r *AppWrapperReconciler) createComponent(ctx context.Context, aw *workload
317317
}
318318
// fall through. This is not actually an error. The object already exists and the correct appwrapper owns it.
319319
} else {
320+
// resource not actually created; patch status to reflect that
321+
meta.SetStatusCondition(&aw.Status.ComponentStatus[componentIdx].Conditions, metav1.Condition{
322+
Type: string(workloadv1beta2.ResourcesDeployed),
323+
Status: metav1.ConditionFalse,
324+
Reason: "ComponentCreationErrored",
325+
})
326+
if patchErr := r.Status().Patch(ctx, aw, client.MergeFrom(orig)); patchErr != nil {
327+
// ugh. Patch failed, so retry the create so we can get to a consistient state
328+
return patchErr, false
329+
}
330+
// return actual error
320331
return err, meta.IsNoMatchError(err) || apierrors.IsInvalid(err) // fatal
321332
}
322333
}

0 commit comments

Comments
 (0)