From bbc83cec3e3616d0284fe649505a9cf8eb4942e1 Mon Sep 17 00:00:00 2001 From: Sriram Narasimhan Date: Mon, 24 Jul 2023 09:13:55 -0400 Subject: [PATCH] Add script to refresh deploy plug-in post upgrade Wrapper script is created to upgrade deploy plug-in automatically post upgrade. This invokes update deploy plug-in script that runs ansible playbook to refresh deploy plug-in. Test Plan: PASS: Verify deploy plug-in is upgraded after script execution. - Perform the platform upgrade procedure - Copy upgrade wrapper script to /etc/upgrade.d/ before executing 'system upgrade-activate' - Continue the platform upgrade procedure for completion - Check deploy plug-in is refreshed PASS: Verify script logs generated in /var/log/platform.log Story: 2010718 Task: 48455 Depends-On: https://review.opendev.org/c/starlingx/utilities/+/889402 Change-Id: I2374b8d24fd36fb69facbe60caac5dd4d302be7e Signed-off-by: Sriram Narasimhan --- .../upgrade-scripts/91-upgrade-dm.sh | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 controllerconfig/controllerconfig/upgrade-scripts/91-upgrade-dm.sh diff --git a/controllerconfig/controllerconfig/upgrade-scripts/91-upgrade-dm.sh b/controllerconfig/controllerconfig/upgrade-scripts/91-upgrade-dm.sh new file mode 100755 index 0000000000..4046d96a6e --- /dev/null +++ b/controllerconfig/controllerconfig/upgrade-scripts/91-upgrade-dm.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# Copyright (c) 2023 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +# This migration script is used to refresh deploy plug-in +# during the activate stage of a platform upgrade. + +# The migration scripts are passed these parameters: +NAME=$(basename $0) +FROM_RELEASE=$1 +TO_RELEASE=$2 +ACTION=$3 + +# This will log to /var/log/platform.log +function log { + logger -p local1.info "$1" +} + +DEPLOY_PLAYBOOK=$(ls /usr/local/share/applications/playbooks/*deployment-manager.yaml 2> /dev/null) +DEPLOY_CHART=$(ls /usr/local/share/applications/helm/*deployment-manager*.tgz 2> /dev/null) +DEPLOY_OVERRIDES=$(ls /usr/local/share/applications/overrides/*deployment-manager-overrides.yaml 2> /dev/null) +REFRESH_DM_IMAGES="false" + +if [[ "${ACTION}" == "activate" ]]; then + if [[ -z "${DEPLOY_OVERRIDES}" ]] || [[ -z "${DEPLOY_PLAYBOOK}" ]] || [[ -z "${DEPLOY_CHART}" ]]; then + log "$NAME: script execution is skipped. There are no deploy files." + else + log "$NAME: Refreshing deploy plug-in from $FROM_RELEASE to $TO_RELEASE" + /usr/local/bin/update-dm.sh ${DEPLOY_PLAYBOOK} ${DEPLOY_CHART} ${DEPLOY_OVERRIDES} ${REFRESH_DM_IMAGES} + exit $? + fi +else + log "$NAME: No actions required for from release $FROM_RELEASE to $TO_RELEASE with action $ACTION" +fi + +exit 0