rsync repo only for same sw-version

software-controller and sw-patch-controller both arbitrarily perform
repo rsync from the active controller. This operation deletes the newly
created to-release repo during a DX major release deploy, as the
to-release is first deployed to the standby controller.

This change applies the same change to both services, to verify that the
active controller is actually running the same sw-version before
performing rsync.

This change works together with [1]

TCs:
    passed: on a DX system, upgrade from 22.12 to 24.09 then patch to
            24.09 with success

Story: 2010676
Task: 51516

[1] https://review.opendev.org/c/starlingx/update/+/938409

Change-Id: I952d1633387512ccdc40dcbc8c062cbe8efedcd6
Signed-off-by: Bin Qian <bin.qian@windriver.com>
This commit is contained in:
Bin Qian 2025-01-09 14:18:07 +00:00
parent de60f803f9
commit d874c17af1
2 changed files with 42 additions and 8 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2023 Wind River Systems, Inc.
# Copyright (c) 2023-2025 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -52,10 +52,17 @@ function do_setup {
grep -xq "gpg-verify=false" $FEED_OSTREE_CONFIG || sed -i '$a gpg-verify=false' $FEED_OSTREE_CONFIG
grep -xq "gpg-verify=false" $SYSROOT_OSTREE_CONFIG || sed -i '$a gpg-verify=false' $SYSROOT_OSTREE_CONFIG
LOG "apt-ostree repo init --feed $REPO_DIR --release $RELEASE --origin $REPO_ID ..."
apt-ostree repo init \
--feed $REPO_DIR \
--release $RELEASE \
--origin $REPO_ID
if [ $? -eq 0 ]; then
LOG "... done"
else
LOG "... failed"
fi
fi
if [ ! -d $PATCHING_DIR ]; then
@ -76,13 +83,27 @@ function do_setup {
return 0
fi
# TODO(bqian) review this rsync below, it could break the atomic data sync mechanism
# Sync the software dir
LOG_TO_FILE "rsync -acv --delete rsync://controller/software/ ${PATCHING_DIR}/"
rsync -acv --delete rsync://controller/software/ ${PATCHING_DIR}/ >> $logfile 2>&1
# Sync the repo dir
LOG_TO_FILE "rsync -acv --delete rsync://controller/repo/ ${REPO_ROOT}/"
rsync -acv --delete rsync://controller/repo/ ${REPO_ROOT}/ >> $logfile 2>&1
# sync the repo from peer controller if both are running the same sw_version
tmp_dir=$(mktemp -d)
rsync -acv rsync://controller/platform/platform.conf ${tmp_dir}
my_tag="^sw_version=${SW_VERSION}$"
grep ${my_tag} ${tmp_dir}/platform.conf
rc=$?
rm ${tmp_dir}/platform.conf
rmdir ${tmp_dir}
if [ ${rc} -eq 0 ]; then
# Sync the repo dir
LOG_TO_FILE "rsync -acv --delete rsync://controller/repo/ ${REPO_ROOT}/"
rsync -acv --delete rsync://controller/repo/ ${REPO_ROOT}/ >> $logfile 2>&1
else
LOG "Skip rsync. Peer is not running the same software version"
fi
}
case "$1" in

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2014 Wind River Systems, Inc.
# Copyright (c) 2014-2025 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -66,9 +66,22 @@ function do_setup {
LOG_TO_FILE "rsync -acv --delete rsync://controller/patching/ ${PATCHING_DIR}/"
rsync -acv --delete rsync://controller/patching/ ${PATCHING_DIR}/ >> $logfile 2>&1
# Sync the patching dir
LOG_TO_FILE "rsync -acv --delete rsync://controller/repo/ ${REPO_ROOT}/"
rsync -acv --delete rsync://controller/repo/ ${REPO_ROOT}/ >> $logfile 2>&1
# sync the repo from peer controller if both are running the same sw_version
tmp_dir=$(mktemp -d)
rsync -acv rsync://controller/platform/platform.conf ${tmp_dir}
my_tag="^sw_version=${SW_VERSION}$"
grep ${my_tag} ${tmp_dir}/platform.conf
rc=$?
rm ${tmp_dir}/platform.conf
rmdir ${tmp_dir}
if [ ${rc} -eq 0 ]; then
# Sync the repo dir
LOG_TO_FILE "rsync -acv --delete rsync://controller/repo/ ${REPO_ROOT}/"
rsync -acv --delete rsync://controller/repo/ ${REPO_ROOT}/ >> $logfile 2>&1
else
LOG "Skip rsync. Peer is not running the same software version"
fi
}
case "$1" in