Skip to content

Commit

Permalink
Updated migration logic
Browse files Browse the repository at this point in the history
Signed-off-by: sougata-progress <[email protected]>
  • Loading branch information
sougata-progress committed Oct 16, 2024
1 parent 0607b01 commit 9de828d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 93 deletions.
90 changes: 0 additions & 90 deletions scripts/minio-migrate.sh

This file was deleted.

4 changes: 2 additions & 2 deletions scripts/minio-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function preflight_checks () {
echo ""
}

function downloand_bucket_objects () {
function download_bucket_objects () {
aws ${opts[*]} s3 sync $s3_url $waypoint
}

Expand Down Expand Up @@ -264,7 +264,7 @@ case "${1}" in
usage ) usage ;;
print_env ) print_env ;;
preflight_checks ) preflight_checks ;;
download ) downloand_bucket_objects ;;
download ) download_bucket_objects ;;
upgrade ) upgrade_minio ;;
downgrade ) downgrade_minio ;;
upload ) upload_bucket_objects ;;
Expand Down
29 changes: 28 additions & 1 deletion scripts/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ umask 0022

# Defaults
BLDR_ORIGIN=${BLDR_ORIGIN:="habitat"}
LATEST_MINIO_VERSION="2023-11-01T01-57-10Z"

sudo () {
[[ $EUID = 0 ]] || set -- command sudo -E "$@"
Expand Down Expand Up @@ -200,7 +201,22 @@ start_datastore() {
}

start_minio() {
set +e
is_minio_migration_needed
migration_needed=$?
set -e

if [ "$migration_needed" -eq 1 ]; then
echo MinIO migration required
bash ./minio-update.sh download
sudo sh -c "find /hab/svc/builder-minio/data/ -maxdepth 1 -mindepth 1 -type d | xargs rm -rf"
fi

sudo hab svc load "${BLDR_ORIGIN}/builder-minio" --channel "${BLDR_MINIO_CHANNEL:=$BLDR_CHANNEL}" --force

if [ "$migration_needed" -eq 1 ]; then
bash ./minio-update.sh upload
fi
}

start_memcached() {
Expand All @@ -222,6 +238,18 @@ generate_bldr_keys() {
hab file upload "builder-api.default" "$(date +%s)" "/hab/cache/keys/${KEY_NAME}.box.key"
}

is_minio_migration_needed() {
installed_version=$(hab pkg path core/minio | cut -d '/' -f6)

if [ "$installed_version" = "$LATEST_MINIO_VERSION" ]; then
return 0
elif [[ "$installed_version" < "$LATEST_MINIO_VERSION" ]]; then
return 1
else
return 0
fi
}

upload_ssl_certificate() {
if [ "${APP_SSL_ENABLED}" = "true" ]; then
echo "SSL enabled - uploading certificate files"
Expand Down Expand Up @@ -409,7 +437,6 @@ install_options()
install_postgresql
fi
if [ "${MINIO_INSTALL:-0}" = 1 ]; then
./minio-migrate.sh
install_minio
fi
fi
Expand Down

0 comments on commit 9de828d

Please sign in to comment.