Skip to content
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

Do not decommission when node is miss behaving #158

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions src/go/k8s/internal/controller/redpanda/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ const (
SecretAnnotationExternalCAKey = "operator.redpanda.com/external-ca"

NotManaged = "false"

DecommissionOnDeleteAnnotation = "operator.redpanda.com/decommission-on-delete"
)

var (
Expand Down Expand Up @@ -338,16 +336,6 @@ func (r *ClusterReconciler) handlePodFinalizer(
return fmt.Errorf("unable to fetch PodList: %w", err)
}

var decommissionOnDelete bool
decommissionOnDeleteVal, ok := rp.Annotations[DecommissionOnDeleteAnnotation]
if ok {
decommissionOnDelete, err = strconv.ParseBool(decommissionOnDeleteVal)
if err != nil {
//nolint:goerr113 // not going to use wrapped static error here this time
return fmt.Errorf("value of annotation operator.redpanda.com/decommission-on-delete must be convertable to boolean")
}
}

for i := range pods.Items {
pod := &pods.Items[i]
if pod.DeletionTimestamp.IsZero() {
Expand All @@ -371,11 +359,14 @@ func (r *ClusterReconciler) handlePodFinalizer(
// nor has a noexecute taint
untainted := true
for _, taint := range node.Spec.Taints {
if (taint.Effect == corev1.TaintEffectNoExecute && taint.Key == corev1.TaintNodeUnreachable) || (decommissionOnDelete && taint.Effect == corev1.TaintEffectNoSchedule) {
if taint.Effect == corev1.TaintEffectNoExecute && taint.Key == corev1.TaintNodeUnreachable {
untainted = false
}
}
if untainted {

// Continue with Pod finalizer handling if allowPVCDeletion flag is not enabled or when
// K8S Node does not report NoExecute taint effect with NodeUnreachable key.
if untainted || !r.allowPVCDeletion {
// remove the finalizer and let the pod be restarted
if err = r.removePodFinalizer(ctx, pod, log); err != nil {
return fmt.Errorf(`unable to remove finalizer from pod "%s": %w`, pod.Name, err)
Expand Down Expand Up @@ -423,13 +414,6 @@ func (r *ClusterReconciler) handlePodFinalizer(
}
}

if !r.allowPVCDeletion {
// remove the finalizer
if err = r.removePodFinalizer(ctx, pod, log); err != nil {
return fmt.Errorf(`unable to remove finalizer from pod "%s/%s: %w"`, pod.GetNamespace(), pod.GetName(), err)
}
return nil
}
// delete the associated pvc
if err = utils.DeletePodPVCs(ctx, r.Client, pod, log); err != nil {
return fmt.Errorf(`unable to remove VPCs for pod "%s/%s: %w"`, pod.GetNamespace(), pod.GetName(), err)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading