-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add docker.prune - pruning for Docker subsystems #46176
Conversation
FOR REALZ ROFLMAO I could explain this function to my Cognitively Complexively Challenged neighbours |
@The-Loeki Yeah, we need to tweak the rules for the code-climate build. Can you also add some tests for this new function? |
Hi, I'm afraid I'm going to have to pass on that one due to time constraints... I will however update the function once I get the same function PR'd in docker-py; that should get rid of the hidden function calls. After that I'm not even sure what there is to test in this case. That is, I'm assuming Docker does it's testing on the API endpoints, |
salt/modules/dockermod.py
Outdated
def prune(system=True, containers=False, networks=False, images=False, build=False, volumes=False, **filters): | ||
''' | ||
Prune Docker's various subsystems | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing a quick sweep of the codebase, these API functions all seem to have been added in docker-py 2.1.0. Can you please add the following here?
.. note::
This requires docker-py version 2.1.0 or later.
If pre-2.1.0 docker-py is installed, _client_wrapper()
function will handle the API error from the unknown function call, so we won't have a traceback. This is just a bit of extra information that should help users who may be on earlier docker-py releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually there are a few things about this which don't actually work at all, it looks like it may not even have been tested since the kwargs
argument doesn't exist for these API funcs and trying to run this function on my laptop immediately resulted in a tracecback.
I'm working on some modifications that I can submit against your fork that should clear this up.
Another thing I noticed as I look deeper into the docker-py codebase is that negative filters don't seem to be supported. I've opened docker/docker-py#1940 upstream to get clarification. |
The kwargs argument isn't supported and attempting to pass it to the API will result in API errors. This fixes that bug and makes improvements to the docstring. It also changes the behavior of the `system` argument so that it doesn't need to be manually disabled to prune only containers/images/etc. Finally, it moves the prune function higher up to fit with the organizational structure of the module.
@The-Loeki Have a look at https://github.com/The-Loeki/salt/pull/1, I made some fixes, changed how |
Bugfixes, tweaks, tests for docker.prune
@terminalmage thanks for all the help and advice, regarding the older api's: I can probably easily write up the same kind of workarounds for the other prunes? |
You mean posting directly to the API endpoint? Yeah, that should be doable, and I can also work to get them supported in docker-py. Which other prunes are yet to be supported? |
AFAIK just the one I already opened a PR for (https://github.com/docker/docker-py/pull/1925/commits), so that would be purely a backwards compat feature |
Oh, so you were talking about making backwards-compatibility changes for containers, images, etc? If so, I don't think it's necessary in this PR. |
What does this PR do?
Add
docker.prune
, which is capable of clearing Docker's subsystems of cruft. Which seems necessary, a lot ;)