Skip to content

Conversation

eberlep
Copy link
Collaborator

@eberlep eberlep commented Feb 26, 2021

No description provided.

@eberlep eberlep linked an issue Feb 26, 2021 that may be closed by this pull request
isOccupied := make([]bool, int(m.PortRangeSize))
// If there are already any managed services, store all the used ports in a slice.
// Also store the LoadBalancerIP.
portsInUse := make([]int32, len(lbs.Items))
for i := range lbs.Items {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about factoring this logic out into a testable function ?

@LimKianAn LimKianAn added the enhancement New feature or request label Mar 29, 2021
@LimKianAn LimKianAn self-assigned this Mar 29, 2021
@LimKianAn LimKianAn marked this pull request as ready for review March 29, 2021 16:21
@LimKianAn LimKianAn requested a review from majst01 March 29, 2021 16:33
@LimKianAn LimKianAn requested review from LimKianAn and majst01 and removed request for majst01 and LimKianAn April 6, 2021 08:10
Copy link
Collaborator Author

@eberlep eberlep left a comment

Choose a reason for hiding this comment

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

I think that is not exactly what @majst01 had in mind, but it also works.

Stefan probably meant refactoring the logic so it is easily testable without any additional dependencies. At the end of the day, the core task of this code is to simply pick the next free int from a given range with another list of occupied ints not to choose. When refactored correctly, we do not need any mocks to test this.

@LimKianAn LimKianAn merged commit 1e67481 into main Apr 6, 2021
@LimKianAn LimKianAn deleted the refactor-nextFreeSocket branch April 6, 2021 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nextFreeSocket: index out of range
3 participants