90 lines
4.2 KiB
Django/Jinja
90 lines
4.2 KiB
Django/Jinja
#!/bin/bash
|
|
#
|
|
# Apply upgrade workarounds
|
|
set -euo pipefail
|
|
|
|
function apply_patch {
|
|
local patch_dir=$1
|
|
local patch_id=$2
|
|
local temp_dir=''
|
|
|
|
temp_dir=$( mktemp -d )
|
|
|
|
curl -4 --retry 5 https://review.opendev.org/changes/${patch_id}/revisions/current/patch?download | \
|
|
base64 -d > ${temp_dir}/patch.txt
|
|
|
|
if [[ ${?} -ne 0 ]] ; then
|
|
echo "Failed to download patch https://review.opendev.org/#/c/${patch_id}/"
|
|
exit 1
|
|
fi
|
|
|
|
if sudo patch --dry-run --force -d ${patch_dir} -p1 < ${temp_dir}/patch.txt >/dev/null 2>&1
|
|
then
|
|
sudo patch -Ns -d ${patch_dir} -p1 < ${temp_dir}/patch.txt
|
|
else
|
|
echo "Patch ${patch_id} fails to apply - either already applied or you need to fix it."
|
|
fi
|
|
|
|
sudo rm -Rf ${temp_dir}/
|
|
|
|
}
|
|
|
|
{% macro render_workarounds(workaround_var, workaround_name) -%}
|
|
{% if workaround_name in item -%}
|
|
{% for bugs in workaround_var -%}
|
|
{% for key, value in bugs.items() -%}
|
|
echo {{ key }}
|
|
{% if value.patch -%}
|
|
apply_patch {{ value.basedir }} {{ value.id }}
|
|
{% else -%}
|
|
{{ value.command }}
|
|
{% endif -%}
|
|
################################################################################
|
|
{% endfor -%}
|
|
{% endfor -%}
|
|
{% endif -%}
|
|
{% endmacro -%}
|
|
|
|
{% if upgrade_workarounds|bool -%}
|
|
{{ render_workarounds(pre_undercloud_upgrade_workarounds|default([]),'pre_undercloud_upgrade_workarounds') }}
|
|
{# finish pre_undercloud_upgrade_workarounds #}
|
|
{{ render_workarounds(post_undercloud_upgrade_workarounds|default([]),'post_undercloud_upgrade_workarounds') }}
|
|
{# finish post_undercloud_upgrade_workarounds #}
|
|
{{ render_workarounds(pre_overcloud_upgrade_prepare_workarounds|default([]),'pre_overcloud_upgrade_prepare_workarounds') }}
|
|
{# finish pre_overcloud_upgrade_prepare_workarounds #}
|
|
{{ render_workarounds(post_overcloud_upgrade_prepare_workarounds|default([]),'post_overcloud_upgrade_prepare_workarounds') }}
|
|
{# finish post_overcloud_upgrade_prepare_workarounds #}
|
|
{{ render_workarounds(pre_overcloud_upgrade_workarounds|default([]),'pre_overcloud_upgrade_workarounds') }}
|
|
{# finish pre_overcloud_upgrade_workarounds #}
|
|
{{ render_workarounds(post_overcloud_upgrade_workarounds|default([]),'post_overcloud_upgrade_workarounds') }}
|
|
{# finish post_overcloud_upgrade_workarounds #}
|
|
{{ render_workarounds(pre_overcloud_upgrade_converge_workarounds|default([]),'pre_overcloud_upgrade_converge_workarounds') }}
|
|
{# finish pre_overcloud_upgrade_converge_workarounds #}
|
|
{{ render_workarounds(post_overcloud_upgrade_converge_workarounds|default([]),'post_overcloud_upgrade_converge_workarounds') }}
|
|
{# finish post_overcloud_upgrade_converge_workarounds #}
|
|
{{ render_workarounds(pre_ceph_upgrade_workarounds|default([]),'pre_ceph_upgrade_workarounds') }}
|
|
{# finish pre_ceph_upgrade_workarounds #}
|
|
{{ render_workarounds(post_ceph_upgrade_workarounds|default([]),'post_ceph_upgrade_workarounds') }}
|
|
{# finish post_ceph_upgrade_workarounds #}
|
|
{% endif -%}
|
|
|
|
{% if updates_workarounds|bool -%}
|
|
# Render for Updates
|
|
{{ render_workarounds(pre_undercloud_update_workarounds|default([]),'pre_undercloud_update_workarounds') }}
|
|
{# finish pre_undercloud_update_workarounds #}
|
|
{{ render_workarounds(post_undercloud_update_workarounds|default([]),'post_undercloud_update_workarounds') }}
|
|
{# finish post_undercloud_update_workarounds #}
|
|
{{ render_workarounds(pre_overcloud_update_prepare_workarounds|default([]),'pre_overcloud_update_prepare_workarounds') }}
|
|
{# finish pre_overcloud_update_prepare_workarounds #}
|
|
{{ render_workarounds(post_overcloud_update_prepare_workarounds|default([]),'post_overcloud_update_prepare_workarounds') }}
|
|
{# finish post_overcloud_update_prepare_workarounds #}
|
|
{{ render_workarounds(pre_overcloud_update_run_workarounds|default([]),'pre_overcloud_update_run_workarounds') }}
|
|
{# finish pre_overcloud_update_run_workarounds #}
|
|
{{ render_workarounds(post_overcloud_update_run_workarounds|default([]),'post_overcloud_update_run_workarounds') }}
|
|
{# finish post_overcloud_update_run_workarounds #}
|
|
{{ render_workarounds(pre_overcloud_update_converge_workarounds|default([]),'pre_overcloud_update_converge_workarounds') }}
|
|
{# finish pre_overcloud_update_converge_workarounds #}
|
|
{{ render_workarounds(post_overcloud_update_converge_workarounds|default([]),'post_overcloud_update_converge_workarounds') }}
|
|
{# finish post_overcloud_update_converge_workarounds #}
|
|
{% endif -%}
|