Skip to content

Commit 3a2d3c2

Browse files
Merge pull request #1513 from craigcomstock/ENT-12383/3.21
Adjusted hub upgrade database migration to show only actionable logs (3.21)
2 parents 9b8dd77 + 52edfbf commit 3a2d3c2

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

packaging/common/cfengine-hub/postinstall.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ check_disk_space() {
518518
# and then importing it into new one
519519

520520
migrate_db_using_pg_upgrade() {
521-
su cfpostgres -c "LD_LIBRARY_PATH=$BACKUP_DIR/lib/ $PREFIX/bin/pg_upgrade --old-bindir=$BACKUP_DIR/bin --new-bindir=$PREFIX/bin --old-datadir=$BACKUP_DIR/data --new-datadir=$PREFIX/state/pg/data"
521+
su cfpostgres -c "$PREFIX/bin/pg_upgrade --old-bindir=$BACKUP_DIR/bin --new-bindir=$PREFIX/bin --old-datadir=$BACKUP_DIR/data --new-datadir=$PREFIX/state/pg/data"
522522
}
523523

524524
migrate_db_using_pipe() {
@@ -699,16 +699,23 @@ do_migration() {
699699
cd /tmp
700700
cf_console echo "Migrating database using pg_upgrade utility..."
701701
cf_console echo
702-
if migrate_db_using_pg_upgrade && [ $DEBUG -lt 1 ]; then
702+
_pg_upgrade_log="/tmp/cfengine_pg_upgrade.log"
703+
if migrate_db_using_pg_upgrade >"${_pg_upgrade_log}" 2>&1 && [ $DEBUG -lt 1 ]; then
703704
# Succeeded
705+
cat "${_pg_upgrade_log}" # might as well see the details of how it worked
706+
rm "${_pg_upgrade_log}" # clean up
704707
exit 0 # exits only from (...)
705708
fi
706709
cf_console echo "Migration using pg_upgrade failed."
707-
# here pg_upgrade probably said something like
708-
# Consult the last few lines of "/var/cfengine/state/pg/data/pg_upgrade_output.d/20230913T150025.959/log/pg_upgrade_server.log" for the probable cause of the failure.
709-
cf_console echo "Showing last lines of any related log files:"
710-
_daysearch=$(date +%Y%m%d)
711-
find "$PREFIX"/state/pg/data/pg_upgrade_output.d -name '*.log' | grep "$_daysearch" | cf_console xargs tail
710+
if [ $DEBUG -gt 0 ]; then
711+
cat "${_pg_upgrade_log}"
712+
rm "${_pg_upgrade_log}"
713+
# pg_upgrade probably said something like
714+
# Consult the last few lines of "/var/cfengine/state/pg/data/pg_upgrade_output.d/20230913T150025.959/log/pg_upgrade_server.log" for the probable cause of the failure.
715+
cf_console echo "Showing last lines of any related log files:"
716+
_daysearch=$(date +%Y%m%d)
717+
find "$PREFIX"/state/pg/data/pg_upgrade_output.d -name '*.log' | grep "$_daysearch" | cf_console xargs tail
718+
fi
712719
cf_console echo
713720
check_disk_space # will abort if low on disk space
714721
init_postgres_dir "$new_pgconfig_file" "$pgconfig_type"

0 commit comments

Comments
 (0)