From a555f16de52e3017c9de42b074a6a40113ac2883 Mon Sep 17 00:00:00 2001 From: Lindley Vieira Date: Tue, 9 Sep 2025 12:20:10 -0400 Subject: [PATCH] Inservice post-install script Adding a post-install for an inservice patch to restart all services during host install to make the changes live. If it is the active controller, the software-controller cannot be restarted at this time, so leaves a flag for it to be restarted during activate step. Test-Plan SX/DX: PASS: Run an inservice patch with this script and check if the changes are applied PASS: Apply an inservice patch pre-bootstrap Story: 2010676 Task: 52804 Change-Id: Id5b853cea0f80af6124c45aab231c44c34d65576 Signed-off-by: Lindley Vieira --- .../install-scripts/24.09.400/post-install.sh | 85 +++++++++++++++++++ patch-scripts/install-scripts/README.md | 73 ++++++++++++++++ .../EXAMPLE_0001/scripts/example-restart | 0 .../scripts/example-cgcs-patch-restart | 0 .../scripts/distcloud-restart-example | 0 .../scripts/dockerd-process-restart | 0 .../scripts/kubelet-restart-example | 0 .../EXAMPLE_MTCE/scripts/mtce-restart-example | 0 .../scripts/service-process-restart | 0 .../scripts/sysinv-restart-example | 0 .../EXAMPLE_VIM/scripts/vim-restart-example | 0 .../SUITE_B_PATCH_A/scripts/restart-script | 0 .../SUITE_B_PATCH_B/scripts/restart-script | 0 .../SUITE_B_PATCH_C/scripts/restart-script | 0 .../SUITE_B_PATCH_D/scripts/restart-script | 0 .../SUITE_B_PATCH_E/scripts/restart-script | 0 .../SUITE_B_PATCH_F/scripts/restart-script | 0 .../INSVC_ALLNODES/scripts/allnodes-restart | 0 .../INSVC_COMPUTE/scripts/compute-restart | 0 .../scripts/controller-restart | 0 .../scripts/restart-failure | 0 .../INSVC_STORAGE/scripts/storage-restart | 0 22 files changed, 158 insertions(+) create mode 100644 patch-scripts/install-scripts/24.09.400/post-install.sh create mode 100644 patch-scripts/install-scripts/README.md rename patch-scripts/{ => install-scripts/examples}/EXAMPLE_0001/scripts/example-restart (100%) rename patch-scripts/{ => install-scripts/examples}/EXAMPLE_0002/scripts/example-cgcs-patch-restart (100%) rename patch-scripts/{ => install-scripts/examples}/EXAMPLE_DC/scripts/distcloud-restart-example (100%) rename patch-scripts/{ => install-scripts/examples}/EXAMPLE_DOCKER/scripts/dockerd-process-restart (100%) rename patch-scripts/{ => install-scripts/examples}/EXAMPLE_KUBELET/scripts/kubelet-restart-example (100%) rename patch-scripts/{ => install-scripts/examples}/EXAMPLE_MTCE/scripts/mtce-restart-example (100%) rename patch-scripts/{ => install-scripts/examples}/EXAMPLE_SERVICE/scripts/service-process-restart (100%) rename patch-scripts/{ => install-scripts/examples}/EXAMPLE_SYSINV/scripts/sysinv-restart-example (100%) rename patch-scripts/{ => install-scripts/examples}/EXAMPLE_VIM/scripts/vim-restart-example (100%) rename patch-scripts/{ => install-scripts/examples}/test-patches-suite-b/SUITE_B_PATCH_A/scripts/restart-script (100%) rename patch-scripts/{ => install-scripts/examples}/test-patches-suite-b/SUITE_B_PATCH_B/scripts/restart-script (100%) rename patch-scripts/{ => install-scripts/examples}/test-patches-suite-b/SUITE_B_PATCH_C/scripts/restart-script (100%) rename patch-scripts/{ => install-scripts/examples}/test-patches-suite-b/SUITE_B_PATCH_D/scripts/restart-script (100%) rename patch-scripts/{ => install-scripts/examples}/test-patches-suite-b/SUITE_B_PATCH_E/scripts/restart-script (100%) rename patch-scripts/{ => install-scripts/examples}/test-patches-suite-b/SUITE_B_PATCH_F/scripts/restart-script (100%) rename patch-scripts/{ => install-scripts/examples}/test-patches/INSVC_ALLNODES/scripts/allnodes-restart (100%) rename patch-scripts/{ => install-scripts/examples}/test-patches/INSVC_COMPUTE/scripts/compute-restart (100%) rename patch-scripts/{ => install-scripts/examples}/test-patches/INSVC_CONTROLLER/scripts/controller-restart (100%) rename patch-scripts/{ => install-scripts/examples}/test-patches/INSVC_RESTART_FAILURE/scripts/restart-failure (100%) rename patch-scripts/{ => install-scripts/examples}/test-patches/INSVC_STORAGE/scripts/storage-restart (100%) diff --git a/patch-scripts/install-scripts/24.09.400/post-install.sh b/patch-scripts/install-scripts/24.09.400/post-install.sh new file mode 100644 index 00000000..0edf4329 --- /dev/null +++ b/patch-scripts/install-scripts/24.09.400/post-install.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# +# Copyright (c) 2025 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +# Source platform.conf, for nodetype and subfunctions +. /etc/platform/platform.conf + +PATCH_STATUS_OK=0 +PATCH_STATUS_FAILED=1 + +logfile="/var/log/software.log" +NAME=$(basename "$0") + +CREDENTIAL_FILE="/opt/platform/.keyring/24.09/.CREDENTIAL" +BOOTSTRAP_COMPLETED_FLAG="/etc/platform/.bootstrap_completed" +INITIAL_CONFIG_COMPLETE_FLAG="/etc/platform/.initial_config_complete" +RESTART_SERVICES_FLAG="/run/software/.activate.restart-services.flag" + +loginfo() { + echo "$(date "+%FT%T.%3N"): $NAME: $*" >> "$logfile" +} + +is_active_controller() { + [[ "$nodetype" == "controller" && -f "$CREDENTIAL_FILE" ]] +} + +is_standby_controller() { + [[ "$nodetype" == "controller" && ! -f "$CREDENTIAL_FILE" ]] +} + +not_controller() { + [[ "$nodetype" != "controller" ]] +} + +# Check if /etc is a bind mount +BIND_SOURCE=$(findmnt /etc -n -o SOURCE) +if [[ -z "$BIND_SOURCE" ]]; then + loginfo "Not an inservice patch, exiting" + exit "$PATCH_STATUS_OK" +fi + +# Pre-bootstrap does not need to restart services since it will be unlocked later +if [ ! -f "$BOOTSTRAP_COMPLETED_FLAG" ] && [ ! -f "$INITIAL_CONFIG_COMPLETE_FLAG"]; then + loginfo "Pre-bootstrap, exiting" + exit "$PATCH_STATUS_OK" +fi + +### Services to restart in all nodes +# Set flag to restart software-agent +touch /run/software/.restart.software-agent + +### Services to restart only in the active controller +if is_active_controller; then + loginfo "Running in the active controller" + + # Let a flag for vim, vim-api, and software-controller + # services to be restarted during activate + touch "$RESTART_SERVICES_FLAG" + + sm-restart-safe service sysinv-conductor + + exit "$PATCH_STATUS_OK" +fi + +### Services to restart only in the standby controller +if is_standby_controller; then + loginfo "Running in the standby controller" + + # It is safe to restart software-controller in the standby controller + pmon-restart software-controller-daemon + + exit "$PATCH_STATUS_OK" +fi + +### Services to restart only in non-controller nodes +if not_controller; then + loginfo "Running in non-controller node" + + exit "$PATCH_STATUS_OK" +fi + +exit "$PATCH_STATUS_OK" diff --git a/patch-scripts/install-scripts/README.md b/patch-scripts/install-scripts/README.md new file mode 100644 index 00000000..44b409dc --- /dev/null +++ b/patch-scripts/install-scripts/README.md @@ -0,0 +1,73 @@ +# Install Scripts Management + +This repository manages **pre-install** and **post-install** shell scripts used in the patch deployment process. +They run for each patch at the beginning and at the end of `software deploy host` for both inservice and reboot required patches. + +## Folder Structure + +``` +install-scripts/ +├── boilerplate/ +│ ├── pre-install.sh +│ └── post-install.sh +├── 24.09.400/ +│ ├── pre-install.sh +│ └── post-install.sh +├── examples/ +└── ... +``` + +- `boilerplate/`: + Contains the **default scripts**. These are the standard versions used for most software releases. + +- `MM.mm.pp/`: + Contains **version-specific scripts**, only when changes are required that differ from the boilerplate. + +- `examples/`: + Contains **previous scripts examples**. Scripts used in old releases. + +--- + +## Usage + +### Default Case + +If the pre and post install steps remain unchanged: +- Use the scripts in the `boilerplate/` folder. +- No need to create a version-specific directory. + +### When Customization Is Needed + +If any version of the software requires changes to the install scripts: + +1. **Create a version folder** (e.g., `24.09.400/`): + ```bash + mkdir install-scripts/24.09.400 + ``` + +2. **Copy the boilerplate scripts**: + ```bash + cp install-scripts/boilerplate/*.sh start-scripts/24.09.400/ + ``` + +3. **Edit the scripts** in `24.09.400/` as needed. + +> Always start from the boilerplate to ensure consistency. + +--- + +## Tips + +- **Include comments** in versioned scripts, noting what the change is doing. +- Use previous versions as examples of what these scripts can do. + +--- + +## License + +Include the license in all scripts + +``` +Copyright (c) 2025 Wind River Systems, Inc. +SPDX-License-Identifier: Apache-2.0 +``` diff --git a/patch-scripts/EXAMPLE_0001/scripts/example-restart b/patch-scripts/install-scripts/examples/EXAMPLE_0001/scripts/example-restart similarity index 100% rename from patch-scripts/EXAMPLE_0001/scripts/example-restart rename to patch-scripts/install-scripts/examples/EXAMPLE_0001/scripts/example-restart diff --git a/patch-scripts/EXAMPLE_0002/scripts/example-cgcs-patch-restart b/patch-scripts/install-scripts/examples/EXAMPLE_0002/scripts/example-cgcs-patch-restart similarity index 100% rename from patch-scripts/EXAMPLE_0002/scripts/example-cgcs-patch-restart rename to patch-scripts/install-scripts/examples/EXAMPLE_0002/scripts/example-cgcs-patch-restart diff --git a/patch-scripts/EXAMPLE_DC/scripts/distcloud-restart-example b/patch-scripts/install-scripts/examples/EXAMPLE_DC/scripts/distcloud-restart-example similarity index 100% rename from patch-scripts/EXAMPLE_DC/scripts/distcloud-restart-example rename to patch-scripts/install-scripts/examples/EXAMPLE_DC/scripts/distcloud-restart-example diff --git a/patch-scripts/EXAMPLE_DOCKER/scripts/dockerd-process-restart b/patch-scripts/install-scripts/examples/EXAMPLE_DOCKER/scripts/dockerd-process-restart similarity index 100% rename from patch-scripts/EXAMPLE_DOCKER/scripts/dockerd-process-restart rename to patch-scripts/install-scripts/examples/EXAMPLE_DOCKER/scripts/dockerd-process-restart diff --git a/patch-scripts/EXAMPLE_KUBELET/scripts/kubelet-restart-example b/patch-scripts/install-scripts/examples/EXAMPLE_KUBELET/scripts/kubelet-restart-example similarity index 100% rename from patch-scripts/EXAMPLE_KUBELET/scripts/kubelet-restart-example rename to patch-scripts/install-scripts/examples/EXAMPLE_KUBELET/scripts/kubelet-restart-example diff --git a/patch-scripts/EXAMPLE_MTCE/scripts/mtce-restart-example b/patch-scripts/install-scripts/examples/EXAMPLE_MTCE/scripts/mtce-restart-example similarity index 100% rename from patch-scripts/EXAMPLE_MTCE/scripts/mtce-restart-example rename to patch-scripts/install-scripts/examples/EXAMPLE_MTCE/scripts/mtce-restart-example diff --git a/patch-scripts/EXAMPLE_SERVICE/scripts/service-process-restart b/patch-scripts/install-scripts/examples/EXAMPLE_SERVICE/scripts/service-process-restart similarity index 100% rename from patch-scripts/EXAMPLE_SERVICE/scripts/service-process-restart rename to patch-scripts/install-scripts/examples/EXAMPLE_SERVICE/scripts/service-process-restart diff --git a/patch-scripts/EXAMPLE_SYSINV/scripts/sysinv-restart-example b/patch-scripts/install-scripts/examples/EXAMPLE_SYSINV/scripts/sysinv-restart-example similarity index 100% rename from patch-scripts/EXAMPLE_SYSINV/scripts/sysinv-restart-example rename to patch-scripts/install-scripts/examples/EXAMPLE_SYSINV/scripts/sysinv-restart-example diff --git a/patch-scripts/EXAMPLE_VIM/scripts/vim-restart-example b/patch-scripts/install-scripts/examples/EXAMPLE_VIM/scripts/vim-restart-example similarity index 100% rename from patch-scripts/EXAMPLE_VIM/scripts/vim-restart-example rename to patch-scripts/install-scripts/examples/EXAMPLE_VIM/scripts/vim-restart-example diff --git a/patch-scripts/test-patches-suite-b/SUITE_B_PATCH_A/scripts/restart-script b/patch-scripts/install-scripts/examples/test-patches-suite-b/SUITE_B_PATCH_A/scripts/restart-script similarity index 100% rename from patch-scripts/test-patches-suite-b/SUITE_B_PATCH_A/scripts/restart-script rename to patch-scripts/install-scripts/examples/test-patches-suite-b/SUITE_B_PATCH_A/scripts/restart-script diff --git a/patch-scripts/test-patches-suite-b/SUITE_B_PATCH_B/scripts/restart-script b/patch-scripts/install-scripts/examples/test-patches-suite-b/SUITE_B_PATCH_B/scripts/restart-script similarity index 100% rename from patch-scripts/test-patches-suite-b/SUITE_B_PATCH_B/scripts/restart-script rename to patch-scripts/install-scripts/examples/test-patches-suite-b/SUITE_B_PATCH_B/scripts/restart-script diff --git a/patch-scripts/test-patches-suite-b/SUITE_B_PATCH_C/scripts/restart-script b/patch-scripts/install-scripts/examples/test-patches-suite-b/SUITE_B_PATCH_C/scripts/restart-script similarity index 100% rename from patch-scripts/test-patches-suite-b/SUITE_B_PATCH_C/scripts/restart-script rename to patch-scripts/install-scripts/examples/test-patches-suite-b/SUITE_B_PATCH_C/scripts/restart-script diff --git a/patch-scripts/test-patches-suite-b/SUITE_B_PATCH_D/scripts/restart-script b/patch-scripts/install-scripts/examples/test-patches-suite-b/SUITE_B_PATCH_D/scripts/restart-script similarity index 100% rename from patch-scripts/test-patches-suite-b/SUITE_B_PATCH_D/scripts/restart-script rename to patch-scripts/install-scripts/examples/test-patches-suite-b/SUITE_B_PATCH_D/scripts/restart-script diff --git a/patch-scripts/test-patches-suite-b/SUITE_B_PATCH_E/scripts/restart-script b/patch-scripts/install-scripts/examples/test-patches-suite-b/SUITE_B_PATCH_E/scripts/restart-script similarity index 100% rename from patch-scripts/test-patches-suite-b/SUITE_B_PATCH_E/scripts/restart-script rename to patch-scripts/install-scripts/examples/test-patches-suite-b/SUITE_B_PATCH_E/scripts/restart-script diff --git a/patch-scripts/test-patches-suite-b/SUITE_B_PATCH_F/scripts/restart-script b/patch-scripts/install-scripts/examples/test-patches-suite-b/SUITE_B_PATCH_F/scripts/restart-script similarity index 100% rename from patch-scripts/test-patches-suite-b/SUITE_B_PATCH_F/scripts/restart-script rename to patch-scripts/install-scripts/examples/test-patches-suite-b/SUITE_B_PATCH_F/scripts/restart-script diff --git a/patch-scripts/test-patches/INSVC_ALLNODES/scripts/allnodes-restart b/patch-scripts/install-scripts/examples/test-patches/INSVC_ALLNODES/scripts/allnodes-restart similarity index 100% rename from patch-scripts/test-patches/INSVC_ALLNODES/scripts/allnodes-restart rename to patch-scripts/install-scripts/examples/test-patches/INSVC_ALLNODES/scripts/allnodes-restart diff --git a/patch-scripts/test-patches/INSVC_COMPUTE/scripts/compute-restart b/patch-scripts/install-scripts/examples/test-patches/INSVC_COMPUTE/scripts/compute-restart similarity index 100% rename from patch-scripts/test-patches/INSVC_COMPUTE/scripts/compute-restart rename to patch-scripts/install-scripts/examples/test-patches/INSVC_COMPUTE/scripts/compute-restart diff --git a/patch-scripts/test-patches/INSVC_CONTROLLER/scripts/controller-restart b/patch-scripts/install-scripts/examples/test-patches/INSVC_CONTROLLER/scripts/controller-restart similarity index 100% rename from patch-scripts/test-patches/INSVC_CONTROLLER/scripts/controller-restart rename to patch-scripts/install-scripts/examples/test-patches/INSVC_CONTROLLER/scripts/controller-restart diff --git a/patch-scripts/test-patches/INSVC_RESTART_FAILURE/scripts/restart-failure b/patch-scripts/install-scripts/examples/test-patches/INSVC_RESTART_FAILURE/scripts/restart-failure similarity index 100% rename from patch-scripts/test-patches/INSVC_RESTART_FAILURE/scripts/restart-failure rename to patch-scripts/install-scripts/examples/test-patches/INSVC_RESTART_FAILURE/scripts/restart-failure diff --git a/patch-scripts/test-patches/INSVC_STORAGE/scripts/storage-restart b/patch-scripts/install-scripts/examples/test-patches/INSVC_STORAGE/scripts/storage-restart similarity index 100% rename from patch-scripts/test-patches/INSVC_STORAGE/scripts/storage-restart rename to patch-scripts/install-scripts/examples/test-patches/INSVC_STORAGE/scripts/storage-restart