From d874c17af14b52e60238d75596d654723e0dd238 Mon Sep 17 00:00:00 2001 From: Bin Qian Date: Thu, 9 Jan 2025 14:18:07 +0000 Subject: [PATCH] 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 --- .../service-files/software-controller-init.sh | 29 ++++++++++++++++--- sw-patch/bin/sw-patch-controller-init.sh | 21 +++++++++++--- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/software/service-files/software-controller-init.sh b/software/service-files/software-controller-init.sh index 59bd5a8d..7868c337 100644 --- a/software/service-files/software-controller-init.sh +++ b/software/service-files/software-controller-init.sh @@ -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 diff --git a/sw-patch/bin/sw-patch-controller-init.sh b/sw-patch/bin/sw-patch-controller-init.sh index 3650833b..1f58ef3f 100644 --- a/sw-patch/bin/sw-patch-controller-init.sh +++ b/sw-patch/bin/sw-patch-controller-init.sh @@ -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