Changing call to create tmp dir as the database user

Previously would run as root, and only set the target directories
permissions. If parent directories were unreadable by the db user, then
pg-upgrade would fail.
This commit is contained in:
Ian Baum 2017-02-28 18:17:33 -06:00
parent 4c2d34e377
commit 7b54cd7656
1 changed files with 13 additions and 4 deletions

View File

@ -150,11 +150,20 @@ add_command_under_category 'pg-upgrade', 'database',
end
unless progress_message('Creating temporary data directory') do
run_command(
"install -d -o gitlab-psql #{@db_worker.tmp_data_dir}.#{upgrade_version}"
)
begin
@db_worker.run_pg_command(
"mkdir -p #{@db_worker.tmp_data_dir}.#{upgrade_version}"
)
rescue GitlabCtl::Errors::ExecutionError => ee
false
else
true
end
end
die 'Error creating new directory'
log "Error creating new directory: #{@db_worker.tmp_data_dir}.#{upgrade_version}"
log "STDOUT: #{ee.stdout}"
log "STDERR: #{ee.stderr}"
die 'Please check the output'
end
unless progress_message('Initializing the new database') do