Pass the --tmp value into run_creator and cleanup after a crash
Crashing can sometimes leave directories in /var/tmp/lmc-* so clean those up after run_creator is finished.
This commit is contained in:
parent
559b66b7e3
commit
d9c4a6c951
@ -48,6 +48,7 @@ def configure(conf_file="/etc/lorax/composer.conf", root_dir="/", test_config=Fa
|
|||||||
conf.set("composer", "dnf_root", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/dnf/root/")))
|
conf.set("composer", "dnf_root", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/dnf/root/")))
|
||||||
conf.set("composer", "repo_dir", os.path.realpath(joinpaths(root_dir, "/var/tmp/composer/repos.d/")))
|
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", "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.add_section("users")
|
||||||
conf.set("users", "root", "1")
|
conf.set("users", "root", "1")
|
||||||
|
@ -48,7 +48,8 @@ def start_queue_monitor(cfg, uid, gid):
|
|||||||
"""
|
"""
|
||||||
lib_dir = cfg.get("composer", "lib_dir")
|
lib_dir = cfg.get("composer", "lib_dir")
|
||||||
share_dir = cfg.get("composer", "share_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 = mp.Process(target=monitor, args=(monitor_cfg,))
|
||||||
p.daemon = True
|
p.daemon = True
|
||||||
p.start()
|
p.start()
|
||||||
@ -170,7 +171,7 @@ def make_compose(cfg, results_dir):
|
|||||||
cfg_dict["squashfs_args"] = None
|
cfg_dict["squashfs_args"] = None
|
||||||
|
|
||||||
cfg_dict["lorax_templates"] = find_templates(cfg.share_dir)
|
cfg_dict["lorax_templates"] = find_templates(cfg.share_dir)
|
||||||
cfg_dict["tmp"] = "/var/tmp/"
|
cfg_dict["tmp"] = cfg.tmp
|
||||||
cfg_dict["dracut_args"] = None # Use default args for dracut
|
cfg_dict["dracut_args"] = None # Use default args for dracut
|
||||||
|
|
||||||
# TODO How to support other arches?
|
# TODO How to support other arches?
|
||||||
@ -210,6 +211,10 @@ def make_compose(cfg, results_dir):
|
|||||||
# Extract the results of the compose into results_dir and cleanup the compose directory
|
# Extract the results of the compose into results_dir and cleanup the compose directory
|
||||||
move_compose_results(install_cfg, results_dir)
|
move_compose_results(install_cfg, results_dir)
|
||||||
finally:
|
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
|
# Make sure that everything under the results directory is owned by the user
|
||||||
user = pwd.getpwuid(cfg.uid).pw_name
|
user = pwd.getpwuid(cfg.uid).pw_name
|
||||||
group = grp.getgrgid(cfg.gid).gr_name
|
group = grp.getgrgid(cfg.gid).gr_name
|
||||||
|
@ -712,4 +712,3 @@ def run_creator(opts, callback_func=None):
|
|||||||
result_dir = None
|
result_dir = None
|
||||||
|
|
||||||
return (result_dir, disk_img)
|
return (result_dir, disk_img)
|
||||||
|
|
||||||
|
@ -214,6 +214,7 @@ if __name__ == '__main__':
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
server.config["COMPOSER_CFG"] = configure(conf_file=opts.config)
|
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
|
# Make sure the git repo can be accessed by the API uid/gid
|
||||||
if os.path.exists(opts.BLUEPRINTS):
|
if os.path.exists(opts.BLUEPRINTS):
|
||||||
|
Loading…
Reference in New Issue
Block a user