Skip to content

Commit a856ac9

Browse files
authored
Fix store check when offline & add cluster manager log file config (#385)
1 parent d72ddee commit a856ac9

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

Diff for: cluster_manage/flash_cluster_manager.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import logging
33
import os
44
import socket
5-
import sys
65
import time
6+
from logging.handlers import RotatingFileHandler
77

88
import conf
99
import etcd
@@ -253,12 +253,14 @@ def table_update(self):
253253

254254
def main():
255255
flash_conf = conf.flash_conf
256-
257-
if not os.path.exists(flash_conf.tmp_path):
258-
os.makedirs(flash_conf.tmp_path)
259-
260-
logging.basicConfig(filename='{}/flash_cluster_manager.log'.format(flash_conf.tmp_path), level=conf.log_level,
261-
format='%(asctime)s <%(levelname)s> %(name)s: %(message)s')
256+
parent_path = os.path.dirname(flash_conf.log_path)
257+
if not os.path.exists(parent_path):
258+
os.makedirs(parent_path)
259+
260+
# keep at most 10G log files
261+
logging.basicConfig(
262+
handlers=[RotatingFileHandler(flash_conf.log_path, maxBytes=1024 * 1024 * 1024, backupCount=10)],
263+
level=conf.log_level, format='%(asctime)s <%(levelname)s> %(name)s: %(message)s')
262264
logging.getLogger("requests").setLevel(logging.WARNING)
263265
logging.getLogger("urllib3").setLevel(logging.WARNING)
264266

Diff for: cluster_manage/flash_tools.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, file_path):
1212
self.pd_addrs = util.compute_addr_list(self.conf_toml['raft']['pd_addr'])
1313
self.http_port = self.conf_toml['http_port']
1414
self.data_path = self.conf_toml['path']
15-
self.tmp_path = self.conf_toml['tmp_path']
15+
tmp_path = self.conf_toml['tmp_path']
1616

1717
p = self.conf_toml['flash']
1818
service_addr = p['service_addr']
@@ -25,6 +25,7 @@ def __init__(self, file_path):
2525
self.cluster_refresh_interval = min(
2626
int(flash_cluster['refresh_interval']), self.cluster_master_ttl)
2727
self.update_rule_interval = int(flash_cluster['update_rule_interval'])
28+
self.log_path = flash_cluster.get('log', '{}/flash_cluster_manager.log'.format(tmp_path))
2829

2930

3031
def main():

Diff for: cluster_manage/pd_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def get_store_by_labels(self, flash_label):
123123
for store in all_stores['stores']:
124124
store = store['store']
125125
for label in store.get('labels', []):
126-
if label == flash_label and store.get('state_name') == 'Up':
126+
if label == flash_label and store.get('state_name') in ('Up', 'Offline'):
127127
res[store['id']] = store
128128
return res
129129

0 commit comments

Comments
 (0)