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
(cherry picked from commit 4c7df58d9b)
This commit is contained in:
Alex Schultz 2020-09-11 13:10:10 -06:00
parent 72161e0a60
commit 048401228d
1 changed files with 8 additions and 0 deletions

View File

@ -82,6 +82,13 @@ class BuildOvercloudImage(command.Command):
help=_("Output directory for images. Defaults to $TRIPLEO_ROOT,"
"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
def take_action(self, parsed_args):
@ -90,6 +97,7 @@ class BuildOvercloudImage(command.Command):
if not parsed_args.config_files:
parsed_args.config_files = [os.path.join(self.IMAGE_YAML_PATH, f)
for f in self.DEFAULT_YAML]
os.environ.update({'TMPDIR': parsed_args.temp_dir})
manager = build.ImageBuildManager(
parsed_args.config_files,
output_directory=parsed_args.output_directory,