-
Notifications
You must be signed in to change notification settings - Fork 98
chore: Print additional error message, if CheCluster controller faile… #2057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| // | ||
| // Copyright (c) 2019-2025 Red Hat, Inc. | ||
| // This program and the accompanying materials are made | ||
| // available under the terms of the Eclipse Public License 2.0 | ||
| // which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
| // | ||
| // SPDX-License-Identifier: EPL-2.0 | ||
| // | ||
| // Contributors: | ||
| // Red Hat, Inc. - initial API and implementation | ||
| // | ||
|
|
||
| package reconciler | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "reflect" | ||
| "strings" | ||
|
|
||
| "github.com/eclipse-che/che-operator/pkg/common/chetypes" | ||
| "github.com/pkg/errors" | ||
| "sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
| ) | ||
|
|
||
| // Reconcilable defines the interface for components that can be reconciled and finalized. | ||
| type Reconcilable interface { | ||
| // Reconcile performs a reconciliation step to ensure the desired state matches the actual state. | ||
| // Returns: | ||
| // - result: reconcile.Result indicating when to requeue (if needed) | ||
| // - done: true if reconciliation completed successfully, false if it needs to be retried | ||
| // - err: any error encountered during reconciliation | ||
| Reconcile(ctx *chetypes.DeployContext) (result reconcile.Result, done bool, err error) | ||
|
|
||
| // Finalize performs cleanup operations before the resource is deleted. | ||
| // All created resources should be removed, including: | ||
| // - finalizers | ||
| // - cluster scoped resources | ||
| // Returns true if finalization completed successfully, false otherwise. | ||
| // TODO make Finalize return error as well | ||
| Finalize(ctx *chetypes.DeployContext) (done bool) | ||
| } | ||
|
|
||
| // ReconcilerManager manages a collection of Reconcilable objects and executes them in order. | ||
| type ReconcilerManager struct { | ||
| reconcilers []Reconcilable | ||
| } | ||
|
|
||
| func NewReconcilerManager() *ReconcilerManager { | ||
| return &ReconcilerManager{ | ||
| reconcilers: make([]Reconcilable, 0), | ||
| } | ||
| } | ||
|
|
||
| func (r *ReconcilerManager) AddReconciler(reconciler Reconcilable) { | ||
| r.reconcilers = append(r.reconcilers, reconciler) | ||
| } | ||
|
|
||
| // ReconcileAll reconciles all registered reconcilers in the order they were added. | ||
| // The reconciliation process stops at the first reconciler that returns done=false, | ||
| // ensuring dependencies between reconcilers are respected. | ||
| func (r *ReconcilerManager) ReconcileAll(ctx *chetypes.DeployContext) (reconcile.Result, bool, error) { | ||
| for _, reconciler := range r.reconcilers { | ||
| result, done, err := reconciler.Reconcile(ctx) | ||
|
|
||
| // Stop reconciliation chain if current reconciler is not done | ||
| if !done { | ||
| if err != nil { | ||
| name := strings.Trim(reflect.TypeOf(reconciler).String(), "*") | ||
| return result, false, errors.Wrap(err, fmt.Sprintf("%s reconciliation failed", name)) | ||
| } else { | ||
| return result, false, nil | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return reconcile.Result{}, true, nil | ||
| } | ||
|
|
||
| // FinalizeAll invokes the Finalize method on all registered reconcilers. | ||
| // Unlike ReconcileAll, this method continues executing all finalizers even if one fails, | ||
| // ensuring all cleanup operations have a chance to run. | ||
| // Returns true if all finalizers completed successfully, false if any failed. | ||
| func (r *ReconcilerManager) FinalizeAll(ctx *chetypes.DeployContext) (doneAll bool) { | ||
| doneAll = true | ||
|
|
||
| for _, reconciler := range r.reconcilers { | ||
| done := reconciler.Finalize(ctx) | ||
| doneAll = doneAll && done | ||
| } | ||
|
|
||
| return doneAll | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.