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 postgres upgrade tasks #182

Merged
merged 2 commits into from
Apr 11, 2018
Merged

Conversation

Nekototori
Copy link
Contributor

Was going through upgrading my older gitlab and had to upgrade the postgres database. This task follows the steps and checks here:
https://docs.gitlab.com/omnibus/settings/database.html#upgrade-packaged-postgresql-server

I've broken it up into two. One does the upgrade, and another does the cleanup.

CMD=$(sudo gitlab-psql --version)
echo "version is ${CMD##* }"
#9.2.18
if [ "${CMD##* }" = "9.2.18" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it better to do a -lt 10 here instead of hardcoding a 9.x?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in this case. Refer to the link in the OP's PR.

@eputnam eputnam added the enhancement New feature or request label Feb 26, 2018
Copy link
Contributor

@LongLiveCHIEF LongLiveCHIEF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nekototori sorry it took so long to get to this. I had to familiarize myself with bolt and get used to using it with sudo before I could properly review this request.

I noted in three spots where your script uses sudo explicitly. Tasks/scripts should not have sudo in them, and should instead be run with --sudo --tty --run-as root on the command line.

We also need to add some documentation to README, adding a ##Tasks section, and then adding this as the first task.

Once you clean up the sudo's, and add in some documentation for usage I'll merge. Make sure to mention the --sudo --run-as root --tty bit, since it's currently not documented fully in bolt docs.

Thanks for your contribution!

#!/bin/bash

echo 'Checking pgsql version'
CMD=$(sudo gitlab-psql --version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sudo needs to come out here, and this task needs to be run with --sudo --tty --run-as root

echo "Database size is: $DB_SIZE kb and freespace is $FREE kb"
if [ $DB_SIZE -lt $FREE ]; then
echo 'Enough freespace available to proceed.'
sudo gitlab-ctl pg-upgrade
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove sudo

@@ -0,0 +1,3 @@
#!/bin/bash
echo 'Cleaning up leftover files from upgrade...'
sudo rm -rf /var/opt/gitlab/postgresql/data.9.2.18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove sudo

@LongLiveCHIEF LongLiveCHIEF merged commit b006a83 into voxpupuli:master Apr 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants