fix details & optimize delete es index code
Change-Id: I34ead1f3ffec6dd5a3ae9c38264cbfc6bff6e918
This commit is contained in:
parent
de3899ebe7
commit
41bb0f4e03
@ -26,7 +26,7 @@ _KNOWN_VERSIONS = {
|
|||||||
"v1.0": {
|
"v1.0": {
|
||||||
"id": "v1.0",
|
"id": "v1.0",
|
||||||
"status": "SUPPORTED",
|
"status": "SUPPORTED",
|
||||||
"updated": "2014-06-28T12:20:21Z",
|
"updated": "2023-02-28T18:43:00Z",
|
||||||
"links": [
|
"links": [
|
||||||
{
|
{
|
||||||
"rel": "describedby",
|
"rel": "describedby",
|
||||||
|
@ -27,7 +27,7 @@ TASK_NAME = "delete_es_index"
|
|||||||
|
|
||||||
|
|
||||||
class DeleteESIndexTask(object):
|
class DeleteESIndexTask(object):
|
||||||
"""delete es index task."""
|
"""delete es index task"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.elasticsearch_url = CONF.elasticsearch.url
|
self.elasticsearch_url = CONF.elasticsearch.url
|
||||||
@ -35,17 +35,22 @@ class DeleteESIndexTask(object):
|
|||||||
self.search_lib = ESSearchObj()
|
self.search_lib = ESSearchObj()
|
||||||
|
|
||||||
def delete_index(self, name):
|
def delete_index(self, name):
|
||||||
url = self.elasticsearch_url + '/' + name
|
try:
|
||||||
status, text = utils.request_es(url, "DELETE")
|
url = self.elasticsearch_url + '/' + name
|
||||||
if status != 200:
|
status, text = utils.request_es(url, "DELETE")
|
||||||
LOG.error(_LE("failed to delete es index: %s"), name)
|
if status != 200:
|
||||||
return
|
LOG.error(_LE("failed to delete es index: %s"), name)
|
||||||
|
return
|
||||||
|
except Exception as e:
|
||||||
|
LOG.error(_LE("delete es inidex:%s, catch exception:%s"),
|
||||||
|
name, str(e))
|
||||||
|
|
||||||
def delete_es_history_index(self):
|
def delete_es_history_index(self):
|
||||||
len_d = self.config_api.get_config("log_save_days")
|
len_d = self.config_api.get_config("log_save_days")
|
||||||
if len_d is None:
|
if len_d is None:
|
||||||
LOG.error(_LE("the config of log_save_days do not exist"))
|
LOG.error(_LE("the config of log_save_days do not exist"))
|
||||||
return
|
return
|
||||||
|
|
||||||
LOG.info(_LI("elasticsearch indexes(log) save days: %d"), len_d)
|
LOG.info(_LI("elasticsearch indexes(log) save days: %d"), len_d)
|
||||||
today = time.strftime('%Y-%m-%d')
|
today = time.strftime('%Y-%m-%d')
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user