Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P45937
(An Untitled Masterwork)
Active
Public
Actions
Authored by
Gehel
on Mar 23 2023, 8:29 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F36924906: raw-paste-data.txt
Mar 23 2023, 8:29 PM
2023-03-23 20:29:43 (UTC+0)
Subscribers
None
from typing import Iterable
def hostname_to_elasticsearch_instances(hosts: Iterable):
target_hosts = [host.split('.')[0] for host in hosts]
target_dc = [host.split('.')[1] for host in hosts]
main_hosts = [f'{host}-production-search-{dc}' for (host, dc) in zip(target_hosts, target_dc)]
psi_hosts = [f'{host}-production-search-psi-{dc}' for (host, dc) in zip(target_hosts, target_dc)]
omega_hosts = [f'{host}-production-search-omega-{dc}' for (host, dc) in zip(target_hosts, target_dc)]
return main_hosts
(instances_codfw, instance_eqiad) = hostname_to_elasticsearch_instances(
['elastic1055.eqiad.wmnet', 'elastic1056.eqiad.wmnet', 'elastic2057.codfw.wmnet', 'elastic2058.codfw.wmnet', ])
assert instances_codfw == [
'elastic1055-production-search-codfw',
]
def ban_nodes(self, nodes: Iterable[str]):
'''
:param nodes: [elastic1001, elastic1002, ...]
:return:
'''
health = self._elasticsearch.cluster.health()
cluster_name = health['cluster_name']
try:
settings = self._elasticsearch.cluster.get_settings()
banned_nodes = settings['']
# extract the currently banned hosts
# add new nodes to list
# set settings with new list
self._elasticsearch.cluster.put_settings({"persistent":{"cluster.routing.allocation.exclude":{"_host": nodes}}})
except (RequestError, TransportError, HTTPError) as e:
raise ElasticsearchClusterError("Could not read or write elasticsearch settings") from e
Event Timeline
Gehel
created this paste.
Mar 23 2023, 8:29 PM
2023-03-23 20:29:43 (UTC+0)
Log In to Comment