deis / postgres

A PostgreSQL database used by Deis Workflow.
https://deis.com
MIT License
36 stars 22 forks source link

feat(charts): add backup to preStop hook #166

Closed bacongobbler closed 7 years ago

bacongobbler commented 7 years ago

closes #164.

deis-bot commented 7 years ago

@kmala is a potential reviewer of this pull request based on my analysis of git blame information. Thanks @bacongobbler!

bacongobbler commented 7 years ago

@nailgun if you feel like taking a spin with this PR, please feel free to test it out.

nailgun commented 7 years ago

Ok, I will test this. But if I understand it in right way, backup script will run infinite loop. Plus it sleeps before actually doing a backup.

bacongobbler commented 7 years ago

fixed.

nailgun commented 7 years ago

Great! Is there a simple way to inject this into my kubernetes? Or I need to build and store image somewhere?

bacongobbler commented 7 years ago

You can do so by running kubectl --namespace=deis edit deployment deis-database.

You'll have to modify the image being used to quay.io/deisci/postgres:git-2615187 and add the preStop hook in there. Jenkins already created the image to test this PR.

Note that this image should only be used temporarily for testing purposes as we clean out the deisci org of all images occasionally.

mboersma commented 7 years ago

I tested this but it appears the script is run as root, not postgres, which causes a problem?

.82 seg=000000020000000000000010 state=complete
FATAL:  role "root" does not exist
LOG:  received smart shutdown request
LOG:  autovacuum launcher shutting down
mboersma commented 7 years ago

Also could you create a deis/charts PR for the workflow-dev chart to go with this? Some of us still test with Helm classic for a few things... 👴

bacongobbler commented 7 years ago

good catch @mboersma. The real invocation should be gosu postgres do_backup. I'll make that change here and PR a helm-classic change as well.

mboersma commented 7 years ago

I re-tested after this gosu postgres change and confirmed that killing a database pod kicks off the preStop backup process. Seems ok here in simple testing.

nailgun commented 7 years ago

Sorry for late reply. I broken my cluster :) Just rebuilt it (I'm new to kubernetes). @mboersma thanks for testing.

bacongobbler commented 7 years ago

closes #108