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

NSDS-2584 - Implement rollover of old job, task, worker, event ES docs on Mozart ES #100

Merged
merged 4 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 41 additions & 21 deletions sdscli/adapters/hysds/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,42 @@ def install_base_es_template():
run("curl -XPUT 'localhost:9200/_template/index_defaults?pretty' -H 'Content-Type: application/json' -d@/tmp/es_template-base.json")


def install_es_policy():
policy_file_name = "es_ilm_policy_mozart.json"
target_file = f"{ops_dir}/mozart/etc/{policy_file_name}"
send_template(
policy_file_name,
target_file
)
run(f"curl -XPUT 'localhost:9200/_ilm/policy/ilm_policy_mozart?pretty' -H 'Content-Type: application/json' -d@{target_file}")


def install_mozart_es_templates():
# install index templates
# Only job_status.template has ILM policy attached
# HC-451 will focus on adding ILM to worker, task, and event status indices

# template files located in ~/.sds/files
templates = [
"job_status.template",
"worker_status.template",
"task_status.template",
"event_status.template"
]

for template in templates:
# Copy templates to etc/ directory
target_path = f"{ops_dir}/mozart/etc/{template}"
send_template(
template,
target_path
)
template_doc_name = template.split(".template")[0]
print(f"Creating ES index template for {template}")
run(f"curl -XPUT 'localhost:9200/_index_template/{template_doc_name}?pretty' "
f"-H 'Content-Type: application/json' -d@{target_path}")


##########################
# grq functions
##########################
Expand Down Expand Up @@ -586,14 +622,14 @@ def rabbitmq_queues_flush():

def mozart_es_flush():
ctx = get_context()
run('curl -XDELETE http://{MOZART_ES_PVT_IP}:9200/_template/*_status'.format(**ctx))
run('~/mozart/ops/hysds/scripts/clean_job_status_indexes.sh http://{MOZART_ES_PVT_IP}:9200'.format(
#run('curl -XDELETE http://{MOZART_ES_PVT_IP}:9200/_index_template/*_status'.format(**ctx))
run('~/mozart/ops/hysds/scripts/clean_indices_from_alias.py http://{MOZART_ES_PVT_IP}:9200 job_status-current'.format(
**ctx))
run('~/mozart/ops/hysds/scripts/clean_task_status_indexes.sh http://{MOZART_ES_PVT_IP}:9200'.format(
run('~/mozart/ops/hysds/scripts/clean_indices_from_alias.py http://{MOZART_ES_PVT_IP}:9200 task_status-current'.format(
**ctx))
run('~/mozart/ops/hysds/scripts/clean_worker_status_indexes.sh http://{MOZART_ES_PVT_IP}:9200'.format(
run('~/mozart/ops/hysds/scripts/clean_indices_from_alias.py http://{MOZART_ES_PVT_IP}:9200 event_status-current'.format(
**ctx))
run('~/mozart/ops/hysds/scripts/clean_event_status_indexes.sh http://{MOZART_ES_PVT_IP}:9200'.format(
run('~/mozart/ops/hysds/scripts/clean_indices_from_alias.py http://{MOZART_ES_PVT_IP}:9200 worker_status-current'.format(
**ctx))
#run('~/mozart/ops/hysds/scripts/clean_job_spec_container_indexes.sh http://{MOZART_ES_PVT_IP}:9200'.format(**ctx))

Expand Down Expand Up @@ -814,14 +850,6 @@ def send_shipper_conf(node_type, log_dir, cluster_jobs, redis_ip_job_status,
if node_type == 'mozart':
upload_template('indexer.conf.mozart', '~/mozart/etc/indexer.conf', use_jinja=True, context=ctx,
template_dir=os.path.join(ops_dir, 'mozart/ops/hysds/configs/logstash'))
upload_template('job_status.template', '~/mozart/etc/job_status.template', use_jinja=True,
template_dir=os.path.join(ops_dir, 'mozart/ops/hysds/configs/logstash'))
upload_template('worker_status.template', '~/mozart/etc/worker_status.template', use_jinja=True,
template_dir=os.path.join(ops_dir, 'mozart/ops/hysds/configs/logstash'))
upload_template('task_status.template', '~/mozart/etc/task_status.template', use_jinja=True,
template_dir=os.path.join(ops_dir, 'mozart/ops/hysds/configs/logstash'))
upload_template('event_status.template', '~/mozart/etc/event_status.template', use_jinja=True,
template_dir=os.path.join(ops_dir, 'mozart/ops/hysds/configs/logstash'))
upload_template('sdswatch_client.conf', '~/mozart/etc/sdswatch_client.conf', use_jinja=True,
context=ctx, template_dir=os.path.join(ops_dir, 'mozart/ops/hysds/configs/logstash'))
send_template("run_sdswatch_client.sh", "~/mozart/bin/run_sdswatch_client.sh")
Expand All @@ -833,14 +861,6 @@ def send_shipper_conf(node_type, log_dir, cluster_jobs, redis_ip_job_status,
elif node_type == 'metrics':
upload_template('indexer.conf.metrics', '~/metrics/etc/indexer.conf', use_jinja=True, context=ctx,
template_dir=os.path.join(ops_dir, 'mozart/ops/hysds/configs/logstash'))
upload_template('job_status.template', '~/metrics/etc/job_status.template', use_jinja=True,
template_dir=os.path.join(ops_dir, 'mozart/ops/hysds/configs/logstash'))
upload_template('worker_status.template', '~/metrics/etc/worker_status.template', use_jinja=True,
template_dir=os.path.join(ops_dir, 'mozart/ops/hysds/configs/logstash'))
upload_template('task_status.template', '~/metrics/etc/task_status.template', use_jinja=True,
template_dir=os.path.join(ops_dir, 'mozart/ops/hysds/configs/logstash'))
upload_template('event_status.template', '~/metrics/etc/event_status.template', use_jinja=True,
template_dir=os.path.join(ops_dir, 'mozart/ops/hysds/configs/logstash'))
upload_template('sdswatch_client.conf', '~/metrics/etc/sdswatch_client.conf', use_jinja=True,
context=ctx, template_dir=os.path.join(ops_dir, 'mozart/ops/hysds/configs/logstash'))
send_template("run_sdswatch_client.sh", "~/metrics/bin/run_sdswatch_client.sh")
Expand Down
43 changes: 43 additions & 0 deletions sdscli/adapters/hysds/files/es_ilm_policy_mozart.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"policy": {
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"set_priority" : {
"priority": 100
}
}
},
"warm": {
"min_age": "90d",
"actions": {
"migrate": {
"enabled": false
},
"set_priority" : {
"priority": 50
}
}
},
"cold": {
"min_age": "97d",
"actions": {
"set_priority" : {
"priority": 0
},
"migrate": {
"enabled": false
},
"freeze": {}
}
},
"delete": {
"min_age": "104d",
"actions": {
"delete": {}
}
}
}
}
}
102 changes: 102 additions & 0 deletions sdscli/adapters/hysds/files/event_status.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"index_patterns": [
"event_status*"
],
"template": {
"mappings": {
"properties": {
"resource": {
"type": "keyword",
"ignore_above": 256,
"copy_to": [
"text_fields"
]
},
"type": {
"type": "keyword",
"ignore_above": 256,
"copy_to": [
"text_fields"
]
},
"status": {
"type": "keyword",
"ignore_above": 256,
"copy_to": [
"text_fields"
]
},
"timestamp": {
"type": "date"
},
"hostname": {
"type": "keyword",
"ignore_above": 256,
"copy_to": [
"text_fields"
]
},
"uuid": {
"type": "keyword",
"ignore_above": 256,
"copy_to": [
"text_fields"
]
},
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"tags": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"copy_to": [
"text_fields"
]
},
"event": {
"type": "object",
"enabled": false
},
"text_fields": {
"type": "text"
}
}
},
"settings": {
"number_of_shards": 8,
"index": {
"refresh_interval": "5s",
"lifecycle": {
"name": "ilm_policy_mozart"
}
},
"analysis": {
"analyzer": {
"default": {
"filter": [
"lowercase",
"word_delimiter"
],
"tokenizer": "keyword"
}
}
}
},
"aliases": {
"job_status": {},
"event_status": {},
"event_status-current": {}
}
}
}
Loading