Page MenuHomePhabricator
Paste P10980

(An Untitled Masterwork)
ActivePublic

Authored by EBernhardson on Apr 14 2020, 9:09 PM.
Tags
None
Referenced Files
F31756827: raw.txt
Apr 14 2020, 9:09 PM
Subscribers
ebernhardson@elastic1050:~$ cat test.py
import elasticsearch
import sys
es = elasticsearch.Elasticsearch('http://search.svc.eqiad.wmnet:9200')
for index in sys.stdin:
index = index.strip()
aliases = es.indices.get_alias(index)
if not aliases:
print("Deleting index with no aliases: {}".format(index))
es.indices.delete(index)
else:
print("WARNING: {} has live aliases: {}".format(index, aliases))
ebernhardson@elastic1050:~$ echo enwiki_content_1582848800 | /srv/deployment/search/mjolnir/deploy/venv/bin/python3 test.py
WARNING: enwiki_content_1582848800 has live aliases: {'enwiki_content_1582848800': {'aliases': {'enwiki': {}, 'enwiki_content': {}}}}

Event Timeline

ended up tweaking it just a little bit so I'll leave that here just on the off chance someone else (or me) needs it

import elasticsearch
import sys

es = elasticsearch.Elasticsearch('https://search.svc.codfw.wmnet:9643',
				use_ssl=True,
				verify_certs=True,
				ca_certs=<path to certs>)
for index in sys.stdin:
    index = index.strip()
    aliases= es.indices.get_alias(index,ignore_unavailable=True)
    if aliases and not aliases[index]['aliases']:
        print("Deleting index with no aliases: {}".format(index))
        es.indices.delete(index)
    else:
        print("WARNING: {} has live aliases or doesn't exist: {}".format(index, aliases))