in internal/controllers/reconciliation/reconstitution.go [72:110]
func (r *reconstitutionSource) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
logger := logr.FromContextOrDiscard(ctx)
comp := &apiv1.Composition{}
err := r.client.Get(ctx, req.NamespacedName, comp)
if errors.IsNotFound(err) {
r.cache.Purge(ctx, req.NamespacedName, nil)
return ctrl.Result{}, nil
}
if err != nil {
logger.Error(err, "failed to get composition")
return ctrl.Result{}, err
}
logger = logger.WithValues("compositionName", comp.Name, "compositionNamespace", comp.Namespace)
ctx = logr.NewContext(ctx, logger)
// The reconciliation controller assumes that the previous synthesis will be loaded first
filled, err := r.populateCache(ctx, comp, comp.Status.PreviousSynthesis)
if err != nil {
logger.Error(err, "failed to process previous state")
return ctrl.Result{}, err
}
if filled {
return ctrl.Result{Requeue: true}, nil
}
filled, err = r.populateCache(ctx, comp, comp.Status.CurrentSynthesis)
if err != nil {
logger.Error(err, "failed to process current state")
return ctrl.Result{}, err
}
if filled {
return ctrl.Result{Requeue: true}, nil
}
r.cache.Purge(ctx, req.NamespacedName, comp)
return ctrl.Result{}, nil
}