diff --git a/src/pylorax/api/config.py b/src/pylorax/api/config.py index 8b2333e8..79ad6f41 100644 --- a/src/pylorax/api/config.py +++ b/src/pylorax/api/config.py @@ -48,6 +48,7 @@ def configure(conf_file="/etc/lorax/composer.conf", root_dir="/", test_config=Fa conf.set("composer", "yum_root", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/yum/root/"))) conf.set("composer", "repo_dir", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/repos.d/"))) conf.set("composer", "cache_dir", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/cache/"))) + conf.set("composer", "tmp", os.path.realpath(joinpaths(root_dir, "/var/tmp/"))) conf.add_section("users") conf.set("users", "root", "1") diff --git a/src/pylorax/api/queue.py b/src/pylorax/api/queue.py index 1cdf8202..664ea249 100644 --- a/src/pylorax/api/queue.py +++ b/src/pylorax/api/queue.py @@ -47,7 +47,8 @@ def start_queue_monitor(cfg, uid, gid): """ lib_dir = cfg.get("composer", "lib_dir") share_dir = cfg.get("composer", "share_dir") - monitor_cfg = DataHolder(composer_dir=lib_dir, share_dir=share_dir, uid=uid, gid=gid) + tmp = cfg.get("composer", "tmp") + monitor_cfg = DataHolder(composer_dir=lib_dir, share_dir=share_dir, uid=uid, gid=gid, tmp=tmp) p = mp.Process(target=monitor, args=(monitor_cfg,)) p.daemon = True p.start() @@ -169,7 +170,7 @@ def make_compose(cfg, results_dir): cfg_dict["squashfs_args"] = None cfg_dict["lorax_templates"] = cfg.share_dir - cfg_dict["tmp"] = "/var/tmp/" + cfg_dict["tmp"] = cfg.tmp cfg_dict["dracut_args"] = None # Use default args for dracut # Compose things in a temporary directory inside the results directory @@ -206,6 +207,10 @@ def make_compose(cfg, results_dir): # Extract the results of the compose into results_dir and cleanup the compose directory move_compose_results(install_cfg, results_dir) finally: + # Make sure any remaining temporary directories are removed (eg. if there was an exception) + for d in glob(joinpaths(cfg.tmp, "lmc-*")): + shutil.rmtree(d) + # Make sure that everything under the results directory is owned by the user user = pwd.getpwuid(cfg.uid).pw_name group = grp.getgrgid(cfg.gid).gr_name diff --git a/src/sbin/lorax-composer b/src/sbin/lorax-composer index 0e03be77..6deecec0 100755 --- a/src/sbin/lorax-composer +++ b/src/sbin/lorax-composer @@ -210,6 +210,7 @@ if __name__ == '__main__': sys.exit(1) server.config["COMPOSER_CFG"] = configure(conf_file=opts.config) + server.config["COMPOSER_CFG"].set("composer", "tmp", opts.tmp) # Make sure the git repo can be accessed by the API uid/gid if os.path.exists(opts.BLUEPRINTS):