Use len(Allocator.poolIPsInUse) for addresses_in_use metric#627
Use len(Allocator.poolIPsInUse) for addresses_in_use metric#627uablrek wants to merge 4 commits into
Conversation
|
Thanks! This change looks good to me, though I haven't tested it myself. Bonus points if you add test coverage, though :) (I'm not a maintainer, so I can't merge this myself) |
|
Hi! I can confirm that #625 and #622 are both solved by this PR (as expected since now covered by unittest as well). I built commit 722078a and tested the following: Both the empty system and the sharedvip system now shows correct metrics. @rata Is it possible to get a review from a maintainer on this PR? Thanks in advance |
|
Thanks for adding a test! |
|
Thanks! Had a quick look and looks good. Will review later this week in case I'm missing anything in the rush :) |
|
We just enabled CircleCI to run tests on open PRs, but that didn't make it run against PRs that were already open. I'm leaving this comment to see if a new comment triggers it to run. |
rata
left a comment
There was a problem hiding this comment.
@uablrek Hi! Thanks a lot for the PR. The actual fix looks good to me :)
I had a look at the test cases, and it seems prometheus has a testutil package to use for tests. Using that, we can actually test that is what we want and not use the protocol transform + strings.Contains(). I tested it locally and works fine.
Added some suggestions to give you a clear idea of what I just tested, but feel free to modify it if you think it's better with some other changes.
Can you please update it to use the prometheus testutil package for testing?
|
I have added a commit that fixes #626 also and moved the poolCapacity check to before the test-loop in the stats test. |
|
Hi! I tested again, building the newest commit 9111d10 and I can confirm that #626 is as well solved by this PR. With a configured, but empty (no LB services yet), system the metrics are working as I would expect. I also retested #625 and #622 to make sure they still work as expected. Thank you very much! |
There was a problem hiding this comment.
@uablrek thanks, LGTM! Added one simple comment to avoid type conversions and, while you are there, can you please squash Updated tests after review commit with Added unit-test for Pool metrics?
If not, no problem, I can do it locally and then push :)
@Aoana thanks a lot for the tests, it really helps! :)
| ports []Port | ||
| sharingKey string | ||
| backendKey string | ||
| ipsInUse int |
There was a problem hiding this comment.
Can you use float64 here, so no type conversion is needed later?
Fixes metallb#625 Fixed metallb#622 Signed-off-by: Lars Ekman <lars.g.ekman@est.tech>
Signed-off-by: Lars Ekman <lars.g.ekman@est.tech>
Fixes metallb#626 Signed-off-by: Lars Ekman <lars.g.ekman@est.tech>
|
@rata Updated, please re-review |
rata
left a comment
There was a problem hiding this comment.
Thanks again, LGTM! :)
If you don't mind, I might fixup two commits locally before pushing (the "corrected type" and the comit that added the "incorrect type") and maybe switch the log test prints statements to use %v if you don't mind (seems simpler, unless you used %f for some reason :))
|
@rata Please adjust the commits as you wich. And no, I just used %f because of my C-heritage 😃 |
Cool, will do in a sec! :)
haha, it happens to me too 😂 . I think I miss programming in C from time to time, until I actually program in C :-P |
|
Thanks a lot for the PR @uablrek and thanks a lot for the tests @Aoana ! I just pushed these, with a simple ammend on this commit. Closing as it is already merged :) |
The
Allocator.poolServicescounter was removed and insteadlen(Allocator.poolIPsInUse)is used for the "addresses_in_use" metric. It handles shared IP's and seem to be intended for this purpose from start, see comment;metallb/internal/allocator/allocator.go
Lines 204 to 208 in a9a6f31
Since this would conflict with PR #624 that fix is included in this PR and #624 will be closed.
Fixes #625
Fixed #622
Fixes #626
Signed-off-by: Lars Ekman lars.g.ekman@est.tech