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

refactor(SelfHeal): Improve height drift mitigation logging #322

Merged
merged 1 commit into from
Jul 7, 2023
Merged
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
13 changes: 8 additions & 5 deletions controllers/selfhealing_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"errors"
"fmt"
"net/http"
"time"

Expand Down Expand Up @@ -118,19 +119,21 @@ func (r *SelfHealingReconciler) mitigateHeightDrift(ctx context.Context, reporte
return
}

const msg = "Height drift mitigation deleted pod"
pods := r.driftDetector.LaggingPods(ctx, crd)
if len(pods) > 0 {
reporter.RecordInfo("HeightDriftMitigation", msg)
}
var deleted int
for _, pod := range pods {
// CosmosFullNodeController will detect missing pod and re-create it.
if err := r.Delete(ctx, pod); kube.IgnoreNotFound(err) != nil {
reporter.Error(err, "Failed to delete pod", "pod", pod)
reporter.RecordError("HeightDriftMitigationDeletePod", err)
continue
}
reporter.Info(msg, "pod", pod)
reporter.Info("Deleted pod for meeting height drift threshold", "pod", pod)
deleted++
}
if deleted > 0 {
msg := fmt.Sprintf("Height lagged behind by %d or more blocks; deleted pod(s)", crd.Spec.SelfHeal.HeightDriftMitigation.Threshold)
reporter.RecordInfo("HeightDriftMitigation", msg)
}
}

Expand Down