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

skip import when persisted data exists #360

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

curtisy1
Copy link

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

curtisy1 and others added 3 commits January 23, 2023 12:47
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

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?

Suggested change
if [ -f /var/lib/postgresql/14/main/.databaseImported ]; then
if [ -f /data/database/planet-import-complete ]; then

I.E.:
https://github.com/Overv/openstreetmap-tile-server/pull/360/files#diff-d31ce0453051853c17ba2a5225b3d1bfab548e095bab0967d6acfd1b3ce1b35dR130

Copy link
Contributor

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
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants