Skip to content

Commit

Permalink
Migration script improvements
Browse files Browse the repository at this point in the history
There is no need to run a potentially lengthy reindexing on minor
upgrades, only on major ones.

Don't call su with `-` parameter as it shows the warning message for
terminals... and that looks ugly in logs.
  • Loading branch information
cbosdo committed Nov 13, 2024
1 parent d2dc1af commit a24cc43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mgradm/shared/kubernetes/dbFinalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func getDBFinalizeJob(
// Prepare the script
scriptData := templates.FinalizePostgresTemplateData{
RunAutotune: true,
RunReindex: true,
RunReindex: migration,
RunSchemaUpdate: schemaUpdateRequired,
Migration: migration,
Kubernetes: true,
Expand Down
6 changes: 3 additions & 3 deletions mgradm/shared/templates/pgsqlFinalizeScriptTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ echo "Running smdba system-check autotuning..."
smdba system-check autotuning
{{ end }}
echo "Starting Postgresql..."
su -s /bin/bash - postgres -c "/usr/share/postgresql/postgresql-script start"
HOME=/var/lib/pgsql PG_DATA=/var/lib/pgsql/data su -s /bin/bash -p postgres -c "/usr/share/postgresql/postgresql-script start"
{{ if .RunReindex }}
echo "Reindexing database. This may take a while, please do not cancel it!"
database=$(sed -n "s/^\s*db_name\s*=\s*\([^ ]*\)\s*$/\1/p" /etc/rhn/rhn.conf)
Expand All @@ -50,7 +50,6 @@ UPDATE rhnKickstartableTree SET base_path = CONCAT('/srv/www/distributions/', ta
from dist_map WHERE dist_map.base_path = rhnKickstartableTree.base_path;
DROP TABLE dist_map;
EOT
{{ end }}
echo "Schedule a system list update task..."
spacewalk-sql --select-mode - <<EOT
Expand All @@ -60,9 +59,10 @@ from rhnserver s
where not exists (select 1 from rhntaskorun r join rhntaskotemplate t on r.template_id = t.id
join rhntaskobunch b on t.bunch_id = b.id where b.name='update-system-overview-bunch' limit 1);
EOT
{{ end }}
echo "Stopping Postgresql..."
su -s /bin/bash - postgres -c "/usr/share/postgresql/postgresql-script stop"
HOME=/var/lib/pgsql PG_DATA=/var/lib/pgsql/data su -s /bin/bash -p postgres -c "/usr/share/postgresql/postgresql-script stop"
echo "Enable SSL again"
cp /var/lib/pgsql/data/postgresql.conf.bak /var/lib/pgsql/data/postgresql.conf
Expand Down

0 comments on commit a24cc43

Please sign in to comment.