-
Notifications
You must be signed in to change notification settings - Fork 491
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
skip import when persisted data exists #360
base: master
Are you sure you want to change the base?
Conversation
When running in a kubernetes cluster, the import step should usually only happen once. For example, this could be done using an init container. Doing so and changing the deployment in a way that triggers a re-deploy currently fails because the database has already been initialized and persisted. To avoid this, write an empty file to the postgresql directory and check whether it exists on the next successful run to avoid running the setup again.
@@ -41,6 +41,11 @@ if [ ! -f /data/style/mapnik.xml ]; then | |||
fi | |||
|
|||
if [ "$1" == "import" ]; then | |||
if [ -f /var/lib/postgresql/14/main/.databaseImported ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, how about just using the already existing "complete" file?
if [ -f /var/lib/postgresql/14/main/.databaseImported ]; then | |
if [ -f /data/database/planet-import-complete ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or /data/database/postgres/.databaseImported
instead, because 14
was already changed to 15
in the master
branch.
@@ -126,6 +131,8 @@ if [ "$1" == "import" ]; then | |||
|
|||
service postgresql stop | |||
|
|||
touch /var/lib/postgresql/14/main/.databaseImported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether we should set this much earlier. That would prevent all these issues with half -imported data.
When running in a kubernetes cluster, the import step should usually only happen once.
For example, this could be done using an init container.
Doing so and changing the deployment in a way that triggers a re-deploy currently fails
because the database has already been initialized and persisted.
To avoid this, write an empty file to the postgresql directory and check whether it exists
on the next successful run to avoid running the setup again.
I don't see any downsides to this except wanting to import another region than what already exists. But that would currently fail as well, I believe