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

hotfix(upstream) display active targets based on proper definition #2310

Merged
merged 1 commit into from
Mar 31, 2017

Conversation

p0pr0ck5
Copy link
Contributor

Previously we defined active upstream targets as any target with
a nonzero weight. This definition was properly implemented, but
caused confusion. As such, we redfine 'active targets' to be the most
recent entry of each nonzero target. This presents a more accurate
picture of the targets currently in use by the balancer.

Fix #2306.

-- track that we found this host:port so we only show
-- the most recent one (kinda)
found[entry.target] = true

else
ignored[entry.target] = true
end
Copy link
Member

Choose a reason for hiding this comment

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

style: switch the if and else blocks, short code path first (easier to read)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

for i = 1, found_n do
found[found[i].target] = nil
end

Copy link
Member

Choose a reason for hiding this comment

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

if you keep track of the ones dealt with in one table (now you track them in found and ignored), then the other table can hold the final result, and hence this final loop won't be necessary anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch!

target = "api-4:80",
weight = 10,
upstream_id = upstream3.id,
})
Copy link
Member

Choose a reason for hiding this comment

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

a case where there are multiple entries, but the last one has weight=0 (and hence is inactive) would be nice here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Previously we defined active upstream targets as any target with
a nonzero weight. This definition was properly implemented, but
caused confusion. As such, we redfine 'active targets' to be the most
recent entry of each nonzero target. This presents a more accurate
picture of the targets currently in use by the balancer.
@p0pr0ck5 p0pr0ck5 force-pushed the hotfix/proper-active branch from c3c6eba to ef05185 Compare March 31, 2017 17:35
@p0pr0ck5
Copy link
Contributor Author

@Tieske thanks for the comments, fixed up. Also refactored the tests a bit to be easier to read and extend cases.

@Tieske Tieske added pr/ready (but hold merge) No more concerns, but do not merge yet (probably a conflict of interest with another PR or release) and removed pr/status/needs review labels Mar 31, 2017
@Tieske Tieske merged commit e5c21c9 into master Mar 31, 2017
@Tieske Tieske deleted the hotfix/proper-active branch March 31, 2017 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/ready (but hold merge) No more concerns, but do not merge yet (probably a conflict of interest with another PR or release)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants