-
Notifications
You must be signed in to change notification settings - Fork 17
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
[drain-helper] remove usage of deprecated methods #59
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 12016700549Details
💛 - Coveralls |
0110535
to
215f563
Compare
pkg/upgrade/drain_manager.go
Outdated
@@ -83,7 +83,7 @@ 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) { | |||
OnPodDeletionOrEvictionFinished: func(pod *corev1.Pod, usingEviction bool, _ error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the idea is to evaluate error
field to determine if the eviction finished or failed. We should change the below logic accordingly. See e.g. here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Thanks for pointing this out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check now
d55acf6
to
be3b5d3
Compare
pkg/upgrade/drain_manager.go
Outdated
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the error handling is only to log to the correct level an alternative solution would be
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
}
log.V(consts.LogLevelInfo).Info("Drain Pod finished")
We also don't need the new line (i.e., \n
) in the log message, the go-logr will add this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks for the review @tobiasgiese ! Please check now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now. Unfortunately I am not able to approve
be3b5d3
to
cb77bca
Compare
Signed-off-by: Tariq Ibrahim <tibrahim@nvidia.com>
cb77bca
to
aa7dd9a
Compare
No description provided.