Skip to content

Commit

Permalink
k8s: continue console deletion if cluster not configured
Browse files Browse the repository at this point in the history
  • Loading branch information
alenkacz committed May 25, 2023
1 parent 57e2d9e commit 7604ccb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/go/k8s/controllers/redpanda/console_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ func (r *ConsoleReconciler) Reconcile(
return ctrl.Result{}, err
}

var consoleIsDeleting bool
if !console.GetDeletionTimestamp().IsZero() {
consoleIsDeleting = true
}

cluster, err := console.GetCluster(ctx, r.Client)
if err != nil {
// Create event instead of logging the error, so user can see in Console CR instead of checking logs in operator
Expand All @@ -111,16 +116,20 @@ func (r *ConsoleReconciler) Reconcile(
corev1.EventTypeWarning, ClusterNotFoundEvent,
"Unable to reconcile Console as the referenced Cluster %s is not found or is being deleted", console.GetClusterRef(),
)
case errors.Is(err, redpandav1alpha1.ErrClusterNotConfigured):
case errors.Is(err, redpandav1alpha1.ErrClusterNotConfigured) && consoleIsDeleting:
r.Log.Info("cluster %s is not yet configured but console is deleting -> proceeding with the delete.", console.GetClusterRef())
case errors.Is(err, redpandav1alpha1.ErrClusterNotConfigured) && !consoleIsDeleting:
r.EventRecorder.Eventf(
console,
corev1.EventTypeWarning, ClusterNotConfiguredEvent,
"Unable to reconcile Console as the referenced Cluster %s is not yet configured", console.GetClusterRef(),
)
// When Cluster will be configured, Console will receive a notification trigger
return ctrl.Result{}, nil

default:
return ctrl.Result{}, err
}
return ctrl.Result{}, err
}

r.Log.V(logger.DebugLevel).Info("console", "observed generation", console.Status.ObservedGeneration, "generation", console.GetGeneration())
Expand Down

0 comments on commit 7604ccb

Please sign in to comment.