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

View File

@@ -251,6 +251,14 @@ service_commit_config() {
if [[ -n "$SERVICE_SHM_SIZE" ]]; then
echo "$SERVICE_SHM_SIZE" >"$SERVICE_ROOT/SHM_SIZE"
fi
if [[ -n "$PLUGIN_IMAGE" ]]; then
echo "$PLUGIN_IMAGE" >"$SERVICE_ROOT/IMAGE"
fi
if [[ -n "$PLUGIN_IMAGE_VERSION" ]]; then
echo "$PLUGIN_IMAGE_VERSION" >"$SERVICE_ROOT/IMAGE_VERSION"
fi
}
service_backup_auth() {
@@ -396,7 +404,13 @@ service_exposed_ports() {
service_image_exists() {
declare desc="check if the current image exists"
local IMAGE="$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION"
declare SERVICE="$1"
local plugin_image="$PLUGIN_IMAGE"
local plugin_image_version="$PLUGIN_IMAGE_VERSION"
[[ -f "$SERVICE_ROOT/IMAGE" ]] && plugin_image="$(cat "$SERVICE_ROOT/IMAGE")"
[[ -f "$SERVICE_ROOT/IMAGE_VERSION" ]] && plugin_image_version="$(cat "$SERVICE_ROOT/IMAGE_VERSION")"
local IMAGE="$plugin_image:$plugin_image_version"
if [[ "$(docker images -q "$IMAGE" 2>/dev/null)" == "" ]]; then
return 1