Skip to content

Commit

Permalink
[drain-helper] remove usage of deprecated methods
Browse files Browse the repository at this point in the history
Signed-off-by: Tariq Ibrahim <tibrahim@nvidia.com>
  • Loading branch information
tariq1890 committed Dec 17, 2024
1 parent db12cb1 commit cb77bca
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions pkg/upgrade/drain_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,25 @@ 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"
OnPodDeletionOrEvictionFinished: func(pod *corev1.Pod, usingEviction bool, err error) {
var verbStr string
if usingEviction {
verbStr = "Evicted"
if err != nil {
verbStr = "eviction failed"
} else {
verbStr = "evicted"
}
} else {
if err != nil {
verbStr = "deletion failed"
} else {
verbStr = "deleted"
}
}
if err != nil {
m.log.V(consts.LogLevelWarning).Info("pod deletion/eviction failed", "error", err)
}
m.log.V(consts.LogLevelInfo).Info(fmt.Sprintf("%s pod from Node %s/%s", verbStr, pod.Namespace, pod.Name))
m.log.V(consts.LogLevelInfo).Info(fmt.Sprintf("pod %s/%s %s\n", pod.Namespace, pod.Name, verbStr))
},
Out: os.Stdout,
ErrOut: os.Stdout,
Expand Down

0 comments on commit cb77bca

Please sign in to comment.