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

Refactor ip in use algorithm #4268

Merged
merged 1 commit into from
Dec 7, 2022
Merged

Refactor ip in use algorithm #4268

merged 1 commit into from
Dec 7, 2022

Conversation

chrisdoherty4
Copy link
Contributor

@chrisdoherty4 chrisdoherty4 commented Dec 2, 2022

Refactor the IsIPInUse algorithm to be faster and more reliable.

The IsIPInUse algorithm iterated over a series of ports testing if they were open at some target address via TCP. It failed to take into consideration devices that are serving the IP but have no services listening on the checked ports resulting in a false negative.

Instead of relying on ports we can focus on whether the device responded. That can be achieved by either validating a TCP connection was in-fact established, or simply that the connection was reset by the server. The timeout period is still our indicator that the IP is not in use.

This check is still best effort but fixes the false negative case where none of the checked ports are open while also being 2s faster making it more appropriate for use in webhooks if desired.

Additional testing

I manually verified the errors returned by running the algorithm as part of an independent binary.

@eks-distro-bot
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@eks-distro-bot eks-distro-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 2, 2022
@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Merging #4268 (4c47a60) into main (e041387) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 4c47a60 differs from pull request most recent head 239c678. Consider uploading reports for the commit 239c678 to get more accurate results

@@            Coverage Diff             @@
##             main    #4268      +/-   ##
==========================================
- Coverage   68.51%   68.50%   -0.02%     
==========================================
  Files         404      404              
  Lines       32940    32939       -1     
==========================================
- Hits        22568    22564       -4     
- Misses       8924     8926       +2     
- Partials     1448     1449       +1     
Impacted Files Coverage Δ
pkg/providers/tinkerbell/tinkerbell.go 51.35% <ø> (ø)
pkg/networkutils/networkutils.go 67.56% <100.00%> (-0.86%) ⬇️
pkg/providers/vsphere/vsphere.go 62.90% <0.00%> (-0.43%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@chrisdoherty4 chrisdoherty4 marked this pull request as ready for review December 6, 2022 15:45
@chrisdoherty4
Copy link
Contributor Author

/approve

@eks-distro-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrisdoherty4

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Member

@g-gaston g-gaston left a comment

Choose a reason for hiding this comment

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

/lgtm

@eks-distro-bot eks-distro-bot merged commit d796af8 into aws:main Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants