Merge "Add --nocache option to container image build"
This commit is contained in:
commit
f6433120ae
@ -4,6 +4,8 @@
|
||||
vars:
|
||||
# Set this to True to push images to the registry when built.
|
||||
push_images: False
|
||||
# Set this to True to skip using cache.
|
||||
nocache: False
|
||||
# Set this variable to a space-separated list of regexes to override the
|
||||
# default set of images.
|
||||
container_image_regexes: ""
|
||||
@ -52,6 +54,7 @@
|
||||
{% if item.type is defined %}--type {{ item.type }}{% endif %}
|
||||
{% if kolla_docker_registry is not none %}--registry {{ kolla_docker_registry }}{% endif %}
|
||||
{% if push_images | bool %}--push{% endif %}
|
||||
{% if nocache | bool %}--nocache{% endif %}
|
||||
{{ item.regexes }} 2>&1 | tee --append {{ kolla_build_log_path }}
|
||||
executable: /bin/bash
|
||||
with_items: "{{ container_image_sets }}"
|
||||
|
@ -767,6 +767,8 @@ class SeedContainerImageBuild(KayobeAnsibleMixin, VaultMixin, Command):
|
||||
parser = super(SeedContainerImageBuild, self).get_parser(
|
||||
prog_name)
|
||||
group = parser.add_argument_group("Container Image Build")
|
||||
group.add_argument("--nocache", action="store_true",
|
||||
help="whether to not use cache")
|
||||
group.add_argument("--push", action="store_true",
|
||||
help="whether to push images to a registry after "
|
||||
"building")
|
||||
@ -780,7 +782,10 @@ class SeedContainerImageBuild(KayobeAnsibleMixin, VaultMixin, Command):
|
||||
playbooks = _build_playbook_list(
|
||||
"container-image-builders-check", "kolla-build",
|
||||
"container-image-build")
|
||||
extra_vars = {"push_images": parsed_args.push}
|
||||
extra_vars = {
|
||||
"nocache": parsed_args.nocache,
|
||||
"push_images": parsed_args.push
|
||||
}
|
||||
if parsed_args.regex:
|
||||
regexes = " ".join(parsed_args.regex)
|
||||
extra_vars["container_image_regexes"] = regexes
|
||||
@ -1493,6 +1498,8 @@ class OvercloudContainerImageBuild(KayobeAnsibleMixin, VaultMixin, Command):
|
||||
parser = super(OvercloudContainerImageBuild, self).get_parser(
|
||||
prog_name)
|
||||
group = parser.add_argument_group("Container Image Build")
|
||||
group.add_argument("--nocache", action="store_true",
|
||||
help="whether to not use cache")
|
||||
group.add_argument("--push", action="store_true",
|
||||
help="whether to push images to a registry after "
|
||||
"building")
|
||||
@ -1506,7 +1513,10 @@ class OvercloudContainerImageBuild(KayobeAnsibleMixin, VaultMixin, Command):
|
||||
playbooks = _build_playbook_list(
|
||||
"container-image-builders-check", "kolla-build",
|
||||
"container-image-build")
|
||||
extra_vars = {"push_images": parsed_args.push}
|
||||
extra_vars = {
|
||||
"nocache": parsed_args.nocache,
|
||||
"push_images": parsed_args.push
|
||||
}
|
||||
if parsed_args.regex:
|
||||
regexes = " ".join(parsed_args.regex)
|
||||
extra_vars["container_image_regexes"] = regexes
|
||||
|
@ -698,6 +698,7 @@ class TestCase(unittest.TestCase):
|
||||
"container_image_sets": (
|
||||
"{{ seed_container_image_sets }}"),
|
||||
"push_images": False,
|
||||
"nocache": False
|
||||
}
|
||||
),
|
||||
]
|
||||
@ -724,6 +725,35 @@ class TestCase(unittest.TestCase):
|
||||
extra_vars={
|
||||
"container_image_regexes": "^regex1$ ^regex2$",
|
||||
"push_images": True,
|
||||
"nocache": False
|
||||
}
|
||||
),
|
||||
]
|
||||
self.assertEqual(expected_calls, mock_run.call_args_list)
|
||||
|
||||
@mock.patch.object(commands.KayobeAnsibleMixin,
|
||||
"run_kayobe_playbooks")
|
||||
def test_seed_container_image_build_with_nocache(self, mock_run):
|
||||
command = commands.SeedContainerImageBuild(TestApp(), [])
|
||||
parser = command.get_parser("test")
|
||||
parsed_args = parser.parse_args(["--nocache"])
|
||||
result = command.run(parsed_args)
|
||||
self.assertEqual(0, result)
|
||||
expected_calls = [
|
||||
mock.call(
|
||||
mock.ANY,
|
||||
[
|
||||
utils.get_data_files_path(
|
||||
"ansible", "container-image-builders-check.yml"),
|
||||
utils.get_data_files_path("ansible", "kolla-build.yml"),
|
||||
utils.get_data_files_path(
|
||||
"ansible", "container-image-build.yml")
|
||||
],
|
||||
extra_vars={
|
||||
"container_image_sets": (
|
||||
"{{ seed_container_image_sets }}"),
|
||||
"push_images": False,
|
||||
"nocache": True
|
||||
}
|
||||
),
|
||||
]
|
||||
@ -1641,6 +1671,7 @@ class TestCase(unittest.TestCase):
|
||||
"container_image_sets": (
|
||||
"{{ overcloud_container_image_sets }}"),
|
||||
"push_images": False,
|
||||
"nocache": False
|
||||
}
|
||||
),
|
||||
]
|
||||
@ -1667,6 +1698,7 @@ class TestCase(unittest.TestCase):
|
||||
extra_vars={
|
||||
"container_image_regexes": "^regex1$ ^regex2$",
|
||||
"push_images": True,
|
||||
"nocache": False
|
||||
}
|
||||
),
|
||||
]
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Added new option (``--nocache``) to ``kayobe seed container image build``
|
||||
and ``kayobe overcloud container image build`` to skip using build cache.
|
Loading…
Reference in New Issue
Block a user