From aa7dd9aceb67f8ca5bab92eff45200cda1eb4e0d Mon Sep 17 00:00:00 2001 From: Tariq Ibrahim Date: Mon, 25 Nov 2024 09:57:26 -0800 Subject: [PATCH] [drain-helper] remove usage of deprecated methods Signed-off-by: Tariq Ibrahim --- pkg/upgrade/drain_manager.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/upgrade/drain_manager.go b/pkg/upgrade/drain_manager.go index d8814048..4e0a70ce 100644 --- a/pkg/upgrade/drain_manager.go +++ b/pkg/upgrade/drain_manager.go @@ -83,12 +83,13 @@ func (m *DrainManagerImpl) ScheduleNodesDrain(ctx context.Context, drainConfig * GracePeriodSeconds: -1, Timeout: time.Duration(drainSpec.TimeoutSecond) * time.Second, PodSelector: drainSpec.PodSelector, - OnPodDeletedOrEvicted: func(pod *corev1.Pod, usingEviction bool) { - verbStr := "Deleted" - if usingEviction { - verbStr = "Evicted" + OnPodDeletionOrEvictionFinished: func(pod *corev1.Pod, usingEviction bool, err error) { + log := m.log.WithValues("using-eviction", usingEviction, "pod", pod.Name, "namespace", pod.Namespace) + if err != nil { + log.V(consts.LogLevelWarning).Info("Drain Pod failed", "error", err) + return } - m.log.V(consts.LogLevelInfo).Info(fmt.Sprintf("%s pod from Node %s/%s", verbStr, pod.Namespace, pod.Name)) + log.V(consts.LogLevelInfo).Info("Drain Pod finished") }, Out: os.Stdout, ErrOut: os.Stdout,