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

Replaced reuse_addr with something more insisting #2757

Merged

Conversation

BjarneHerland
Copy link
Contributor

Issue
Resolves #2728

Approach
Renamed ™reuse_addr" to "will_close_then_reopen_socket" to make users of this flag conscious of why it is there.

Added documentation with reasoning and cleaned up some rather clunky logic in find_available_port(). Cleaned up unnecessary use of the flag in tests and code.

Pre review checklist

  • Added appropriate labels

@BjarneHerland
Copy link
Contributor Author

In particular I would appreciate input on the approach and docs.

@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2022

Codecov Report

Merging #2757 (f826b75) into main (f20fec4) will increase coverage by 0.14%.
The diff coverage is 91.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2757      +/-   ##
==========================================
+ Coverage   65.20%   65.35%   +0.14%     
==========================================
  Files         652      652              
  Lines       53630    53502     -128     
  Branches     4818     4752      -66     
==========================================
- Hits        34970    34965       -5     
+ Misses      17058    16934     -124     
- Partials     1602     1603       +1     
Impacted Files Coverage Δ
ert_shared/ensemble_evaluator/config.py 95.40% <ø> (ø)
ert_shared/services/_storage_main.py 24.77% <0.00%> (ø)
ert_shared/ensemble_evaluator/ensemble/prefect.py 90.58% <100.00%> (+0.05%) ⬆️
ert_shared/port_handler.py 100.00% <100.00%> (+3.84%) ⬆️
ert_gui/ertwidgets/validationsupport.py 79.45% <0.00%> (-19.18%) ⬇️
ert_gui/ertwidgets/__init__.py 75.00% <0.00%> (-2.28%) ⬇️
ert3/console/_console.py 88.29% <0.00%> (-1.26%) ⬇️
ert3/workspace/_workspace.py 89.24% <0.00%> (-0.76%) ⬇️
libres/lib/res_util/matrix.cpp 65.40% <0.00%> (-0.28%) ⬇️
libres/lib/enkf/enkf_node.cpp 52.16% <0.00%> (-0.26%) ⬇️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f20fec4...f826b75. Read the comment docs.

@frode-aarstad
Copy link
Contributor

Looks good. The comment is informative and helps explain the different issues with sockets in the implementation.
I guess its not easy to create a test testing the fix since its mostly seen on clusters.

@@ -57,14 +57,15 @@ async def _eq_submit_job(self, script_filename):


def _get_executor(custom_port_range, name="local"):
_, port, _ = find_available_port(custom_range=custom_port_range, reuse_addr=True)
if name == "local":
cluster_kwargs = {
"silence_logs": "debug",
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the reason of the removal of the port when running locally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think the LocalDaskExecutor runs a server, hence does not need a port

Copy link
Collaborator

@sondreso sondreso Jan 24, 2022

Choose a reason for hiding this comment

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

It does (I think), but when running locally we are not restricted by infrastructure firewall 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh - ok. So it's free to pick whatever port id wants then, which it does when we do not provide a port-number.

@BjarneHerland
Copy link
Contributor Author

Following up on @frode-aarstad 's challenge 😄 I started to write tests for this and discovered quite a lot of funky behaviour.

Hopefully these tests with docs adequately describes current behaviour and provides users of this module some insight into what to expect...

@frode-aarstad
Copy link
Contributor

frode-aarstad commented Jan 25, 2022

Following up on @frode-aarstad 's challenge 😄 I started to write tests for this and discovered quite a lot of funky behaviour.

Hopefully these tests with docs adequately describes current behaviour and provides users of this module some insight into what to expect...

Looks very good. Tested and worked fine on WSL2

@oysteoh
Copy link
Contributor

oysteoh commented Jan 25, 2022

Looks very good - also good with more tests verifying the behavior! 👏

oysteoh
oysteoh previously approved these changes Jan 25, 2022
@joakim-hove
Copy link
Contributor

@BjarneHerland : I tried to find an issue/PR with questions of thread-pool; could not find now. Easiest to reach me on email joakim.hove AT opm-op.com Might be a bit tight today. Cool if you post a link to the issue/PR here. Thank you.

@BjarneHerland
Copy link
Contributor Author

test ert please

@BjarneHerland
Copy link
Contributor Author

test ctest please

@oysteoh
Copy link
Contributor

oysteoh commented Jan 25, 2022

@BjarneHerland : I tried to find an issue/PR with questions of thread-pool; could not find now. Easiest to reach me on email joakim.hove AT opm-op.com Might be a bit tight today. Cool if you post a link to the issue/PR here. Thank you.

@joakim-hove the issue you are looking for is located here #2650

@BjarneHerland
Copy link
Contributor Author

test this please

@oysteoh oysteoh dismissed their stale review January 26, 2022 12:01

awaiting further improvements wrt testing

@BjarneHerland
Copy link
Contributor Author

test ert please

@BjarneHerland
Copy link
Contributor Author

@oysteoh , @sondreso mind taking a look? I hope to merge in the (narrow) window between green tests and need for rebase... 😄

Copy link
Contributor

@oysteoh oysteoh left a comment

Choose a reason for hiding this comment

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

Very good! Nice with good documented testing verifying the behavior of this! 🚀

Copy link
Collaborator

@sondreso sondreso left a comment

Choose a reason for hiding this comment

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

LGTM! Only had a small question

ert_shared/ensemble_evaluator/ensemble/prefect.py Outdated Show resolved Hide resolved
Rename "reuse_addr" to "will_close_then_reopen_socket" to
make users of this flag conscious about why it is there.
Added reasoning and cleaned up some rather clunky logic
in find_available_port(). Cleaned up unnecessary use of the
flag in tests and code. Added extensive tests.
@BjarneHerland
Copy link
Contributor Author

If no other questions or concerns, I'll just merge this one. Would be interesting, though, to identify one or two tests crucial in this context.

@BjarneHerland BjarneHerland merged commit d6cd336 into equinor:main Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove reuse_addr parameter from port_handler
6 participants