improve delete_es_index_task log
Change-Id: Ic47c8abf2760896f57a2a388633a7cafe24e5296
This commit is contained in:
parent
aed02ca86c
commit
b62f9dad83
@ -42,7 +42,7 @@ class DeleteESIndexTask(object):
|
||||
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"),
|
||||
LOG.error(_LE("delete es index:%s, catch exception:%s"),
|
||||
name, str(e))
|
||||
|
||||
def delete_es_outdated_index(self):
|
||||
@ -51,27 +51,27 @@ class DeleteESIndexTask(object):
|
||||
LOG.error(_LE("the config of log_save_days do not exist"))
|
||||
return
|
||||
|
||||
LOG.info(_LI("elasticsearch indexes(log) save days: %s"), len_d)
|
||||
LOG.info(_LI("es indexes(log) save days: %s"), len_d)
|
||||
today = time.strftime('%Y-%m-%d')
|
||||
try:
|
||||
indexes_array = self.search_lib.get_all_index()
|
||||
for index in indexes_array:
|
||||
index_name = index["index"]
|
||||
|
||||
index_day = index_name.split('-')[1]
|
||||
today_start = datetime.datetime.strptime(today, "%Y-%m-%d")
|
||||
index_start = datetime.datetime.strptime(index_day, '%Y.%m.%d')
|
||||
diff_day = today_start - index_start
|
||||
|
||||
if diff_day.days >= int(len_d):
|
||||
LOG.info(_LI("delete index %s, diff day %d"),
|
||||
LOG.info(_LI("deleted index %s, diff day %d"),
|
||||
index_name, diff_day.days)
|
||||
self.delete_index(index_name)
|
||||
else:
|
||||
LOG.debug(_LI("not delete index %s, diff day %d"),
|
||||
LOG.debug(_LI("reserved index %s, diff day %d"),
|
||||
index_name, diff_day.days)
|
||||
|
||||
except Exception as e:
|
||||
LOG.error(_LE("delete es inidex, catch exception:%s"), str(e))
|
||||
LOG.error(_LE("delete es index, catch exception:%s"), str(e))
|
||||
|
||||
def start_task(self):
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user