fix: pin the image and image version of a created service at creation time

This will help ensure that users upgrading to a new plugin version who stop/start databases will always get the same version. This is particularly important for datastores such as elasticsearch and postgres that have more involved upgraded processes.
This commit is contained in:
Jose Diaz-Gonzalez
2021-09-13 02:28:41 -04:00
parent 36b5a80263
commit 7ca7c20ef8
3 changed files with 30 additions and 1 deletions

10
install
View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
@@ -46,6 +47,15 @@ EOL
local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null)
for SERVICE in $SERVICES; do
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
if [[ ! -f "$SERVICE_ROOT/IMAGE" ]] || [[ ! -f "$SERVICE_ROOT/IMAGE_VERSION" ]]; then
local image="$(service_version "$SERVICE")"
if [[ "$image" == *":"* ]]; then
echo "${image%:*}" > "$SERVICE_ROOT/IMAGE"
echo "${image##*:}" > "$SERVICE_ROOT/IMAGE_VERSION"
fi
fi
if [[ -f "$SERVICE_ROOT/${PLUGIN_VARIABLE}_CONFIG_OPTIONS" ]]; then
mv "$SERVICE_ROOT/${PLUGIN_VARIABLE}_CONFIG_OPTIONS" "$SERVICE_ROOT/CONFIG_OPTIONS"
fi