Skip to content

Commit

Permalink
Debian 10 support (#68)
Browse files Browse the repository at this point in the history
* TOOLS-1224: (ASADM-HEALTHCHECK) Add new rules to check server health stats.

* TOOLS-1346: (ASADM-COLLECTINFO-ANALYSER) Fix conf parser to handle xdr-max-ship-bandwidth.

* TOOLS-1358: (ASADM-HEALTHCHECK) Add rule to check clock_skew_stop_writes.

* TOOLS-1360: (ASADM) Fix 'with' modifier for info command default execution.

* TOOLS-1362: (TOOLS) Add support for Debian 10.

* TOOLS-1364: (TOOLS) Remove support for deprecated Debian 7.

* TOOLS-1374: (ASADM-HEALTHCHECK) Add rule to check XDR overflow statistics.

* TOOLS-1377: (ASADM-HEALTHCHECK) Fix dynamic configuration check to handle configs with time unit.

* TOOLS-1379: (ASADM-COLLECTINFO-ANALYSER) Fix to read all internal files from compressed collectinfo file.

* TOOLS-1380: (ASADM) Support separate history files for each mode.

* TOOLS-1381: (ASADM) Fix collectinfo json dump error.
  • Loading branch information
hbpatre committed Jul 29, 2019
1 parent 5772a83 commit 268337f
Show file tree
Hide file tree
Showing 17 changed files with 262 additions and 154 deletions.
42 changes: 26 additions & 16 deletions asadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,32 +96,30 @@ def critical(self, msg, *args, **kwargs):
from lib.collectinfocontroller import CollectinfoRootController
from lib.logcontroller import LogRootController
from lib.utils import common, util, conf
from lib.utils.constants import ADMIN_HOME, AuthMode
from lib.utils.constants import ADMIN_HOME, AdminMode, AuthMode
from lib.view import terminal, view

__version__ = '$$__version__$$'
CMD_FILE_SINGLE_LINE_COMMENT_START = "//"
CMD_FILE_MULTI_LINE_COMMENT_START = "/*"
CMD_FILE_MULTI_LINE_COMMENT_END = "*/"

ADMINHIST = ADMIN_HOME + 'admin_hist'

MULTILEVEL_COMMANDS = ["show", "info"]


class AerospikeShell(cmd.Cmd):
def __init__(self, admin_version, seeds, user=None, password=None, auth_mode=AuthMode.INTERNAL, use_services_alumni=False, use_services_alt=False,
log_path="", log_analyser=False, collectinfo=False,
def __init__(self, admin_version, seeds, user=None, password=None, auth_mode=AuthMode.INTERNAL,
use_services_alumni=False, use_services_alt=False, log_path="", mode=AdminMode.LIVE_CLUSTER,
ssl_context=None, only_connect_seed=False, execute_only_mode=False, timeout=5):

# indicates shell created successfully and connected to cluster/collectinfo/logfile
self.connected = True

self.admin_history = ADMIN_HOME + 'admin_' + str(mode).lower() + "_history"
self.execute_only_mode = execute_only_mode

if log_analyser:
if mode == AdminMode.LOG_ANALYZER:
self.name = 'Aerospike Log Analyzer Shell'
elif collectinfo:
elif mode == AdminMode.COLLECTINFO_ANALYZER:
self.name = 'Aerospike Collectinfo Shell'
else:
self.name = 'Aerospike Interactive Shell'
Expand All @@ -133,13 +131,13 @@ def __init__(self, admin_version, seeds, user=None, password=None, auth_mode=Aut
cmd.Cmd.__init__(self)

try:
if log_analyser:
if mode == AdminMode.LOG_ANALYZER:
if not log_path:
log_path = " "
self.ctrl = LogRootController(admin_version, log_path)

self.prompt = "Log-analyzer> "
elif collectinfo:
elif mode == AdminMode.COLLECTINFO_ANALYZER:
if not log_path:
logger.error(
"You have not specified any collectinfo path. Usage: asadm -c -f <collectinfopath>")
Expand Down Expand Up @@ -203,10 +201,11 @@ def __init__(self, admin_version, seeds, user=None, password=None, auth_mode=Aut
logger.critical(str(e))

if not execute_only_mode:

try:
readline.read_history_file(ADMINHIST)
readline.read_history_file(self.admin_history)
except Exception:
readline.write_history_file(ADMINHIST)
readline.write_history_file(self.admin_history)

self.commands = set()

Expand Down Expand Up @@ -411,7 +410,7 @@ def close(self):
def do_exit(self, line):
self.close()
if not self.execute_only_mode and readline.get_current_history_length() > 0:
readline.write_history_file(ADMINHIST)
readline.write_history_file(self.admin_history)

return True

Expand Down Expand Up @@ -466,6 +465,9 @@ def do_ctrl_c(*args, **kwargs):


def parse_tls_input(cli_args):
if cli_args.collectinfo:
return None

try:
keyfile_password = cli_args.tls_keyfile_password

Expand Down Expand Up @@ -553,6 +555,15 @@ def main():
if cli_args.no_color:
disable_coloring()

mode = AdminMode.LIVE_CLUSTER
if cli_args.collectinfo:
mode = AdminMode.COLLECTINFO_ANALYZER

if cli_args.log_analyser:
if cli_args.collectinfo:
logger.critical("collectinfo-analyser and log-analyser are mutually exclusive options. Please enable only one.")
mode = AdminMode.LOG_ANALYZER

if not os.path.isdir(ADMIN_HOME):
os.makedirs(ADMIN_HOME)

Expand All @@ -572,7 +583,7 @@ def main():

if cli_args.asinfo_mode:

if cli_args.collectinfo or cli_args.log_analyser:
if mode == AdminMode.COLLECTINFO_ANALYZER or mode == AdminMode.LOG_ANALYZER:
logger.critical("asinfo mode can not work with Collectinfo-analyser or Log-analyser mode.")

commands_arg = cli_args.execute
Expand All @@ -597,8 +608,7 @@ def main():
use_services_alumni=cli_args.services_alumni,
use_services_alt=cli_args.services_alternate,
log_path=cli_args.log_path,
log_analyser=cli_args.log_analyser,
collectinfo=cli_args.collectinfo,
mode=mode,
ssl_context=ssl_context,
only_connect_seed=cli_args.single_node,
execute_only_mode=execute_only_mode, timeout=cli_args.timeout)
Expand Down
11 changes: 9 additions & 2 deletions lib/basiccontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,14 @@ def _do_default(self, line):
# 'info namespace object', but since it is not correct command it should print output for partial correct
# command, in this case it should print data for 'info'. To keep consistent output format, we are passing empty
# list as line.
actions.extend(self.controller_map['namespace'](get_futures=True)([])['futures'])
res = self.controller_map['namespace'](get_futures=True)(line)
if isinstance(res, dict):
if 'futures' in res:
actions.extend(res['futures'])
else:
for action in res:
if action:
actions.append(action)
actions.append(util.Future(self.do_xdr, line).start())

return [action.result() for action in actions]
Expand Down Expand Up @@ -389,7 +396,7 @@ def do_object_size(self, line):
units = None

try:
units = common.is_new_histogram_version(histogram)
units = common.get_histogram_units(histogram)

if units is None:
units = 'Record Blocks'
Expand Down
18 changes: 9 additions & 9 deletions lib/client/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
import re
import socket
import threading
from distutils.version import LooseVersion
from time import time

from lib.client import util
from lib.client.assocket import ASSocket
from lib.collectinfo_parser import conf_parser
from lib.collectinfo_parser.full_parser import parse_system_live_command
from lib.utils import common
from lib.utils.constants import AuthMode, SERVER_OLD_HISTOGRAM_LAST_VERSION
from lib.utils.constants import AuthMode

#### Remote Server connection module

Expand Down Expand Up @@ -241,7 +240,7 @@ def connect(self, address, port):
self._key = hash(self._service_IP_port)
if self.has_peers_changed():
self.peers = self.info_peers_list()
self.new_histogram_version = self._is_new_hist_version()
self.new_histogram_version = self._is_new_histogram_version()
self.alive = True

except Exception:
Expand Down Expand Up @@ -353,15 +352,12 @@ def has_peers_changed(self):
except Exception:
return True

def _is_new_hist_version(self):
def _is_new_histogram_version(self):
as_version = self.info("build")
if isinstance(as_version, Exception):
return False

if LooseVersion(as_version) > LooseVersion(SERVER_OLD_HISTOGRAM_LAST_VERSION):
return True

return False
return common.is_new_histogram_version(as_version)

def _get_connection(self, ip, port):
sock = None
Expand Down Expand Up @@ -1468,7 +1464,11 @@ def _get_localhost_system_statistics(self, commands):
if (e and not ignore_error) or not o:
continue
else:
parse_system_live_command(_key, o, sys_stats)
try:
parse_system_live_command(_key, o, sys_stats)
except Exception:
pass

break

return sys_stats
Expand Down
13 changes: 8 additions & 5 deletions lib/collectinfo/cinfolog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from distutils.version import LooseVersion

from lib.collectinfo_parser.full_parser import parse_info_all
from lib.utils import constants, util
from lib.utils import common, util
from lib.utils.lookupdict import LookupDict


Expand Down Expand Up @@ -224,13 +224,14 @@ def get_data(self, type="", stanza=""):

else:
# old collectinfo does not have object-size-logarithmic
# it should return objsz if server version is <= SERVER_OLD_HISTOGRAM_LAST_VERSION
# it should return objsz if server version is old
as_version = node_data['as_stat']['meta_data']['asd_build']
if not LooseVersion(as_version) > LooseVersion(constants.SERVER_OLD_HISTOGRAM_LAST_VERSION):
if not common.is_new_histogram_version(as_version) and 'objsz' in d:
data[node] = copy.deepcopy(d['objsz'])

else:
data[node] = {}

else:
data[node] = copy.deepcopy(d[stanza])

Expand Down Expand Up @@ -409,8 +410,10 @@ def __init__(self, cinfo_path, files, reader):
for ts in sorted(self.data.keys(), reverse=True):
if self.data[ts]:
for cl in self.data[ts]:
self.snapshots[ts] = CollectinfoSnapshot(
cl, ts, self.data[ts][cl], cinfo_path)
cinfo_data = self.data[ts][cl]
if cinfo_data and not isinstance(cinfo_data, Exception):
self.snapshots[ts] = CollectinfoSnapshot(
cl, ts, cinfo_data, cinfo_path)

# Since we are not dealing with timeseries we should fetch only one snapshot
break
Expand Down
Loading

0 comments on commit 268337f

Please sign in to comment.