Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added minio migration script #277

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
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
28 changes: 28 additions & 0 deletions 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"
sougata-progress marked this conversation as resolved.
Show resolved Hide resolved

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
sougata-progress marked this conversation as resolved.
Show resolved Hide resolved

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"
sougata-progress marked this conversation as resolved.
Show resolved Hide resolved
sougata-progress marked this conversation as resolved.
Show resolved Hide resolved
fi

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

sougata-progress marked this conversation as resolved.
Show resolved Hide resolved
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
sougata-progress marked this conversation as resolved.
Show resolved Hide resolved
return 0
elif [[ "$installed_version" < "$LATEST_MINIO_VERSION" ]]; then
return 1
else
return 0
fi
sougata-progress marked this conversation as resolved.
Show resolved Hide resolved
}

upload_ssl_certificate() {
if [ "${APP_SSL_ENABLED}" = "true" ]; then
echo "SSL enabled - uploading certificate files"
Expand Down