in internal/handler/operation.go [97:126]
func (o *OperationHandler) EnsureAllAppsAreReady(ctx context.Context) (reconciler.OperationResult, error) {
o.logger.V(1).Info("Operation EnsureAllAppsAreReady")
if o.phaseIn(v1alpha1.OperationPhaseDeleted, v1alpha1.OperationPhaseDeleting) {
return reconciler.ContinueProcessing()
}
if o.phaseIn(v1alpha1.OperationPhaseEmpty) {
o.logger.V(1).Info("initializing operation status")
o.oputils.ClearConditions(o.operation)
o.operation.Status.OperationID = o.oputils.NewOperationId()
}
if o.phaseIn(v1alpha1.OperationPhaseReconciling) {
err := o.reconcilingApplications(ctx)
if err != nil {
o.logger.Error(err, "reconciling applications failed")
o.recorder.Event(o.operation, "Warning", "ReconcileFailed", "Failed to reconcile deployments")
return reconciler.RequeueWithError(err)
}
o.operation.Status.Phase = v1alpha1.OperationPhaseReconciled
return reconciler.RequeueOnErrorOrStop(o.client.Status().Update(ctx, o.operation))
}
// check the diff between the expected and actual apps, set phase to reconciling and requeue if changes
expectedCacheKey := o.cacheutils.NewCacheKeyFromApplications(o.operation.Spec.Applications)
if o.operation.Status.CacheKey != expectedCacheKey {
o.operation.Status.CacheKey = expectedCacheKey
o.operation.Status.Phase = v1alpha1.OperationPhaseReconciling
}
return reconciler.RequeueOnErrorOrContinue(o.client.Status().Update(ctx, o.operation))
}