Add --temp-dir to overcloud image build

By default, DIB puts the temp folders it uses in /tmp. In newer
versions, this can cause images to go missing because systemd will
cleanup tmp (see tmpfiles.d) which may cause files and directories in
the image to missing. This change adds a --temp-dir option to the cli
which by default will configure TMPDIR to be the current working
directory if not specified.

Change-Id: Ib5f82a175266675d9639416dd664604bee370a1d
Closes-Bug: #1879766
This commit is contained in:
Alex Schultz 2020-09-11 13:10:10 -06:00
parent e21e04884e
commit 4c7df58d9b
1 changed files with 8 additions and 0 deletions

View File

@ -81,6 +81,13 @@ class BuildOvercloudImage(command.Command):
help=_("Output directory for images. Defaults to $TRIPLEO_ROOT," help=_("Output directory for images. Defaults to $TRIPLEO_ROOT,"
"or current directory if unset."), "or current directory if unset."),
) )
parser.add_argument(
"--temp-dir",
dest="temp_dir",
default=os.environ.get('TMPDIR', os.getcwd()),
help=_("Temporary directory to use when building the images. "
"Defaults to $TMPDIR or current directory if unset."),
)
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
@ -89,6 +96,7 @@ class BuildOvercloudImage(command.Command):
if not parsed_args.config_files: if not parsed_args.config_files:
parsed_args.config_files = [os.path.join(self.IMAGE_YAML_PATH, f) parsed_args.config_files = [os.path.join(self.IMAGE_YAML_PATH, f)
for f in self.DEFAULT_YAML] for f in self.DEFAULT_YAML]
os.environ.update({'TMPDIR': parsed_args.temp_dir})
manager = build.ImageBuildManager( manager = build.ImageBuildManager(
parsed_args.config_files, parsed_args.config_files,
output_directory=parsed_args.output_directory, output_directory=parsed_args.output_directory,