Release: cut over Echoion 2.0 components
Modular container CI / release-build (push) Has been cancelled
Modular container CI / release-build (push) Has been cancelled
This commit is contained in:
169 files changed
+3069
-32261
No files matched your search
+126
-2
@@ -342,6 +342,50 @@ systemctl_for() {
|
||||
fi
|
||||
}
|
||||
|
||||
write_pending_generation() {
|
||||
local destination=$1
|
||||
local generation=$2
|
||||
local previous=$3
|
||||
local temporary
|
||||
temporary=$(mktemp --tmpdir="$(dirname -- "$destination")" \
|
||||
'.pending-install-generation.XXXXXX')
|
||||
{
|
||||
printf 'version=%s\n' "$generation"
|
||||
printf 'previous=%s\n' "$previous"
|
||||
} >"$temporary"
|
||||
chmod 0600 "$temporary"
|
||||
if [[ $mode == system || $register_service == system ]]; then
|
||||
chown "$SERVICE_USER:$SERVICE_USER" "$temporary"
|
||||
fi
|
||||
mv -f -- "$temporary" "$destination"
|
||||
}
|
||||
|
||||
wait_for_service_health() {
|
||||
local scope=$1
|
||||
local expected_version=$2
|
||||
local state=$3
|
||||
local main_pid deadline observed
|
||||
main_pid=$(systemctl_for "$scope" show --property MainPID --value \
|
||||
"$SERVICE_NAME" 2>/dev/null || true)
|
||||
if [[ ! $main_pid =~ ^[1-9][0-9]*$ ]]; then
|
||||
warn "systemd did not report a service PID; live readiness will finish on first launch"
|
||||
return 0
|
||||
fi
|
||||
deadline=$((SECONDS + 45))
|
||||
while ((SECONDS < deadline)); do
|
||||
observed=
|
||||
if [[ -f $state/release-health && ! -L $state/release-health ]]; then
|
||||
IFS= read -r observed <"$state/release-health" || true
|
||||
fi
|
||||
if [[ $observed == "$expected_version" ]] &&
|
||||
systemctl_for "$scope" is-active --quiet "$SERVICE_NAME"; then
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
safe_recorded_unit_path() {
|
||||
local scope=$1
|
||||
local unit=$2
|
||||
@@ -722,6 +766,7 @@ load_old_record() {
|
||||
local record=$1
|
||||
local key value
|
||||
OLD_PREFIX=
|
||||
OLD_VERSION=
|
||||
OLD_SERVICE_SCOPE=none
|
||||
OLD_SERVICE_UNIT=
|
||||
OLD_SERVICE_SHA256=
|
||||
@@ -750,10 +795,12 @@ load_old_record() {
|
||||
OLD_RELOCATABLE=0
|
||||
OLD_LAUNCHER=
|
||||
OLD_LAUNCHER_SHA256=
|
||||
OLD_LEGACY_ROLLBACK=
|
||||
[[ -f $record ]] || return 0
|
||||
while IFS='=' read -r key value; do
|
||||
case $key in
|
||||
prefix) OLD_PREFIX=$value ;;
|
||||
version) OLD_VERSION=$value ;;
|
||||
service_scope) OLD_SERVICE_SCOPE=$value ;;
|
||||
service_unit) OLD_SERVICE_UNIT=$value ;;
|
||||
service_unit_sha256) OLD_SERVICE_SHA256=$value ;;
|
||||
@@ -782,6 +829,7 @@ load_old_record() {
|
||||
relocatable) OLD_RELOCATABLE=$value ;;
|
||||
launcher) OLD_LAUNCHER=$value ;;
|
||||
launcher_sha256) OLD_LAUNCHER_SHA256=$value ;;
|
||||
legacy_rollback) OLD_LEGACY_ROLLBACK=$value ;;
|
||||
esac
|
||||
done < "$record"
|
||||
case $OLD_RELOCATABLE in
|
||||
@@ -1117,6 +1165,7 @@ write_record() {
|
||||
printf 'state_marker_sha256=%s\n' "$STATE_MARKER_SHA256"
|
||||
printf 'launcher=%s\n' "$LAUNCHER_RECORD_PATH"
|
||||
printf 'launcher_sha256=%s\n' "$LAUNCHER_SHA256"
|
||||
printf 'legacy_rollback=%s\n' "$LEGACY_ROLLBACK_RECORD"
|
||||
} > "$temporary"
|
||||
chmod 0600 "$temporary"
|
||||
mv -f -- "$temporary" "$destination"
|
||||
@@ -1153,7 +1202,9 @@ write_json_record() {
|
||||
printf ' "updater": {"executable": "current/bin/echoion-updater", '
|
||||
printf '"privilegedHelper": "%s", ' \
|
||||
"$(json_escape "$UPDATER_HELPER_RECORD_PATH")"
|
||||
printf '"timer": "echoion-updater.timer"}\n'
|
||||
printf '"timer": "echoion-updater.timer"},\n'
|
||||
printf ' "legacyRollback": "%s"\n' \
|
||||
"$(json_escape "$LEGACY_ROLLBACK_RECORD")"
|
||||
printf '}\n'
|
||||
} > "$temporary"
|
||||
chmod 0600 "$temporary"
|
||||
@@ -1469,6 +1520,9 @@ UPDATER_BUNDLE_CREATED=0
|
||||
WANT_LAUNCHER=$RELOCATABLE
|
||||
PLUGIN_BOOTSTRAP_CREATED_PATHS=()
|
||||
PLUGIN_BOOTSTRAP_TEMPORARY=
|
||||
LEGACY_MIGRATION=0
|
||||
LEGACY_ROLLBACK_RECORD=
|
||||
LEGACY_ARCHIVE_ROOT=
|
||||
STAGING=
|
||||
TRANSACTION_BACKUP_DIR=
|
||||
|
||||
@@ -1546,6 +1600,12 @@ rollback_install() {
|
||||
fi
|
||||
fi
|
||||
restore_current_link "$old_current"
|
||||
if [[ -f $TRANSACTION_BACKUP_DIR/pending-install-generation ]]; then
|
||||
cp -a -- "$TRANSACTION_BACKUP_DIR/pending-install-generation" \
|
||||
"$pending_generation"
|
||||
else
|
||||
rm -f -- "$pending_generation"
|
||||
fi
|
||||
if [[ -f $TRANSACTION_BACKUP_DIR/install-record ]]; then
|
||||
cp -a -- "$TRANSACTION_BACKUP_DIR/install-record" "$record"
|
||||
else
|
||||
@@ -1661,6 +1721,18 @@ acquire_prefix_lock "$prefix"
|
||||
record=$prefix/$RECORD_NAME
|
||||
json_record=$prefix/$JSON_RECORD_NAME
|
||||
load_old_record "$record"
|
||||
if [[ ${OLD_VERSION:-} =~ ^1\.[0-9]+\.[0-9]+([.-].*)?$ &&
|
||||
$version =~ ^2\. ]]; then
|
||||
LEGACY_MIGRATION=1
|
||||
LEGACY_ROLLBACK_RECORD=legacy/v1
|
||||
LEGACY_ARCHIVE_ROOT=$prefix/$LEGACY_ROLLBACK_RECORD
|
||||
elif [[ ${OLD_LEGACY_ROLLBACK:-} == legacy/v1 &&
|
||||
-d $prefix/legacy/v1 && ! -L $prefix/legacy/v1 ]]; then
|
||||
LEGACY_ROLLBACK_RECORD=$OLD_LEGACY_ROLLBACK
|
||||
LEGACY_ARCHIVE_ROOT=$prefix/$LEGACY_ROLLBACK_RECORD
|
||||
elif [[ -n ${OLD_LEGACY_ROLLBACK:-} ]]; then
|
||||
die "existing install record has an unsafe or missing legacy rollback target"
|
||||
fi
|
||||
if [[ -n ${OLD_UPDATER_HELPER:-} ]]; then
|
||||
verify_recorded_updater_helper "$OLD_UPDATER_HELPER" \
|
||||
"${OLD_UPDATER_HELPER_SHA256:-}"
|
||||
@@ -1826,6 +1898,11 @@ if [[ -L $prefix/current ]]; then
|
||||
elif [[ -e $prefix/current ]]; then
|
||||
die "current exists but is not a symlink: $prefix/current"
|
||||
fi
|
||||
if [[ $LEGACY_MIGRATION -eq 1 ]]; then
|
||||
[[ $old_current == "versions/$OLD_VERSION" &&
|
||||
-d $prefix/$old_current && ! -L $prefix/$old_current ]] ||
|
||||
die "v1 migration requires the recorded complete legacy runtime tree"
|
||||
fi
|
||||
|
||||
unit_path=
|
||||
unit_hash=
|
||||
@@ -1985,6 +2062,13 @@ fi
|
||||
if [[ -f $json_record ]]; then
|
||||
cp -a -- "$json_record" "$TRANSACTION_BACKUP_DIR/install-json"
|
||||
fi
|
||||
pending_generation=$state_dir/updates/pending-install-generation
|
||||
if [[ -f $pending_generation && ! -L $pending_generation ]]; then
|
||||
cp -a -- "$pending_generation" \
|
||||
"$TRANSACTION_BACKUP_DIR/pending-install-generation"
|
||||
elif [[ -e $pending_generation || -L $pending_generation ]]; then
|
||||
die "pending generation marker is not a regular file"
|
||||
fi
|
||||
if [[ $service_scope_changes -eq 1 ]]; then
|
||||
cp -a -- "$OLD_SERVICE_UNIT" "$TRANSACTION_BACKUP_DIR/old-scope-unit"
|
||||
if [[ -n ${OLD_UPDATER_SERVICE_UNIT:-} ]]; then
|
||||
@@ -2032,6 +2116,44 @@ if [[ ${OLD_SERVICE_SCOPE:-none} != none &&
|
||||
die "current exists but is not a symlink: $prefix/current"
|
||||
fi
|
||||
fi
|
||||
if [[ $LEGACY_MIGRATION -eq 1 ]]; then
|
||||
if [[ ${OLD_SERVICE_SCOPE:-none} != none ]]; then
|
||||
systemctl_for "$OLD_SERVICE_SCOPE" stop "$SERVICE_NAME" ||
|
||||
die "v1 service must be stopped before modular migration"
|
||||
fi
|
||||
if [[ -e $LEGACY_ARCHIVE_ROOT || -L $LEGACY_ARCHIVE_ROOT ]]; then
|
||||
[[ -d $LEGACY_ARCHIVE_ROOT && ! -L $LEGACY_ARCHIVE_ROOT &&
|
||||
-f $LEGACY_ARCHIVE_ROOT/rollback.conf &&
|
||||
-d $LEGACY_ARCHIVE_ROOT/tree ]] ||
|
||||
die "legacy rollback archive is incomplete: $LEGACY_ARCHIVE_ROOT"
|
||||
grep -Fx -- "version=$OLD_VERSION" \
|
||||
"$LEGACY_ARCHIVE_ROOT/rollback.conf" >/dev/null ||
|
||||
die "legacy rollback archive belongs to another version"
|
||||
else
|
||||
legacy_staging=$(mktemp -d --tmpdir="$prefix" '.legacy-v1.XXXXXX')
|
||||
cp -a --reflink=auto "$prefix/$old_current" "$legacy_staging/tree"
|
||||
install -d -m 0755 -- "$legacy_staging/service"
|
||||
if [[ -n ${OLD_SERVICE_UNIT:-} ]]; then
|
||||
cp -a -- "$OLD_SERVICE_UNIT" "$legacy_staging/service/"
|
||||
fi
|
||||
if [[ -n ${OLD_UPDATER_SERVICE_UNIT:-} ]]; then
|
||||
cp -a -- "$OLD_UPDATER_SERVICE_UNIT" "$legacy_staging/service/"
|
||||
fi
|
||||
if [[ -n ${OLD_UPDATER_TIMER_UNIT:-} ]]; then
|
||||
cp -a -- "$OLD_UPDATER_TIMER_UNIT" "$legacy_staging/service/"
|
||||
fi
|
||||
{
|
||||
printf 'version=%s\n' "$OLD_VERSION"
|
||||
printf 'current=%s\n' "$old_current"
|
||||
printf 'service_scope=%s\n' "${OLD_SERVICE_SCOPE:-none}"
|
||||
printf 'config=%s\n' "$config_file"
|
||||
printf 'state=%s\n' "$state_dir"
|
||||
} >"$legacy_staging/rollback.conf"
|
||||
chmod 0600 "$legacy_staging/rollback.conf"
|
||||
install -d -m 0755 -- "$(dirname -- "$LEGACY_ARCHIVE_ROOT")"
|
||||
mv -- "$legacy_staging" "$LEGACY_ARCHIVE_ROOT"
|
||||
fi
|
||||
fi
|
||||
TRANSACTION_ACTIVE=1
|
||||
|
||||
if [[ $CONFIG_MIGRATION_ARMED -eq 1 ]]; then
|
||||
@@ -2079,6 +2201,7 @@ new_link_directory=$(mktemp -d --tmpdir="$prefix" '.current-link.XXXXXX')
|
||||
ln -s -- "versions/$version" "$new_link_directory/current"
|
||||
mv -Tf -- "$new_link_directory/current" "$prefix/current"
|
||||
rmdir -- "$new_link_directory"
|
||||
write_pending_generation "$pending_generation" "$version" "$old_current"
|
||||
|
||||
if [[ $register_service != none ]]; then
|
||||
systemctl_for "$register_service" daemon-reload || die "systemd rejected the installed service unit"
|
||||
@@ -2088,7 +2211,8 @@ if [[ $register_service != none ]]; then
|
||||
if ! systemctl_for "$register_service" enable "$SERVICE_NAME" "$UPDATER_TIMER_NAME" ||
|
||||
! systemctl_for "$register_service" restart "$SERVICE_NAME" ||
|
||||
! systemctl_for "$register_service" start "$UPDATER_TIMER_NAME" ||
|
||||
! systemctl_for "$register_service" is-active --quiet "$SERVICE_NAME"; then
|
||||
! systemctl_for "$register_service" is-active --quiet "$SERVICE_NAME" ||
|
||||
! wait_for_service_health "$register_service" "$version" "$state_dir"; then
|
||||
warn "new service failed health validation; restoring previous release and unit"
|
||||
die "service failed to start"
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user