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

Emptiness reconcile now properly backs off #664

Merged
merged 8 commits into from
Sep 8, 2021
Merged

Emptiness reconcile now properly backs off #664

merged 8 commits into from
Sep 8, 2021

Conversation

njtran
Copy link
Contributor

@njtran njtran commented Sep 8, 2021

1. Issue, if available:
#663

2. Description of changes:

3. Does this change impact docs?

  • Yes, PR includes docs updates
  • Yes, issue opened: link to issue
  • No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@netlify
Copy link

netlify bot commented Sep 8, 2021

✔️ Deploy Preview for karpenter-docs-prod canceled.

🔨 Explore the source changes: 8ad0d83

🔍 Inspect the deploy log: https://app.netlify.com/sites/karpenter-docs-prod/deploys/6139265b3f7b5100071a76ad

for _, duration := range durations {
if duration > max {
max = duration
if (duration < min && duration != 0) || (duration != 0 && min == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if you initialize min to the first duration, you can simplify this check by removing all the 0s

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIUC, if the first duration is 0, we still run into the problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh you want to return the smallest non-zero, ok. I'm guessing it's fine to return 0 if all the durations are 0 then?

for _, duration := range durations {
if duration > max {
max = duration
if (duration < min && duration != 0) || (duration != 0 && min == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for safety, clarity, can you use https://pkg.go.dev/time#Time.IsZero ?

Copy link
Contributor Author

@njtran njtran Sep 8, 2021

Choose a reason for hiding this comment

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

Since we're comparing time.Duration and not time.Time, this kind of comparison should be okay.

From their code
type Duration int64

Copy link
Contributor

@JacobGabrielson JacobGabrielson Sep 8, 2021

Choose a reason for hiding this comment

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

Yeah, I realize it works either way, but I think IsZero is preferable from a readability standpoint (eg as a reader of the code I don't have to think as much :-))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So since there's not a time.Duration.IsZero() function, are you suggesting I add it?

bwagner5
bwagner5 previously approved these changes Sep 8, 2021
Copy link
Contributor

@bwagner5 bwagner5 left a comment

Choose a reason for hiding this comment

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

lgtm

@njtran njtran merged commit 845fe01 into aws:main Sep 8, 2021
@njtran njtran deleted the emptinessReconcile branch September 9, 2021 22:49
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