Allow applying workaround patches in containers.
The current workarounds mechanism allows applying a patch into a host, usually the Undercloud. With the containerization of both undercloud and overcloud a new need arises, the option to apply a patch into a container or list of containers. This patch adds new workarounds field to apply modifications to overcloud or undercloud containers using tripleo container image prepare[1]. The workaround mechanism takes a ContainerImagePrepare file and adds desired modifications on top of it. After building containers, modified containers parameters file are added to desired update or upgrade scripts to update TripleO Heat Templates before update/upgrade run. This way changes in containers are persistent. There is also field 'preparation_commands' to execute some pre container image prepare commands, for example to download rpms or create custom Dockerfile. pre_undercloud_update_workarounds: - rhbz1: patch: false containers: true environment: undercloud preparation_commands: | echo "Updates undercloud containers command" containers_file_modifications: modify_role: tripleo-modify-image includes: - ironic-inspector modify_append_tag: "-updated" modify_vars: tasks_from: yum_update.yml compare_host_packages: true yum_repos_dir_path: /etc/yum.repos.d pre_overcloud_update_prepare_workarounds: - rhbz11: patch: false containers: true environment: overcloud deploy_scripts: overcloud_update_prepare.sh,overcloud_update_converge.sh preparation_commands: | echo "Updates overcloud containers command" containers_file_modifications: modify_role: tripleo-modify-image includes: - rabbitmq - haproxy - maria - redis modify_append_tag: "-updated" modify_vars: tasks_from: yum_update.yml compare_host_packages: true yum_repos_dir_path: /etc/yum.repos.d #Only supports python source projects pre_overcloud_update_prepare_workarounds: - rhbz11: patch: false containers: true environment: overcloud deploy_scripts: overcloud_update_prepare.sh,overcloud_update_converge.sh preparation_commands: "" containers_file_modifications: modify_role: tripleo-modify-image includes: - heat-api modify_append_tag: "-modified" modify_vars: tasks_from: dev_install.yml source_image: docker.io/tripleomaster/centos-binary-heat-api:current-tripleo refspecs: - project: heat refspec: refs/changes/12/1234/3 Change-Id: I4f8151f003d7636c3b34158e32ee62047f008129 [1] https://docs.openstack.org/project-deploy-guide/tripleo-docs/latest/deployment/container_image_prepare.html#modifying-images-during-prepare
This commit is contained in:
parent
15f4fc5a02
commit
5d1bf944d6
|
@ -46,6 +46,36 @@ function apply_patch {
|
|||
|
||||
}
|
||||
|
||||
# Applies a patch into overcloud containers with Container Image Preparation.
|
||||
function overcloud_container_apply_patch {
|
||||
local bz_key=$1
|
||||
local scripts=$2
|
||||
PARAMS_FILE=$HOME/containers_workarounds/${bz_key}-params.yaml
|
||||
IFS=',' read -ra SCRIPTS <<< "$scripts"
|
||||
sudo openstack tripleo container image prepare -e $HOME/containers_workarounds/${bz_key}.yaml \
|
||||
--output-env-file $PARAMS_FILE
|
||||
for i in "${SCRIPTS[@]}"; do
|
||||
cat /home/stack/$i | \
|
||||
sed -e 's,2>&1,-e '${PARAMS_FILE}' \\\n 2>\&1,' \
|
||||
> /home/stack/${i}.new.sh
|
||||
cp "/home/stack/${i}"{,.original.sh}
|
||||
cat "/home/stack/${i}".new.sh > "/home/stack/${i}"
|
||||
done
|
||||
}
|
||||
|
||||
# Applies a patch into undercloud containers with Container Image Preparation.
|
||||
function undercloud_container_apply_patch {
|
||||
local bz_key=$1
|
||||
local undercloud_conf=$HOME/undercloud.conf
|
||||
PARAMS_FILE=$HOME/containers_workarounds/${bz_key}-params.yaml
|
||||
sudo openstack tripleo container image prepare -e $HOME/containers_workarounds/${bz_key}.yaml --output-env-file $PARAMS_FILE
|
||||
cat $undercloud_conf | \
|
||||
sed "\|custom_env_files|s|$|,$PARAMS_FILE|" \
|
||||
> ${undercloud_conf}.new.sh
|
||||
cp "${undercloud_conf}"{,.original.sh}
|
||||
cat "${undercloud_conf}".new.sh > "${undercloud_conf}"
|
||||
}
|
||||
|
||||
function ansible_patch {
|
||||
local ansible_filename=$1
|
||||
local ansible_limit=""
|
||||
|
@ -122,6 +152,17 @@ echo {{ key }}
|
|||
{% set _patch_strip = value.patch_strip | default(1, True) -%}
|
||||
{% set _gerrit_url = value.gerrit_url | default('https://review.opendev.org', True) -%}
|
||||
apply_patch {{ value.basedir }} {{ value.id }} {{ _patch_revision }} {{ _patch_strip }} {{ _gerrit_url }}
|
||||
{% elif value.containers is defined and value.containers == true -%}
|
||||
{{ value.preparation_commands }}
|
||||
[ -d $HOME/containers_workarounds ] || mkdir $HOME/containers_workarounds
|
||||
cat << EOF | cat $HOME/containers-prepare-parameter.yaml - > "$HOME/containers_workarounds/{{ key }}.yaml"
|
||||
{{ value.containers_file_modifications | to_nice_yaml | indent(width=4, first=True) }}
|
||||
EOF
|
||||
{% if value.environment|lower == 'overcloud' -%}
|
||||
overcloud_container_apply_patch {{ key }} {{ value.deploy_scripts }}
|
||||
{% elif value.environment|lower == 'undercloud' -%}
|
||||
undercloud_container_apply_patch {{ key }}
|
||||
{% endif -%}
|
||||
{% elif value.ansible_hosts is defined and value.ansible_hosts != '' -%}
|
||||
|
||||
[ -d $HOME/ansible_workarounds ] || mkdir $HOME/ansible_workarounds
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
---
|
||||
pre_undercloud_update_workarounds:
|
||||
- rhbz1:
|
||||
patch: true
|
||||
basedir: /usr/share/openstack-tripleo-heat-templates
|
||||
id: 112345
|
||||
command:
|
||||
patch: false
|
||||
containers: true
|
||||
environment: undercloud
|
||||
preparation_commands: |
|
||||
echo "Updates undercloud containers command"
|
||||
containers_file_modifications:
|
||||
modify_role: tripleo-modify-image
|
||||
includes:
|
||||
- ironic-inspector
|
||||
modify_append_tag: "-updated"
|
||||
modify_vars:
|
||||
tasks_from: yum_update.yml
|
||||
compare_host_packages: true
|
||||
yum_repos_dir_path: /etc/yum.repos.d
|
||||
- rhbz2:
|
||||
patch: true
|
||||
basedir: /usr/share/openstack-tripleo-heat-templates
|
||||
patch_strip: 2
|
||||
id: 212321
|
||||
command:
|
||||
- rhbz3:
|
||||
patch: false
|
||||
basedir: ''
|
||||
id: ''
|
||||
|
@ -23,8 +27,28 @@ post_undercloud_update_workarounds:
|
|||
id: ''
|
||||
command: |
|
||||
echo "This is a nice workaround"
|
||||
pre_overcloud_update_run_workarounds:
|
||||
pre_overcloud_update_prepare_workarounds:
|
||||
- rhbz11:
|
||||
patch: false
|
||||
containers: true
|
||||
environment: overcloud
|
||||
deploy_scripts: overcloud_update_prepare.sh,overcloud_update_converge.sh
|
||||
preparation_commands: |
|
||||
echo "Updates overcloud containers command"
|
||||
containers_file_modifications:
|
||||
modify_role: tripleo-modify-image
|
||||
includes:
|
||||
- rabbitmq
|
||||
- haproxy
|
||||
- maria
|
||||
- redis
|
||||
modify_append_tag: "-updated"
|
||||
modify_vars:
|
||||
tasks_from: yum_update.yml
|
||||
compare_host_packages: true
|
||||
yum_repos_dir_path: /etc/yum.repos.d
|
||||
pre_overcloud_update_run_workarounds:
|
||||
- rhbz12:
|
||||
patch: false
|
||||
basedir: ''
|
||||
id: ''
|
||||
|
@ -32,7 +56,7 @@ pre_overcloud_update_run_workarounds:
|
|||
command: |
|
||||
cat /etc/redhat-release
|
||||
post_overcloud_update_converge_workarounds:
|
||||
- rhbz12:
|
||||
- rhbz13:
|
||||
patch: false
|
||||
basedir: ''
|
||||
id: ''
|
||||
|
|
|
@ -7,15 +7,45 @@ pre_undercloud_upgrade_workarounds:
|
|||
id: 112233
|
||||
command:
|
||||
- rhbz2:
|
||||
patch: true
|
||||
basedir: /home/stack/
|
||||
id: 112234
|
||||
command:
|
||||
- rhbz3:
|
||||
patch: false
|
||||
basedir: ''
|
||||
id: ''
|
||||
command: 'some command goes here'
|
||||
- rhbz3:
|
||||
patch: false
|
||||
containers: true
|
||||
environment: undercloud
|
||||
preparation_commands: |
|
||||
echo "Updates undercloud containers command"
|
||||
containers_file_modification:
|
||||
modify_role: tripleo-modify-image
|
||||
includes:
|
||||
- ironic-inspector
|
||||
modify_append_tag: "-updated"
|
||||
modify_vars:
|
||||
tasks_from: yum_update.yml
|
||||
compare_host_packages: true
|
||||
yum_repos_dir_path: /etc/yum.repos.d
|
||||
pre_overcloud_upgrade_prepare_workarounds:
|
||||
- rhbz4:
|
||||
patch: false
|
||||
containers: true
|
||||
environment: overcloud
|
||||
deploy_scripts: overcloud_upgrade_prepare.sh,overcloud_upgrade_converge.sh
|
||||
preparation_commands: |
|
||||
echo "Updates overcloud containers command"
|
||||
containers_file_modifications:
|
||||
modify_role: tripleo-modify-image
|
||||
includes:
|
||||
- rabbitmq
|
||||
- haproxy
|
||||
- maria
|
||||
- redis
|
||||
modify_append_tag: "-updated"
|
||||
modify_vars:
|
||||
tasks_from: yum_update.yml
|
||||
compare_host_packages: true
|
||||
yum_repos_dir_path: /etc/yum.repos.d
|
||||
post_undercloud_upgrade_workarounds:
|
||||
- rhbz10:
|
||||
patch: true
|
||||
|
|
Loading…
Reference in New Issue