From f6fef277fc3a2a67e1662dc075f904c15863fe51 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 24 Sep 2023 16:06:23 +0100 Subject: [PATCH] Copy hourly and daily replication diffs to S3 --- .../files/default/replication-bin/replicate-day | 16 ++++++++++++++++ .../files/default/replication-bin/replicate-hour | 16 ++++++++++++++++ cookbooks/planet/recipes/replication.rb | 8 ++++++-- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 cookbooks/planet/files/default/replication-bin/replicate-day create mode 100644 cookbooks/planet/files/default/replication-bin/replicate-hour diff --git a/cookbooks/planet/files/default/replication-bin/replicate-day b/cookbooks/planet/files/default/replication-bin/replicate-day new file mode 100644 index 000000000..2db770c16 --- /dev/null +++ b/cookbooks/planet/files/default/replication-bin/replicate-day @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +/usr/local/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/day + +. /store/planet/replication/day/state.txt + +sequencePart1=$(($sequenceNumber / 1000000 % 1000)) +sequencePart2=$(($sequenceNumber / 1000 % 1000)) +sequencePart3=$(($sequenceNumber % 1000)) +diffPath=$(printf "%03d/%03d/%03d" $sequencePart1 $sequencePart2 $sequencePart3) + +/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "/store/planet/replication/day/${diffPath}.osc.gz" "s3://osm-planet-eu-central-1/planet/replication/day/${diffPath}.osc.gz" +/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "/store/planet/replication/day/${diffPath}.state.txt" "s3://osm-planet-eu-central-1/planet/replication/day/${diffPath}.state.txt" +/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "/store/planet/replication/day/state.txt" "s3://osm-planet-eu-central-1/planet/replication/day/state.txt" diff --git a/cookbooks/planet/files/default/replication-bin/replicate-hour b/cookbooks/planet/files/default/replication-bin/replicate-hour new file mode 100644 index 000000000..849cbb417 --- /dev/null +++ b/cookbooks/planet/files/default/replication-bin/replicate-hour @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +/usr/local/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/hour + +. /store/planet/replication/hour/state.txt + +sequencePart1=$(($sequenceNumber / 1000000 % 1000)) +sequencePart2=$(($sequenceNumber / 1000 % 1000)) +sequencePart3=$(($sequenceNumber % 1000)) +diffPath=$(printf "%03d/%03d/%03d" $sequencePart1 $sequencePart2 $sequencePart3) + +/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "/store/planet/replication/hour/${diffPath}.osc.gz" "s3://osm-planet-eu-central-1/planet/replication/hour/${diffPath}.osc.gz" +/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "/store/planet/replication/hour/${diffPath}.state.txt" "s3://osm-planet-eu-central-1/planet/replication/hour/${diffPath}.state.txt" +/opt/awscli/v2/current/bin/aws --profile=osm-pds-upload s3 cp --storage-class=INTELLIGENT_TIERING "/store/planet/replication/hour/state.txt" "s3://osm-planet-eu-central-1/planet/replication/hour/state.txt" diff --git a/cookbooks/planet/recipes/replication.rb b/cookbooks/planet/recipes/replication.rb index 6b2f9ab74..d719d11ae 100644 --- a/cookbooks/planet/recipes/replication.rb +++ b/cookbooks/planet/recipes/replication.rb @@ -314,10 +314,12 @@ end systemd_service "replication-hourly" do description "Hourly replication" user "planet" - exec_start "/usr/local/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/hour" + exec_start "/usr/local/bin/replicate-hour" environment "LD_PRELOAD" => "/opt/flush/flush.so" sandbox :enable_network => true memory_deny_write_execute false + protect_home "tmpfs" + bind_paths "/home/planet" read_write_paths [ "/store/planet/replication/hour", "/var/lib/replication/hour" @@ -358,10 +360,12 @@ end systemd_service "replication-daily" do description "Daily replication" user "planet" - exec_start "/usr/local/bin/osmosis -q --merge-replication-files workingDirectory=/var/lib/replication/day" + exec_start "/usr/local/bin/replicate-day" environment "LD_PRELOAD" => "/opt/flush/flush.so" sandbox :enable_network => true memory_deny_write_execute false + protect_home "tmpfs" + bind_paths "/home/planet" read_write_paths [ "/store/planet/replication/day", "/var/lib/replication/day" -- 2.39.5