Browse Source

[hca] Only build/push stable images if unpublished

At present, the only mechanism we have for publishing a stable heat
container agent image through manual tagging. This PS aims to automate
this through the CI by only building them if they have not already been
published. This should allow us to keep better track of which commit was
used to build a given heat container agent image.

Story: 2007264
Task: 40045

Change-Id: Ifb80575c18a34584afddc8b83084702713a802b7
changes/00/735100/9
Bharat Kunwar 1 year ago
parent
commit
ff57593984
3 changed files with 28 additions and 10 deletions
  1. +7
    -3
      playbooks/container-builder-vars.yaml
  2. +19
    -5
      playbooks/container-builder.yaml
  3. +2
    -2
      playbooks/container-publish.yaml

+ 7
- 3
playbooks/container-builder-vars.yaml View File

@ -2,9 +2,13 @@ magnum_src_dir: "src/opendev.org/openstack/magnum"
magnum_repository: openstackmagnum
magnum_images:
- name: heat-container-agent
tag: victoria-dev
# NOTE: By default, stable images are not built if they already exist.
# Assigning dev=true property for heat container agent images means that a new
# image is re-built and pushed under the same tag every time.
heat_container_agent_images:
- tag: victoria-stable-1
- tag: wallaby-dev
dev: true
kubernetes_versions:
- version: v1.15.12


+ 19
- 5
playbooks/container-builder.yaml View File

@ -2,15 +2,29 @@
tasks:
- include_vars: container-builder-vars.yaml
- name: "Build magnum images"
# NOTE: By default, stable images are not built if they already exist.
# Assigning dev=true property for heat container agent images means that a new
# image is re-built and pushed under the same tag every time.
- name: "Build heat-container-agent images"
block:
- name: "Build {{ magnum_repository }}/{{ item.name }}:{{ item.tag }} image"
- name: "Check if {{ magnum_repository }}/heat-container-agent:{{ item.tag }} exists"
docker_image:
path: "{{ magnum_src_dir }}/dockerfiles/{{ item.name }}"
name: "{{ magnum_repository }}/{{ item.name }}"
name: "{{ magnum_repository }}/heat-container-agent"
tag: "{{ item.tag }}"
pull: yes
register: docker_output
when: not (item.dev | default(false) | bool)
ignore_errors: true
with_items: "{{ heat_container_agent_images }}"
- name: "Build {{ magnum_repository }}/heat-container-agent:{{ item.item.tag }} image"
docker_image:
path: "{{ magnum_src_dir }}/dockerfiles/heat-container-agent"
name: "{{ magnum_repository }}/heat-container-agent"
tag: "{{ item.item.tag }}"
push: no
with_items: "{{ magnum_images }}"
source: build
with_items: "{{ docker_output.results }}"
when: (item is failed) or (item.item.dev | default(false) | bool)
retries: 10
- name: "Build kubernetes images"


+ 2
- 2
playbooks/container-publish.yaml View File

@ -9,8 +9,8 @@
- name: Push images to DockerHub
block:
- command: docker push {{ magnum_repository }}/{{ item.name }}:{{ item.tag }}
with_items: "{{ magnum_images }}"
- command: docker push {{ magnum_repository }}/heat-container-agent:{{ item.tag }}
with_items: "{{ heat_container_agent_images }}"
retries: 10
- command: docker push {{ magnum_repository }}/{{ item[1].name }}:{{ item[0].version }}
with_nested:


Loading…
Cancel
Save