From 99397ce7198818e478d859402cde031e60925576 Mon Sep 17 00:00:00 2001 From: hyunlee Date: Wed, 3 Apr 2024 11:09:02 -0700 Subject: [PATCH] ES snapshot policy is now daily instead of hourly --- cluster_provisioning/modules/common/mozart.tf | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/cluster_provisioning/modules/common/mozart.tf b/cluster_provisioning/modules/common/mozart.tf index 2cba0fd61..6027a7c2e 100644 --- a/cluster_provisioning/modules/common/mozart.tf +++ b/cluster_provisioning/modules/common/mozart.tf @@ -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 @@ -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 @@ -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 ] } @@ -613,6 +637,7 @@ 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 @@ -620,17 +645,17 @@ resource "aws_instance" "mozart" { 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