From ad0cf94b46cb8fc21d9fbd3ce52dbcbbb7566fa7 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 21 Nov 2025 15:35:30 +0100 Subject: [PATCH] MT#63742 Add new post-build script to handle database actions We will use this new action to handle database actions that are currently done in the commit action. These need to be performed after build and before service, so that any service restart will have the correct grants and schema changes to be able to operate correctly. Change-Id: Ia13c40bcd219902fa523f989d3f1f686fdff93a1 --- debian/ngcp-ngcpcfg.install | 1 + docs/ngcpcfg.txt | 22 +++++++++++++++------- scripts/apply | 3 +++ scripts/post-build | 26 ++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 7 deletions(-) create mode 100755 scripts/post-build diff --git a/debian/ngcp-ngcpcfg.install b/debian/ngcp-ngcpcfg.install index 04411140..265fc628 100644 --- a/debian/ngcp-ngcpcfg.install +++ b/debian/ngcp-ngcpcfg.install @@ -36,6 +36,7 @@ scripts/get usr/share/ngcp-ngcpcfg/scripts/ scripts/initialise usr/share/ngcp-ngcpcfg/scripts/ scripts/log usr/share/ngcp-ngcpcfg/scripts/ scripts/patch usr/share/ngcp-ngcpcfg/scripts/ +scripts/post-build usr/share/ngcp-ngcpcfg/scripts/ scripts/services usr/share/ngcp-ngcpcfg/scripts/ scripts/set usr/share/ngcp-ngcpcfg/scripts/ scripts/show usr/share/ngcp-ngcpcfg/scripts/ diff --git a/docs/ngcpcfg.txt b/docs/ngcpcfg.txt index 60109b24..3a4802a9 100644 --- a/docs/ngcpcfg.txt +++ b/docs/ngcpcfg.txt @@ -311,13 +311,14 @@ Actions and action specific options **apply** [--dry-run] [--force-all-services] [--ignore-branch-check] [--ignore-shared-storage-check] [--modified-only] []:: -Executes the _check_, _build_, _services_ and _commit_ commands in a batch -(assuming each command worked as expected). This option serves as a shortcut for -the most commonly executed commands. If there are any outstanding changes that -need to be committed, then the commit message needs to be provided. This is -meant so the configuration change history (accessible e.g. via 'ngcpcfg log') -provides useful information. -Options for _services_, _build_ and _check_ can be used here too. +Executes the _check_, _build_, _post-build_, _services_ and _commit_ commands +in a batch (assuming each command worked as expected). +This option serves as a shortcut for the most commonly executed commands. +If there are any outstanding changes that need to be committed, +then the commit message needs to be provided. +This is meant so the configuration change history +(accessible e.g. via 'ngcpcfg log') provides useful information. +Options for _check_, _build_ and _services_ can be used here too. **cat** [...]:: @@ -366,6 +367,12 @@ shell globbing patterns - so argument 'mo..t' will match the files You can combine __ and __ and use multiple arguments. + **post-build**:: + +Performs needed actions after building the files, and before starting the +services, such as synchronizing the database credentials or updating its +timestamps. + **clean** [--all] [--branches] [--force] [--help] [--reset-master] [--stashes] [--tracked-files] [--untracked-files]:: Clean ngcpcfg from not-yet committed/applied changes, reset git state and remove @@ -609,6 +616,7 @@ The main workflow *with* High Availability setup is: ngcpcfg pull # retrieve possibly pending updates $EDITOR /etc/ngcp-config/config.yml # adjust/extend configuration ngcpcfg build # generate/update configuration files + ngcpcfg post-build # perform post build actions ngcpcfg services # restart services for modified configs ngcpcfg commit "summary of changes" # register changes ngcpcfg push # upload changes to shared storage + remote systems diff --git a/scripts/apply b/scripts/apply index 05e20834..cd40f1be 100755 --- a/scripts/apply +++ b/scripts/apply @@ -65,6 +65,9 @@ if ! ${DRYRUN} && check_for_outstanding_commits && [ -z "${1:-}" ] ; then fi "${SCRIPTS}"/build "${build_args[@]}" "${check_args[@]}" +if ! ${DRYRUN} ; then + "${SCRIPTS}"/post-build +fi "${SCRIPTS}"/services "${services_args[@]}" if ! ${DRYRUN} ; then diff --git a/scripts/post-build b/scripts/post-build new file mode 100755 index 00000000..b07cc792 --- /dev/null +++ b/scripts/post-build @@ -0,0 +1,26 @@ +#!/bin/bash +# Purpose: perform post-build actions +################################################################################ + +set -e +set -u +set -o pipefail + +# support testsuite +FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}" + +if ! [ -r "${FUNCTIONS}"/main ]; then + printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}" >&2 + exit 1 +fi + +# shellcheck source=./functions/main +. "${FUNCTIONS}"/main + +# main script + +cd "$NGCPCTL_MAIN" + +# XXX: Skeleton for incremental deployment. + +## END OF FILE #################################################################