Skip to content

Commit

Permalink
ES snapshot policy is now daily instead of hourly
Browse files Browse the repository at this point in the history
  • Loading branch information
hhlee445 committed Apr 3, 2024
1 parent 4c52506 commit 99397ce
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions cluster_provisioning/modules/common/mozart.tf
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,20 @@ resource "aws_instance" "mozart" {
]
}

# Copy down latest opera-sds-int and opera-sds-ops repos for convenience
provisioner "remote-exec" {
inline = [<<-EOT
while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 5; done
set -ex
cd ~/mozart/ops
wget https://github.com/nasa/opera-sds-int/archive/refs/heads/main.zip -O opera-sds-int.zip
wget https://github.com/nasa/opera-sds-ops/archive/refs/heads/main.zip -O opera-sds-ops.zip
unzip opera-sds-int.zip
unzip opera-sds-ops.zip
EOT
]
}

provisioner "remote-exec" {
inline = [<<-EOT
while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 5; done
Expand Down Expand Up @@ -538,9 +552,13 @@ resource "aws_instance" "mozart" {
fi
cp -pr ~/mozart/ops/opera-pcm ~/verdi/ops/opera-pcm
echo buckets are ---- ${local.code_bucket} ${local.dataset_bucket} ${local.isl_bucket}
sed -i "s/RELEASE_VERSION: '{{ RELEASE_VERSION }}'/RELEASE_VERSION: '${var.pcm_branch}'/g" ~/mozart/ops/opera-pcm/conf/settings.yaml
if [ "${var.pge_sim_mode}" = false ]; then
sed -i 's/PGE_SIMULATION_MODE: !!bool true/PGE_SIMULATION_MODE: !!bool false/g' ~/mozart/ops/opera-pcm/conf/settings.yaml
fi
sed -i "s/DATASET_BUCKET: '{{ DATASET_BUCKET }}'/DATASET_BUCKET: '${local.dataset_bucket}'/g" ~/mozart/ops/opera-pcm/conf/settings.yaml
sleep 180
if [ "${var.use_artifactory}" = true ]; then
Expand Down Expand Up @@ -570,7 +588,13 @@ resource "aws_instance" "mozart" {
cd ~/mozart/ops/opera-pcm
echo # download dependencies for CLI execution of daac_data_subscriber.py
pip install '.[subscriber]'
pip install '.[audit]'
pip install '.[cmr_audit]'
pip install --progress-bar off -e .
# For daac_data_subscriber utility tool
mkdir ~/Downloads/
aws s3 cp s3://opera-ancillaries/mgrs_tiles/dswx_s1/MGRS_tile_collection_v0.3.sqlite ~/Downloads/
EOT
]
}
Expand Down Expand Up @@ -613,24 +637,25 @@ resource "aws_instance" "mozart" {
}

// Snapshot repositories and lifecycles for GRQ mozart and metrics ES, also set shard max
// Snapshot schedule is in UTC, 5 AM UTC is 9/10 PM PST, depending on daylight savingss
provisioner "remote-exec" {
inline = [<<-EOT
while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 5; done
set -ex
source ~/.bash_profile
echo // grq
~/mozart/bin/snapshot_es_data.py --es-url ${local.grq_es_url} create-repository --repository snapshot-repository --bucket ${var.es_snapshot_bucket} --bucket-path ${var.project}-${var.venue}-${var.counter}/grq --role-arn ${var.es_bucket_role_arn}
~/mozart/bin/snapshot_es_data.py --es-url ${local.grq_es_url} create-lifecycle --repository snapshot-repository --policy-id hourly-snapshot --snapshot grq-backup --index-pattern grq_*,*_catalog
~/mozart/bin/snapshot_es_data.py --es-url ${local.grq_es_url} create-lifecycle --repository snapshot-repository --policy-id daily-snapshot --snapshot grq-backup --index-pattern grq_*,*_catalog --schedule="0 0 5 * * ?"
curl -XPUT ${local.grq_es_url}/_cluster/settings -H 'Content-type: application/json' --data-binary $'{"transient":{"cluster.max_shards_per_node": 6000, "search.max_open_scroll_context": 6000}, "persistent":{"cluster.max_shards_per_node": 6000, "search.max_open_scroll_context": 6000}}'
echo // mozart
~/mozart/bin/snapshot_es_data.py --es-url http://${aws_instance.mozart.private_ip}:9200 create-repository --repository snapshot-repository --bucket ${var.es_snapshot_bucket} --bucket-path ${var.project}-${var.venue}-${var.counter}/mozart --role-arn ${var.es_bucket_role_arn}
~/mozart/bin/snapshot_es_data.py --es-url http://${aws_instance.mozart.private_ip}:9200 create-lifecycle --repository snapshot-repository --policy-id hourly-snapshot --snapshot mozart-backup --index-pattern *_status-*,user_rules-*,job_specs,hysds_ios-*,containers
~/mozart/bin/snapshot_es_data.py --es-url http://${aws_instance.mozart.private_ip}:9200 create-lifecycle --repository snapshot-repository --policy-id daily-snapshot --snapshot mozart-backup --index-pattern *_status-*,user_rules-*,job_specs,hysds_ios-*,containers --schedule="0 0 5 * * ?"
curl -XPUT http://${aws_instance.mozart.private_ip}:9200/_cluster/settings -H 'Content-type: application/json' --data-binary $'{"transient":{"cluster.max_shards_per_node": 6000, "search.max_open_scroll_context": 6000}, "persistent":{"cluster.max_shards_per_node": 6000, "search.max_open_scroll_context": 6000}}'
echo // metrics
~/mozart/bin/snapshot_es_data.py --es-url http://${aws_instance.metrics.private_ip}:9200 create-repository --repository snapshot-repository --bucket ${var.es_snapshot_bucket} --bucket-path ${var.project}-${var.venue}-${var.counter}/metrics --role-arn ${var.es_bucket_role_arn}
~/mozart/bin/snapshot_es_data.py --es-url http://${aws_instance.metrics.private_ip}:9200 create-lifecycle --repository snapshot-repository --policy-id hourly-snapshot --snapshot metrics-backup --index-pattern logstash-*,sdswatch-*,mozart-logs-*,factotum-logs-*,grq-logs-*
~/mozart/bin/snapshot_es_data.py --es-url http://${aws_instance.metrics.private_ip}:9200 create-lifecycle --repository snapshot-repository --policy-id daily-snapshot --snapshot metrics-backup --index-pattern logstash-*,sdswatch-*,mozart-logs-*,factotum-logs-*,grq-logs-* --schedule="0 0 5 * * ?"
curl -XPUT http://${aws_instance.metrics.private_ip}:9200/_cluster/settings -H 'Content-type: application/json' --data-binary $'{"transient":{"cluster.max_shards_per_node": 6000, "search.max_open_scroll_context": 6000}, "persistent":{"cluster.max_shards_per_node": 6000, "search.max_open_scroll_context": 6000}}'
EOT
Expand Down

0 comments on commit 99397ce

Please sign in to comment.