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

Fixes #415 - Close stdin when tearing down subprocesses in system-tests to prevent fd leaks #505

Merged

Conversation

jiridanek
Copy link
Contributor

No description provided.

Make sure a router exits if an initial HTTP listener fails, doesn't hang ... FAIL
/usr/lib64/python3.10/unittest/case.py:613: ResourceWarning: unclosed file <_io.BufferedWriter name=6>
  outcome.errors.clear()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
@codecov-commenter
Copy link

Codecov Report

Merging #505 (1d4bbb9) into main (618e4b3) will decrease coverage by 0.00%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #505      +/-   ##
==========================================
- Coverage   25.17%   25.17%   -0.01%     
==========================================
  Files         115      115              
  Lines       28772    28772              
  Branches     4669     4669              
==========================================
- Hits         7243     7242       -1     
  Misses      20562    20562              
- Partials      967      968       +1     
Flag Coverage Δ
unittests 25.17% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/router_core/address_watch.c 78.48% <0.00%> (-1.27%) ⬇️

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 618e4b3...1d4bbb9. Read the comment docs.

@@ -372,6 +372,10 @@ def error(msg):
# at this point the process has terminated, either of its own accord or
# due to the above terminate call.

# prevent leak of stdin fd
Copy link
Contributor

Choose a reason for hiding this comment

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

Is closing the stdin the only fix needed in order not to see the backtrace seen in #415 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, close stdin and ensure that the teardown method is always called.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, so you added the __enter__ and __exit__ functions to class Qdrouterd so if anyone uses the with keyword, we can ensure that the teardown() function will be called. But adding these two functions and the changes to the other tests in this commit are not part of the fix. The actual fix is to close the stdin on teardown(), right ?

Copy link
Contributor Author

@jiridanek jiridanek May 26, 2022

Choose a reason for hiding this comment

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

It is part of the fix. I need to ensure that stdin gets closed. If some tests never called teardown() and I am closing stdin in teardown, then I have to also call teardown there. And I can best do it with the with thing.

Am I missing something obvious 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.

I think I get it now. The change in system_tests_management.py from assertTrue to assertEqual is unrelated, yes. Let me put it to separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Split into #508, thanks!

@jiridanek jiridanek force-pushed the jd_2022_05_26_close_stdin_subprocess branch from 1d4bbb9 to 102945b Compare May 26, 2022 17:05
@jiridanek jiridanek merged commit adfd4fb into skupperproject:main May 26, 2022
@jiridanek jiridanek deleted the jd_2022_05_26_close_stdin_subprocess branch May 26, 2022 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ResourceWarning: unclosed file <_io.BufferedWriter name=12> Orderly router shutdown and resource cleanup
3 participants