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

[drain-helper] remove usage of deprecated methods #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tariq1890
Copy link
Collaborator

No description provided.

@coveralls
Copy link

coveralls commented Nov 25, 2024

Pull Request Test Coverage Report for Build 12016700549

Details

  • 1 of 16 (6.25%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.4%) to 61.718%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/upgrade/drain_manager.go 1 16 6.25%
Totals Coverage Status
Change from base Build 11928826672: -0.4%
Covered Lines: 1085
Relevant Lines: 1758

💛 - Coveralls

@@ -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) {
Copy link
Collaborator

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.

Copy link
Collaborator Author

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!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check now

@tariq1890 tariq1890 force-pushed the rm-deprec-method branch 2 times, most recently from d55acf6 to be3b5d3 Compare November 25, 2024 18:44
Comment on lines 87 to 104
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))
Copy link
Member

@tobiasgiese tobiasgiese Nov 26, 2024

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.

Copy link
Collaborator Author

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

Copy link
Member

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

Signed-off-by: Tariq Ibrahim <tibrahim@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants