Full /tmp filesystem

I have a number of servers which I’ve deployed to run openstack a couple months ago, and they started with a 20g /tmp filesystem.

They are all coming up with a full /tmp this week, so I got busy figuring out why.

The script maas-run-scripts which gets put in /usr/bin has a small bug in that it doesn’t remove the stuff it leaves in /tmp when it’s done with it. One way to resolve that put the following code in the script to clean up after itself:

  1. In the definition of ScriptsPaths class - add a class named cleanup that looks like this:
    def cleanup(self):
        if self.base_path.exists():
            shutil.rmtree(self.base_path)
  1. Add an initialization for the self.base_path variable in the init class so it looks like this:
    def __init__(self, base_path=None):
       if base_path is None:
           base_path = Path(mkdtemp())
       self.base_path = base_path
       self.scripts = base_path / "scripts"
       self.out = base_path / "out"
       self.downloads = base_path / "downloads"
       self.resources_file = base_path / "resources.json"
  1. And lastly, call the cleanup method at the end of the action_report_results function after the signal handler (line 963)
    paths.cleanup()

That should fix the issue at its source, which is a better solution than having a daily cron script clean out /tmp/tmp* (which is what I’ve implemented)

Thanks

~~ Charles

@bedfordc, thank you for your contribution!

I took a liberty of creating a bug report on Launchpad to track the issue, hope you don’t mind.

No - that’s perfect. Thanks!