Skip to content

Conversation

@sakateka
Copy link
Contributor

@sakateka sakateka commented Apr 29, 2022

Container.FilesManager leaks through the inheritance chain
in the external pylxd module. Every time the LazyLoader reimports
via the importlib module/lxd.py, a proxy FilesManager class is created,
which inherits from itself in the external module and then
it overwrites the FilesManager class in the external module by itself.
The result is an ever-growing chain of inheritance.

What does this PR do?

fix memory leak

What issues does this PR fix or reference?

Fixes:
may be #61988

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

`Container.FilesManager` leaks through the inheritance chain
in the external pylxd module. Every time the LazyLoader reimports
via the importlib `module/lxd.py`, a proxy FilesManager class is created,
which inherits from itself in the external module and then
it overwrites the `FilesManager` class in the external module by itself.
The result is an ever-growing chain of inheritance.
@sakateka sakateka requested a review from a team as a code owner April 29, 2022 17:06
@sakateka sakateka requested review from twangboy and removed request for a team April 29, 2022 17:06
@sakateka
Copy link
Contributor Author

sakateka commented May 18, 2022

This #62006 is the most intense leak I've found.
#62007
#62021

@sakateka
Copy link
Contributor Author

@Ch3LL Hi, this is a very simple patch, can you help merge it?

@sakateka sakateka mentioned this pull request Jun 16, 2022
3 tasks
@sakateka
Copy link
Contributor Author

re-run pr-windows-2019-x64-py3-pytest
re-run pr-macosx-catalina-x86_64-py3-pytest

@sakateka
Copy link
Contributor Author

@Ch3LL all the required tests have been passed, please merge this PR

@github-actions
Copy link

Hi! I'm your friendly PR bot!

You might be wondering what I'm doing commenting here on your PR.

Yes, as a matter of fact, I am...

I'm just here to help us improve the documentation. I can't respond to
questions or anything, but what I can do, I do well!

Okay... so what do you do?

I detect modules that are missing docstrings or "CLI Example" on existing docstrings!
When I was created we had a lot of these. The documentation for these
modules need some love and attention to make Salt better for our users.

So what does that have to do with my PR?

I noticed that in this PR there are some files changed that have some of these
issues. So I'm leaving this comment to let you know your options.

Okay, what are they?

Well, my favorite, is that since you were making changes here I'm hoping that
you would be the most familiar with this module and be able to add some other
examples or fix any of the reported issues.

If I can, then what?

Well, you can either add them to this PR or add them to another PR. Either way is fine!

Well... what if I can't, or don't want to?

That's also fine! We appreciate all contributions to the Salt Project. If you
can't add those other examples, either because you're too busy, or unfamiliar,
or you just aren't interested, we still appreciate the contributions that
you've made already.

Whatever approach you decide to take, just drop a comment here letting us know!

Detected Issues (click me)
Check Known Missing Docstrings...........................................Failed
- hook id: invoke
- duration: 1.21s
- exit code: 1

/home/runner/.cache/pre-commit/repoav828ei8/py_env-python3/lib/python3.9/site-packages/_distutils_hack/init.py:30: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
The function 'pylxd_client_get' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'pylxd_save_object' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_get' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_delete' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_rename' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_state' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_start' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_stop' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_restart' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_freeze' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_unfreeze' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_config_get' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_config_set' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_config_delete' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_device_get' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_device_add' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_device_delete' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'container_file_get' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
The function 'sync_config_devices' on 'salt/modules/lxd.py' does not have a 'CLI Example:' in its docstring
Found 19 errors


Thanks again!

@twangboy
Copy link
Contributor

@sakateka Thanks for submitting this PR. Would you please write a test for this?

@sakateka
Copy link
Contributor Author

Would you please write a test for this?

There is no new functionality here, the tests that already exist should be enough, or what kind of test do you want?

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.

4 participants