Files
update/software/debian/deb_folder/rules
Heitor Matsui c86d830872 Integrate lvm snapshot feature with upgrade process
This commit integrates the previously created lvm snapshot
code in [1], [2] and [3] with the upgrade/rollback process:

[1] https://review.opendev.org/c/starlingx/update/+/946371
[2] https://review.opendev.org/c/starlingx/update/+/946716
[3] https://review.opendev.org/c/starlingx/update/+/946835

NOTE: the feature is supported ONLY for AIO-SX for now
NOTE: the 'Depends-on' commit ensures that deploy precheck
      enforces the feature requirements are satisfied before
      allowing it to be enabled on deploy start
TODO: the snapshot removal after upgrade is successful will be
      implemented after the action 'delete' is included for
      the upgrade scripts; currently this is still in progress

- New functions are added to the lvm_snapshot module, to
  create and restore lvm snapshots safely, i.e.:
  - For snapshot creation, if it fails to create any snapshot
    then it will delete the others and proceed with the feature
    disabled
  - For snapshot restoration, it validates if all expected
    snapshots exists, if they aren't expired (not older than
    a time limit) and if they are valid (not 100% full) and
    only after all these conditions are satisfied the snapshots
    are restored. If any of them fail, rollback proceeds with
    the feature disabled
- Now, software controller effectively uses the --snapshot option
  to trigger snapshot creation during deploy start step
- lvm_snapshot.py module can be called as a standalone executable
  to allow it be called from deploy start script, reducing the
  dependenvy of the feature on the from-release code
- software controller restores the lvm snapshots during
  activate-rollback, so that the workflow is not changed (which
  is better from the point of view of orchestration)
- If lvm snapshot restoration fails, it will fall back to
  the standard activate-rollback procedure (upgrade scripts
  with action 'activate-rollback')
- Snapshots are now an object, and can override the default
  behavior of create/restore; one case was introduced to var-lv,
  to update software.json so that after host reboots the deployment
  data is correct

This commit also improve some log messages and remove deprecated code.

Test Plan
PASS: AIO-SX stx-10 -> stx-11 e2e upgrade with snapshot enabled
PASS: AIO-SX stx-10 -> stx-11 e2e rollback with snapshot enabled
PASS: AIO-SX stx-10 -> stx-11 e2e upgrade with snapshot disabled
PASS: AIO-SX stx-10 -> stx-11 e2e rollback with snapshot disabled
PASS: AIO-DX stx-10 -> stx-11, attempt to enable snapshot and
      verify deploy precheck blocks it
PASS: AIO-DX stx-10 -> stx-11 e2e upgrade with snapshot disabled

Depends-on: https://review.opendev.org/c/starlingx/update/+/946672

Story: 2011357
Task: 51981

Change-Id: I0759c424f9590947b349263a181a16e9d277741b
Signed-off-by: Heitor Matsui <heitorvieira.matsui@windriver.com>
2025-05-23 17:19:39 -03:00

105 lines
4.3 KiB
Makefile
Executable File

#!/usr/bin/make -f
export DH_VERBOSE = 1
export PYBUILD_NAME = software
export PBR_VERSION=1.0.0
ROOT := $(CURDIR)/debian/tmp
PMONDIR := ${ROOT}/usr/share/starlingx/pmon.d
SBINDIR := ${ROOT}/usr/sbin
SCRIPTDIR := ${SBINDIR}/software-deploy
export PLATFORM_RELEASE="$(shell grep SW_VERSION /usr/include/build_info.h | cut -d ' ' -f 3)"
export METADATA_FILE="starlingx-${PLATFORM_RELEASE}.0-metadata.xml"
%:
dh $@ --with python3 --buildsystem=pybuild
override_dh_auto_build:
cp service-files/starlingx-GA-metadata.xml ${METADATA_FILE}
sed -i "s/xxxPLATFORM_RELEASExxx/${PLATFORM_RELEASE}/g" ${METADATA_FILE}
sed -i "s/xxxPLATFORM_RELEASExxx/${PLATFORM_RELEASE}/g" software/utilities/constants.py
override_dh_install:
python3 setup.py install -f --install-layout=deb --root=$(ROOT)
python3 setup.py bdist_wheel --universal -d $(CURDIR)/debian/$(PYBUILD_NAME)-wheels/usr/share/python-wheels
install -d -m 755 $(ROOT)/usr/bin
install -d -m 755 ${SBINDIR}
install -d -m 755 ${SCRIPTDIR}
install -d -m 755 $(ROOT)/run
install -m 755 -d ${ROOT}/etc/goenabled.d
install -m 755 -d ${ROOT}/etc/init.d
install -m 755 -d ${ROOT}/etc/logrotate.d
install -m 755 -d ${ROOT}/etc/software
install -m 755 -d ${ROOT}/etc/software/software-scripts
install -m 755 -d ${ROOT}/lib/systemd/system
install -m 755 -d ${ROOT}/var/persist/software-agent
install -m 755 -d ${PMONDIR}
install -m 500 service-files/software-controller-daemon-init.sh \
${ROOT}/etc/init.d/software-controller-daemon
install -m 500 service-files/software-agent-init.sh \
${ROOT}/etc/init.d/software-agent
install -m 500 service-files/software-init.sh \
${ROOT}/etc/init.d/software
install -m 500 service-files/software-controller-init.sh \
${ROOT}/etc/init.d/software-controller
install -m 500 service-files/usm-initialize-init.sh \
${ROOT}/etc/init.d/usm-initialize
install -m 600 service-files/software.conf \
${ROOT}/etc/software/software.conf
install -m 644 service-files/policy.json \
${ROOT}/etc/software/policy.json
install -m 444 service-files/pmon-software-controller-daemon.conf \
${PMONDIR}/software-controller-daemon.conf
install -m 444 service-files/pmon-software-agent.conf \
${PMONDIR}/software-agent.conf
install -m 444 service-files/*.service \
${ROOT}/lib/systemd/system
install -m 400 service-files/software-functions \
${ROOT}/etc/software/software-functions
install -m 444 service-files/software-tmpdirs.conf \
${ROOT}/run/software-tmpdirs.conf
install -m 500 service-files/run-software-scripts \
${SBINDIR}/run-software-scripts
install -m 500 service-files/software-controller-daemon-restart \
${SBINDIR}/software-controller-daemon-restart
install -m 500 service-files/software-agent-restart \
${SBINDIR}/software-agent-restart
install -m 555 service-files/software_check_goenabled.sh \
${ROOT}/etc/goenabled.d/software_check_goenabled.sh
install -m 444 service-files/software.logrotate \
${ROOT}/etc/logrotate.d/software
install -m 444 ${METADATA_FILE} \
${ROOT}/etc/software/${METADATA_FILE}
install -m 755 scripts/controllers-software-sync \
${SCRIPTDIR}/controllers-software-sync
install -m 755 scripts/deploy-precheck \
${SCRIPTDIR}/deploy-precheck
install -m 755 scripts/deploy-start \
${SCRIPTDIR}/deploy-start
install -m 444 scripts/upgrade_utils.py \
${SCRIPTDIR}/upgrade_utils.py
install -m 755 scripts/prepare-data-migration \
${SCRIPTDIR}/prepare-data-migration
install -m 755 scripts/prepare-chroot-mounts \
${SCRIPTDIR}/prepare-chroot-mounts
install -m 755 scripts/create-postgres-database \
${SCRIPTDIR}/create-postgres-database
install -m 755 scripts/major-release-upload \
${SCRIPTDIR}/major-release-upload
install -m 755 scripts/sync-controllers-feed \
${SCRIPTDIR}/sync-controllers-feed
install -m 755 scripts/remove-temporary-data \
${SCRIPTDIR}/remove-temporary-data
install -m 755 software/lvm_snapshot.py \
${SCRIPTDIR}/manage-lvm-snapshots
install -d -m 755 $(ROOT)/usr/local/share/upgrade.d
install -p -D -m 755 upgrade-scripts/* $(ROOT)/usr/local/share/upgrade.d
install -d -m 755 $(ROOT)/etc/update.d
# TODO(heitormatsui): following lines are for backward compatibility and can be removed in stx-12
cd ${SCRIPTDIR} ; ln -sf major-release-upload usm_load_import
cd ${SCRIPTDIR} ; ln -sf deploy-start software-deploy-start
dh_install
override_dh_usrlocal: