-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(snap): Install Unit of Measure config file on upgrade (#4125)
* fix(snap): Install Unit of Measure config file on upgrade * refactor: rename snap options for clarity * fix: Correct legacy snap option name Signed-off-by: Farshid Tavakolizadeh <farshid.tavakolizadeh@canonical.com>
- Loading branch information
Showing
2 changed files
with
31 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,28 @@ | ||
#!/bin/bash -e | ||
|
||
TAG=$SNAP_INSTANCE_NAME.$(basename "$0") | ||
|
||
# read revision/version of the previous installation, set in the pre-refresh hook | ||
pre_rev=$(snapctl get pre-refresh.revision) | ||
pre_ver=$(snapctl get pre-refresh.version) | ||
# read the revision from the legacy lastrev option (EdgeX <2.3) | ||
[ -z "$pre_rev" ] && pre_rev=$(snapctl get lastrev) | ||
|
||
logger --tag $TAG "Refreshing from $pre_ver ($pre_rev) to $SNAP_VERSION ($SNAP_REVISION)" | ||
|
||
# set up postgres, if we are upgrading it | ||
$SNAP/bin/kong-postgres-setup.sh "post-refresh" | ||
|
||
# Install the Unit of Measure config file when upgrading from an old version | ||
# UoM was added in v2.3.0-dev.45 (snap revision 3900): | ||
# https://github.com/edgexfoundry/edgex-go/pull/4119 | ||
if (( pre_rev < 3900 )); then | ||
uom="config/core-metadata/res/uom.toml" | ||
logger --tag $TAG "Installing $SNAP/$uom" | ||
if [ -f "$SNAP/$uom" ]; then | ||
# --no-clobber: copy if missing from target | ||
cp --no-clobber "$SNAP/$uom" "$SNAP_DATA/$uom" | ||
else | ||
logger --stderr --tag $TAG "$SNAP/$uom does not exit." | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
#!/bin/bash -e | ||
|
||
# save this revision for when we run again in the post-refresh | ||
snapctl set lastrev="$SNAP_REVISION" | ||
# save these for use in the post-refresh hook | ||
snapctl set pre-refresh.revision=$SNAP_REVISION | ||
snapctl set pre-refresh.version=$SNAP_VERSION | ||
|
||
# unset legacy EdgeX <2.3 options | ||
snapctl unset lastrev release | ||
|
||
snapctl set release="jakarta" | ||
|
||
# back up the Kong database, so that if the new snap contains a newer | ||
# postgresql, then the configuration can be imported into the new database | ||
# in the post-refresh hook. | ||
$SNAP/bin/kong-postgres-setup.sh "pre-refresh" | ||
$SNAP/bin/kong-postgres-setup.sh "pre-refresh" |