Add --nocache option to container image build
Change-Id: I11f0677681e51a59bcbb171d8da0e14c853d6c5c
This commit is contained in:
parent
0e2efc09ec
commit
0408e5388f
@ -4,6 +4,8 @@
|
|||||||
vars:
|
vars:
|
||||||
# Set this to True to push images to the registry when built.
|
# Set this to True to push images to the registry when built.
|
||||||
push_images: False
|
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
|
# Set this variable to a space-separated list of regexes to override the
|
||||||
# default set of images.
|
# default set of images.
|
||||||
container_image_regexes: ""
|
container_image_regexes: ""
|
||||||
@ -52,6 +54,7 @@
|
|||||||
{% if item.type is defined %}--type {{ item.type }}{% endif %}
|
{% if item.type is defined %}--type {{ item.type }}{% endif %}
|
||||||
{% if kolla_docker_registry is not none %}--registry {{ kolla_docker_registry }}{% endif %}
|
{% if kolla_docker_registry is not none %}--registry {{ kolla_docker_registry }}{% endif %}
|
||||||
{% if push_images | bool %}--push{% endif %}
|
{% if push_images | bool %}--push{% endif %}
|
||||||
|
{% if nocache | bool %}--nocache{% endif %}
|
||||||
{{ item.regexes }} 2>&1 | tee --append {{ kolla_build_log_path }}
|
{{ item.regexes }} 2>&1 | tee --append {{ kolla_build_log_path }}
|
||||||
executable: /bin/bash
|
executable: /bin/bash
|
||||||
with_items: "{{ container_image_sets }}"
|
with_items: "{{ container_image_sets }}"
|
||||||
|
@ -760,6 +760,8 @@ class SeedContainerImageBuild(KayobeAnsibleMixin, VaultMixin, Command):
|
|||||||
parser = super(SeedContainerImageBuild, self).get_parser(
|
parser = super(SeedContainerImageBuild, self).get_parser(
|
||||||
prog_name)
|
prog_name)
|
||||||
group = parser.add_argument_group("Container Image Build")
|
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",
|
group.add_argument("--push", action="store_true",
|
||||||
help="whether to push images to a registry after "
|
help="whether to push images to a registry after "
|
||||||
"building")
|
"building")
|
||||||
@ -773,7 +775,10 @@ class SeedContainerImageBuild(KayobeAnsibleMixin, VaultMixin, Command):
|
|||||||
playbooks = _build_playbook_list(
|
playbooks = _build_playbook_list(
|
||||||
"container-image-builders-check", "kolla-build",
|
"container-image-builders-check", "kolla-build",
|
||||||
"container-image-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:
|
if parsed_args.regex:
|
||||||
regexes = " ".join(parsed_args.regex)
|
regexes = " ".join(parsed_args.regex)
|
||||||
extra_vars["container_image_regexes"] = regexes
|
extra_vars["container_image_regexes"] = regexes
|
||||||
@ -1483,6 +1488,8 @@ class OvercloudContainerImageBuild(KayobeAnsibleMixin, VaultMixin, Command):
|
|||||||
parser = super(OvercloudContainerImageBuild, self).get_parser(
|
parser = super(OvercloudContainerImageBuild, self).get_parser(
|
||||||
prog_name)
|
prog_name)
|
||||||
group = parser.add_argument_group("Container Image Build")
|
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",
|
group.add_argument("--push", action="store_true",
|
||||||
help="whether to push images to a registry after "
|
help="whether to push images to a registry after "
|
||||||
"building")
|
"building")
|
||||||
@ -1496,7 +1503,10 @@ class OvercloudContainerImageBuild(KayobeAnsibleMixin, VaultMixin, Command):
|
|||||||
playbooks = _build_playbook_list(
|
playbooks = _build_playbook_list(
|
||||||
"container-image-builders-check", "kolla-build",
|
"container-image-builders-check", "kolla-build",
|
||||||
"container-image-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:
|
if parsed_args.regex:
|
||||||
regexes = " ".join(parsed_args.regex)
|
regexes = " ".join(parsed_args.regex)
|
||||||
extra_vars["container_image_regexes"] = regexes
|
extra_vars["container_image_regexes"] = regexes
|
||||||
|
@ -694,6 +694,7 @@ class TestCase(unittest.TestCase):
|
|||||||
"container_image_sets": (
|
"container_image_sets": (
|
||||||
"{{ seed_container_image_sets }}"),
|
"{{ seed_container_image_sets }}"),
|
||||||
"push_images": False,
|
"push_images": False,
|
||||||
|
"nocache": False
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@ -720,6 +721,35 @@ class TestCase(unittest.TestCase):
|
|||||||
extra_vars={
|
extra_vars={
|
||||||
"container_image_regexes": "^regex1$ ^regex2$",
|
"container_image_regexes": "^regex1$ ^regex2$",
|
||||||
"push_images": True,
|
"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
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@ -1635,6 +1665,7 @@ class TestCase(unittest.TestCase):
|
|||||||
"container_image_sets": (
|
"container_image_sets": (
|
||||||
"{{ overcloud_container_image_sets }}"),
|
"{{ overcloud_container_image_sets }}"),
|
||||||
"push_images": False,
|
"push_images": False,
|
||||||
|
"nocache": False
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@ -1661,6 +1692,7 @@ class TestCase(unittest.TestCase):
|
|||||||
extra_vars={
|
extra_vars={
|
||||||
"container_image_regexes": "^regex1$ ^regex2$",
|
"container_image_regexes": "^regex1$ ^regex2$",
|
||||||
"push_images": True,
|
"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