kaqing 2.0.184__py3-none-any.whl → 2.0.227__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kaqing might be problematic. Click here for more details.
- adam/app_session.py +1 -1
- adam/batch.py +15 -15
- adam/checks/compactionstats.py +2 -1
- adam/checks/cpu.py +2 -1
- adam/checks/disk.py +6 -5
- adam/checks/gossip.py +2 -1
- adam/checks/memory.py +2 -1
- adam/checks/status.py +2 -1
- adam/commands/app/app.py +4 -4
- adam/commands/app/app_ping.py +2 -2
- adam/commands/{login.py → app/login.py} +2 -2
- adam/commands/app/show_app_actions.py +3 -3
- adam/commands/app/show_app_id.py +2 -2
- adam/commands/app/show_app_queues.py +2 -2
- adam/commands/{show → app}/show_login.py +3 -3
- adam/commands/app/utils_app.py +9 -1
- adam/commands/audit/audit.py +8 -24
- adam/commands/audit/audit_repair_tables.py +3 -3
- adam/commands/audit/audit_run.py +3 -3
- adam/commands/audit/completions_l.py +15 -0
- adam/commands/audit/show_last10.py +2 -3
- adam/commands/audit/show_slow10.py +2 -2
- adam/commands/audit/show_top10.py +2 -2
- adam/commands/bash/bash.py +3 -3
- adam/commands/bash/utils_bash.py +1 -1
- adam/commands/cassandra/download_cassandra_log.py +45 -0
- adam/commands/cassandra/restart_cluster.py +47 -0
- adam/commands/cassandra/restart_node.py +51 -0
- adam/commands/cassandra/restart_nodes.py +47 -0
- adam/commands/{rollout.py → cassandra/rollout.py} +3 -3
- adam/commands/{show → cassandra}/show_cassandra_repairs.py +7 -5
- adam/commands/{show → cassandra}/show_cassandra_status.py +24 -17
- adam/commands/{show → cassandra}/show_cassandra_version.py +2 -2
- adam/commands/cassandra/show_processes.py +50 -0
- adam/commands/cassandra/show_storage.py +44 -0
- adam/commands/{watch.py → cassandra/watch.py} +2 -2
- adam/commands/cli/__init__.py +0 -0
- adam/commands/{cli_commands.py → cli/cli_commands.py} +6 -1
- adam/commands/{clipboard_copy.py → cli/clipboard_copy.py} +4 -4
- adam/commands/{show/show_commands.py → cli/show_cli_commands.py} +5 -5
- adam/commands/code.py +2 -2
- adam/commands/command.py +54 -14
- adam/commands/commands_utils.py +14 -6
- adam/commands/config/__init__.py +0 -0
- adam/commands/{param_get.py → config/param_get.py} +2 -2
- adam/commands/{param_set.py → config/param_set.py} +2 -2
- adam/commands/{show → config}/show_params.py +3 -3
- adam/commands/{alter_tables.py → cql/alter_tables.py} +3 -3
- adam/commands/cql/completions_c.py +29 -0
- adam/commands/cql/cqlsh.py +4 -8
- adam/commands/cql/utils_cql.py +36 -17
- adam/commands/debug/__init__.py +0 -0
- adam/commands/debug/debug.py +22 -0
- adam/commands/debug/debug_completes.py +35 -0
- adam/commands/debug/debug_timings.py +35 -0
- adam/commands/debug/show_offloaded_completes.py +45 -0
- adam/commands/deploy/code_start.py +2 -2
- adam/commands/deploy/code_stop.py +2 -2
- adam/commands/deploy/deploy_frontend.py +2 -2
- adam/commands/deploy/deploy_pg_agent.py +2 -2
- adam/commands/deploy/deploy_pod.py +2 -2
- adam/commands/deploy/undeploy_frontend.py +2 -2
- adam/commands/deploy/undeploy_pg_agent.py +2 -2
- adam/commands/deploy/undeploy_pod.py +2 -2
- adam/commands/devices/device.py +37 -11
- adam/commands/devices/device_app.py +7 -7
- adam/commands/devices/device_auit_log.py +2 -2
- adam/commands/devices/device_cass.py +6 -6
- adam/commands/devices/device_export.py +7 -4
- adam/commands/devices/device_postgres.py +19 -9
- adam/commands/devices/devices.py +1 -1
- adam/commands/diag/__init__.py +0 -0
- adam/commands/{check.py → diag/check.py} +3 -3
- adam/commands/diag/generate_report.py +52 -0
- adam/commands/{issues.py → diag/issues.py} +3 -2
- adam/commands/exit.py +2 -2
- adam/commands/export/clean_up_all_export_sessions.py +2 -2
- adam/commands/export/clean_up_export_sessions.py +2 -2
- adam/commands/export/completions_x.py +11 -0
- adam/commands/export/download_export_session.py +5 -5
- adam/commands/export/drop_export_database.py +2 -2
- adam/commands/export/drop_export_databases.py +2 -2
- adam/commands/export/export.py +3 -19
- adam/commands/export/export_databases.py +20 -11
- adam/commands/export/export_select.py +9 -34
- adam/commands/export/export_sessions.py +13 -11
- adam/commands/export/export_use.py +6 -6
- adam/commands/export/export_x_select.py +48 -0
- adam/commands/export/exporter.py +140 -53
- adam/commands/export/import_files.py +3 -7
- adam/commands/export/import_session.py +2 -6
- adam/commands/export/importer.py +12 -13
- adam/commands/export/importer_athena.py +15 -35
- adam/commands/export/importer_sqlite.py +19 -8
- adam/commands/export/show_column_counts.py +11 -12
- adam/commands/export/show_export_databases.py +4 -4
- adam/commands/export/show_export_session.py +5 -5
- adam/commands/export/show_export_sessions.py +4 -4
- adam/commands/export/utils_export.py +40 -25
- adam/commands/fs/__init__.py +0 -0
- adam/commands/{cat.py → fs/cat.py} +4 -4
- adam/commands/fs/cat_local.py +42 -0
- adam/commands/{cd.py → fs/cd.py} +4 -4
- adam/commands/{download_file.py → fs/download_file.py} +7 -7
- adam/commands/{find_files.py → fs/find_files.py} +7 -7
- adam/commands/{find_processes.py → fs/find_processes.py} +14 -22
- adam/commands/{head.py → fs/head.py} +5 -5
- adam/commands/fs/head_local.py +46 -0
- adam/commands/{ls.py → fs/ls.py} +4 -4
- adam/commands/fs/ls_local.py +40 -0
- adam/commands/{pwd.py → fs/pwd.py} +2 -2
- adam/commands/fs/rm.py +18 -0
- adam/commands/fs/rm_downloads.py +39 -0
- adam/commands/fs/rm_logs.py +44 -0
- adam/commands/fs/rm_logs_local.py +38 -0
- adam/commands/{shell.py → fs/shell.py} +2 -2
- adam/commands/{show → fs}/show_adam.py +3 -3
- adam/commands/{show → fs}/show_host.py +2 -2
- adam/commands/fs/show_last_results.py +39 -0
- adam/commands/fs/tail.py +36 -0
- adam/commands/fs/tail_local.py +46 -0
- adam/commands/fs/utils_fs.py +192 -0
- adam/commands/help.py +2 -2
- adam/commands/intermediate_command.py +3 -0
- adam/commands/kubectl.py +2 -2
- adam/commands/medusa/medusa_backup.py +2 -2
- adam/commands/medusa/medusa_restore.py +4 -18
- adam/commands/medusa/medusa_show_backupjobs.py +2 -2
- adam/commands/medusa/medusa_show_restorejobs.py +2 -2
- adam/commands/medusa/utils_medusa.py +15 -0
- adam/commands/nodetool/__init__.py +0 -0
- adam/commands/nodetool/nodetool.py +87 -0
- adam/commands/nodetool/utils_nodetool.py +44 -0
- adam/commands/postgres/completions_p.py +22 -0
- adam/commands/postgres/postgres.py +10 -20
- adam/commands/postgres/postgres_databases.py +3 -3
- adam/commands/postgres/postgres_ls.py +3 -3
- adam/commands/postgres/postgres_preview.py +2 -2
- adam/commands/postgres/utils_postgres.py +12 -2
- adam/commands/preview_table.py +3 -4
- adam/commands/reaper/reaper_forward.py +2 -2
- adam/commands/reaper/reaper_forward_stop.py +2 -2
- adam/commands/reaper/reaper_restart.py +2 -2
- adam/commands/reaper/reaper_run_abort.py +2 -2
- adam/commands/reaper/reaper_runs.py +14 -12
- adam/commands/reaper/reaper_runs_abort.py +2 -2
- adam/commands/reaper/reaper_schedule_activate.py +8 -4
- adam/commands/reaper/reaper_schedule_start.py +3 -4
- adam/commands/reaper/reaper_schedule_stop.py +3 -4
- adam/commands/reaper/reaper_schedules.py +2 -2
- adam/commands/reaper/reaper_status.py +2 -2
- adam/commands/reaper/utils_reaper.py +41 -6
- adam/commands/repair/repair_log.py +2 -2
- adam/commands/repair/repair_run.py +2 -2
- adam/commands/repair/repair_scan.py +2 -4
- adam/commands/repair/repair_stop.py +2 -3
- adam/commands/{show/show.py → show.py} +12 -11
- adam/config.py +4 -5
- adam/embedded_params.py +1 -1
- adam/repl.py +24 -10
- adam/repl_commands.py +68 -45
- adam/repl_session.py +16 -1
- adam/repl_state.py +16 -1
- adam/sql/async_executor.py +62 -0
- adam/sql/lark_completer.py +286 -0
- adam/sql/lark_parser.py +604 -0
- adam/sql/qingl.lark +1075 -0
- adam/sso/cred_cache.py +2 -5
- adam/utils.py +259 -82
- adam/utils_async_job.py +73 -0
- adam/utils_k8s/app_clusters.py +11 -4
- adam/utils_k8s/app_pods.py +10 -5
- adam/utils_k8s/cassandra_clusters.py +19 -7
- adam/utils_k8s/cassandra_nodes.py +16 -6
- adam/utils_k8s/k8s.py +9 -0
- adam/utils_k8s/kube_context.py +1 -4
- adam/{pod_exec_result.py → utils_k8s/pod_exec_result.py} +8 -2
- adam/utils_k8s/pods.py +189 -29
- adam/utils_k8s/statefulsets.py +5 -2
- adam/utils_local.py +78 -2
- adam/utils_repl/appendable_completer.py +6 -0
- adam/utils_repl/repl_completer.py +51 -4
- adam/utils_sqlite.py +3 -8
- adam/version.py +1 -1
- {kaqing-2.0.184.dist-info → kaqing-2.0.227.dist-info}/METADATA +1 -1
- kaqing-2.0.227.dist-info/RECORD +280 -0
- kaqing-2.0.227.dist-info/top_level.txt +2 -0
- teddy/__init__.py +0 -0
- teddy/lark_parser.py +436 -0
- teddy/lark_parser2.py +618 -0
- adam/commands/cql/cql_completions.py +0 -32
- adam/commands/export/export_select_x.py +0 -54
- adam/commands/logs.py +0 -37
- adam/commands/nodetool.py +0 -69
- adam/commands/postgres/psql_completions.py +0 -11
- adam/commands/report.py +0 -61
- adam/commands/restart.py +0 -60
- adam/commands/show/show_processes.py +0 -49
- adam/commands/show/show_storage.py +0 -42
- kaqing-2.0.184.dist-info/RECORD +0 -244
- kaqing-2.0.184.dist-info/top_level.txt +0 -1
- /adam/commands/{show → cassandra}/__init__.py +0 -0
- /adam/commands/{nodetool_commands.py → nodetool/nodetool_commands.py} +0 -0
- {kaqing-2.0.184.dist-info → kaqing-2.0.227.dist-info}/WHEEL +0 -0
- {kaqing-2.0.184.dist-info → kaqing-2.0.227.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from adam.commands import extract_options, validate_args
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.utils_k8s.pods import Pods
|
|
4
|
+
from adam.utils_k8s.statefulsets import StatefulSets
|
|
5
|
+
from adam.repl_state import ReplState, RequiredState
|
|
6
|
+
from adam.utils import log2
|
|
7
|
+
|
|
8
|
+
class RestartNodes(Command):
|
|
9
|
+
COMMAND = 'restart nodes'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(RestartNodes, cls).__new__(cls)
|
|
14
|
+
|
|
15
|
+
return cls.instance
|
|
16
|
+
|
|
17
|
+
def __init__(self, successor: Command=None):
|
|
18
|
+
super().__init__(successor)
|
|
19
|
+
|
|
20
|
+
def command(self):
|
|
21
|
+
return RestartNodes.COMMAND
|
|
22
|
+
|
|
23
|
+
def required(self):
|
|
24
|
+
return RequiredState.CLUSTER
|
|
25
|
+
|
|
26
|
+
def run(self, cmd: str, state: ReplState):
|
|
27
|
+
if not(args := self.args(cmd)):
|
|
28
|
+
return super().run(cmd, state)
|
|
29
|
+
|
|
30
|
+
with self.validate(args, state, apply=False) as (args, state):
|
|
31
|
+
with extract_options(args, '--force') as (args, forced):
|
|
32
|
+
with validate_args(args, state, name='pod name'):
|
|
33
|
+
if not forced:
|
|
34
|
+
log2('Please add --force for restarting nodes.')
|
|
35
|
+
|
|
36
|
+
return 'force-needed'
|
|
37
|
+
|
|
38
|
+
for arg in args:
|
|
39
|
+
Pods.delete(arg, state.namespace)
|
|
40
|
+
|
|
41
|
+
return state
|
|
42
|
+
|
|
43
|
+
def completion(self, state: ReplState):
|
|
44
|
+
return super().completion(state, lambda: {p: {'--force': None} for p in StatefulSets.pod_names(state.sts, state.namespace)})
|
|
45
|
+
|
|
46
|
+
def help(self, state: ReplState):
|
|
47
|
+
return super().help(state, 'restart Cassandra nodes', args='<pod-name>... --force')
|
|
@@ -3,8 +3,8 @@ from kubernetes import client
|
|
|
3
3
|
from kubernetes.client.rest import ApiException
|
|
4
4
|
|
|
5
5
|
from adam.commands import extract_options
|
|
6
|
+
from adam.commands.cassandra.watch import Watch
|
|
6
7
|
from adam.commands.command import Command
|
|
7
|
-
from adam.commands.watch import Watch
|
|
8
8
|
from adam.utils_k8s.statefulsets import StatefulSets
|
|
9
9
|
from adam.config import Config
|
|
10
10
|
from adam.repl_state import ReplState, RequiredState
|
|
@@ -84,5 +84,5 @@ class RollOut(Command):
|
|
|
84
84
|
|
|
85
85
|
return {}
|
|
86
86
|
|
|
87
|
-
def help(self,
|
|
88
|
-
return
|
|
87
|
+
def help(self, state: ReplState):
|
|
88
|
+
return super().help(state, 'rollout all nodes --force ignore current rolling out', args='[--force]')
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from adam.commands import extract_trailing_options
|
|
1
2
|
from adam.commands.command import Command
|
|
2
3
|
from adam.commands.cql.utils_cql import cassandra
|
|
3
4
|
from adam.repl_state import ReplState, RequiredState
|
|
@@ -25,11 +26,12 @@ class ShowCassandraRepairs(Command):
|
|
|
25
26
|
return super().run(cmd, state)
|
|
26
27
|
|
|
27
28
|
with self.validate(args, state) as (args, state):
|
|
28
|
-
with
|
|
29
|
-
|
|
29
|
+
with extract_trailing_options(args, '&') as (args, backgrounded):
|
|
30
|
+
with cassandra(state) as pods:
|
|
31
|
+
return pods.nodetool('repair_admin list', backgrounded=backgrounded)
|
|
30
32
|
|
|
31
33
|
def completion(self, state: ReplState):
|
|
32
|
-
return super().completion(state)
|
|
34
|
+
return super().completion(state, {'&': None})
|
|
33
35
|
|
|
34
|
-
def help(self,
|
|
35
|
-
return
|
|
36
|
+
def help(self, state: ReplState):
|
|
37
|
+
return super().help(state, 'show Cassandra repairs', args='[&]')
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from datetime import datetime
|
|
1
2
|
import sys
|
|
2
3
|
|
|
3
4
|
from adam.checks.check_result import CheckResult
|
|
@@ -5,14 +6,16 @@ from adam.checks.check_utils import run_checks
|
|
|
5
6
|
from adam.checks.compactionstats import CompactionStats
|
|
6
7
|
from adam.checks.gossip import Gossip
|
|
7
8
|
from adam.columns.columns import Columns
|
|
8
|
-
from adam.commands import extract_options
|
|
9
|
+
from adam.commands import extract_options, extract_trailing_options
|
|
9
10
|
from adam.commands.command import Command
|
|
11
|
+
from adam.commands.commands_utils import write_to_kaqing_log_file
|
|
10
12
|
from adam.commands.cql.utils_cql import cassandra
|
|
11
13
|
from adam.config import Config
|
|
14
|
+
from adam.repl_session import ReplSession
|
|
12
15
|
from adam.utils_issues import IssuesUtils
|
|
13
16
|
from adam.utils_k8s.statefulsets import StatefulSets
|
|
14
17
|
from adam.repl_state import ReplState, RequiredState
|
|
15
|
-
from adam.utils import SORT,
|
|
18
|
+
from adam.utils import SORT, log_dir, tabulize, log2, log_exc
|
|
16
19
|
from adam.checks.status import parse_nodetool_status
|
|
17
20
|
|
|
18
21
|
class ShowCassandraStatus(Command):
|
|
@@ -38,23 +41,24 @@ class ShowCassandraStatus(Command):
|
|
|
38
41
|
return super().run(cmd, state)
|
|
39
42
|
|
|
40
43
|
with self.validate(args, state) as (args, state):
|
|
41
|
-
with
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
with extract_trailing_options(args, '&') as (args, backgrounded):
|
|
45
|
+
with extract_options(args, ['-s', '--show']) as (args, show_out):
|
|
46
|
+
if state.namespace and state.pod:
|
|
47
|
+
self.show_single_pod(state, show_out=show_out, backgrounded=backgrounded)
|
|
48
|
+
elif state.namespace and state.sts:
|
|
49
|
+
self.merge(state, Config().get('nodetool.samples', sys.maxsize), show_output=show_out, backgrounded=backgrounded)
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
return state
|
|
48
52
|
|
|
49
|
-
def show_single_pod(self, state: ReplState, show_out = False):
|
|
53
|
+
def show_single_pod(self, state: ReplState, show_out = False, backgrounded = False):
|
|
50
54
|
with log_exc(True):
|
|
51
55
|
with cassandra(state) as pods:
|
|
52
56
|
result = pods.nodetool('status', show_out=False)
|
|
53
57
|
status = parse_nodetool_status(result.stdout)
|
|
54
58
|
check_results = run_checks(cluster=state.sts, namespace=state.namespace, checks=[CompactionStats(), Gossip()], show_out=show_out)
|
|
55
|
-
self.show_table(status, check_results)
|
|
59
|
+
self.show_table(status, check_results, backgrounded=backgrounded)
|
|
56
60
|
|
|
57
|
-
def merge(self, state: ReplState, samples: int, show_output=False):
|
|
61
|
+
def merge(self, state: ReplState, samples: int, show_output=False, backgrounded = False):
|
|
58
62
|
statuses: list[list[dict]] = []
|
|
59
63
|
|
|
60
64
|
pod_names = StatefulSets.pod_names(state.sts, state.namespace)
|
|
@@ -73,7 +77,7 @@ class ShowCassandraStatus(Command):
|
|
|
73
77
|
combined_status = self.merge_status(statuses)
|
|
74
78
|
log2(f'Showing merged status from {len(statuses)}/{len(pod_names)} nodes...')
|
|
75
79
|
check_results = run_checks(cluster=state.sts, namespace=state.namespace, checks=[CompactionStats(), Gossip()], show_out=show_output)
|
|
76
|
-
self.show_table(combined_status, check_results)
|
|
80
|
+
self.show_table(combined_status, check_results, backgrounded=backgrounded)
|
|
77
81
|
|
|
78
82
|
return combined_status
|
|
79
83
|
|
|
@@ -94,17 +98,20 @@ class ShowCassandraStatus(Command):
|
|
|
94
98
|
|
|
95
99
|
return combined
|
|
96
100
|
|
|
97
|
-
def show_table(self, status: list[dict[str, any]], check_results: list[CheckResult]):
|
|
101
|
+
def show_table(self, status: list[dict[str, any]], check_results: list[CheckResult], backgrounded=False):
|
|
98
102
|
cols = Config().get('status.columns', 'status,address,load,tokens,owns,host_id,gossip,compactions')
|
|
99
103
|
header = Config().get('status.header', '--,Address,Load,Tokens,Owns,Host ID,GOSSIP,COMPACTIONS')
|
|
100
104
|
columns = Columns.create_columns(cols)
|
|
101
105
|
|
|
102
|
-
tabulize(status, lambda s: ','.join([c.host_value(check_results, s) for c in columns]), header=header, separator=',', sorted=SORT)
|
|
106
|
+
r = tabulize(status, lambda s: ','.join([c.host_value(check_results, s) for c in columns]), header=header, separator=',', sorted=SORT, to = 0 if backgrounded else 1)
|
|
107
|
+
|
|
108
|
+
if backgrounded:
|
|
109
|
+
r = write_to_kaqing_log_file(r)
|
|
103
110
|
|
|
104
111
|
IssuesUtils.show(check_results)
|
|
105
112
|
|
|
106
113
|
def completion(self, state: ReplState):
|
|
107
|
-
return super().completion(state, {'-s': None})
|
|
114
|
+
return super().completion(state, {'-s': {'&': None}, '&': None})
|
|
108
115
|
|
|
109
|
-
def help(self,
|
|
110
|
-
return
|
|
116
|
+
def help(self, state: ReplState):
|
|
117
|
+
return super().help(state, 'show merged nodetool status -s show processing details', args='[-s]')
|
|
@@ -31,5 +31,5 @@ class ShowCassandraVersion(Command):
|
|
|
31
31
|
def completion(self, state: ReplState):
|
|
32
32
|
return super().completion(state)
|
|
33
33
|
|
|
34
|
-
def help(self,
|
|
35
|
-
return
|
|
34
|
+
def help(self, state: ReplState):
|
|
35
|
+
return super().help(state, 'show Cassandra version')
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from adam.commands import extract_options, extract_sequence, extract_trailing_options
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.commands.cql.utils_cql import cassandra
|
|
4
|
+
from adam.config import Config
|
|
5
|
+
from adam.repl_state import ReplState, RequiredState
|
|
6
|
+
|
|
7
|
+
class ShowProcesses(Command):
|
|
8
|
+
COMMAND = 'show processes'
|
|
9
|
+
|
|
10
|
+
# the singleton pattern
|
|
11
|
+
def __new__(cls, *args, **kwargs):
|
|
12
|
+
if not hasattr(cls, 'instance'): cls.instance = super(ShowProcesses, cls).__new__(cls)
|
|
13
|
+
|
|
14
|
+
return cls.instance
|
|
15
|
+
|
|
16
|
+
def __init__(self, successor: Command=None):
|
|
17
|
+
super().__init__(successor)
|
|
18
|
+
|
|
19
|
+
def command(self):
|
|
20
|
+
return ShowProcesses.COMMAND
|
|
21
|
+
|
|
22
|
+
def required(self):
|
|
23
|
+
return RequiredState.CLUSTER_OR_POD
|
|
24
|
+
|
|
25
|
+
def run(self, cmd: str, state: ReplState):
|
|
26
|
+
if not(args := self.args(cmd)):
|
|
27
|
+
return super().run(cmd, state)
|
|
28
|
+
|
|
29
|
+
with self.validate(args, state) as (args, state):
|
|
30
|
+
with extract_trailing_options(args, '&') as (args, backgrounded):
|
|
31
|
+
with extract_options(args, ['-s', '--show']) as (args, show_out):
|
|
32
|
+
with extract_sequence(args, ['with', 'recipe', '=', 'mpstat']) as (_, recipe_qing):
|
|
33
|
+
cols = Config().get('processes.columns', 'pod,cpu-metrics,mem')
|
|
34
|
+
header = Config().get('processes.header', 'POD_NAME,M_CPU(USAGE/LIMIT),MEM/LIMIT')
|
|
35
|
+
if recipe_qing:
|
|
36
|
+
cols = Config().get('processes-mpstat.columns', 'pod,cpu,mem')
|
|
37
|
+
header = Config().get('processes-mpstat.header', 'POD_NAME,Q_CPU/TOTAL,MEM/LIMIT')
|
|
38
|
+
|
|
39
|
+
with cassandra(state) as pods:
|
|
40
|
+
pods.display_table(cols, header, show_out=show_out, backgrounded=backgrounded, msg='Checking processes')
|
|
41
|
+
|
|
42
|
+
return state
|
|
43
|
+
|
|
44
|
+
def completion(self, state: ReplState):
|
|
45
|
+
recipes = ['metrics', 'mpstat']
|
|
46
|
+
return super().completion(state, {'with': {'recipe': {'=': {r: {'-s': {'&': None}, '&': None} for r in recipes}}}, '-s': {'&': None}, '&': None})
|
|
47
|
+
# return super().completion(state, {'with': {'recipe': {'=': {'metrics': {'-s': {'&': None}, '&': None}, 'qing': {'-s': {'&': None}}}}}, '-s': {'&': None}, '&': None})
|
|
48
|
+
|
|
49
|
+
def help(self, state: ReplState):
|
|
50
|
+
return super().help(state, 'show process overview -s show processing details', args='[with recipe=metrics|mpstat] [-s]')
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from adam.commands import extract_options, extract_trailing_options
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.commands.cql.utils_cql import cassandra
|
|
4
|
+
from adam.config import Config
|
|
5
|
+
from adam.repl_state import ReplState, RequiredState
|
|
6
|
+
from adam.utils import ing
|
|
7
|
+
|
|
8
|
+
class ShowStorage(Command):
|
|
9
|
+
COMMAND = 'show storage'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(ShowStorage, cls).__new__(cls)
|
|
14
|
+
|
|
15
|
+
return cls.instance
|
|
16
|
+
|
|
17
|
+
def __init__(self, successor: Command=None):
|
|
18
|
+
super().__init__(successor)
|
|
19
|
+
|
|
20
|
+
def command(self):
|
|
21
|
+
return ShowStorage.COMMAND
|
|
22
|
+
|
|
23
|
+
def required(self):
|
|
24
|
+
return RequiredState.CLUSTER_OR_POD
|
|
25
|
+
|
|
26
|
+
def run(self, cmd: str, state: ReplState):
|
|
27
|
+
if not(args := self.args(cmd)):
|
|
28
|
+
return super().run(cmd, state)
|
|
29
|
+
|
|
30
|
+
with self.validate(args, state) as (args, state):
|
|
31
|
+
with extract_trailing_options(args, '&') as (args, backgrounded):
|
|
32
|
+
with extract_options(args, ['-s', '--show']) as (args, show_out):
|
|
33
|
+
cols = Config().get('storage.columns', 'pod,volume_root,volume_cassandra,snapshots,data,compactions')
|
|
34
|
+
header = Config().get('storage.header', 'POD_NAME,VOLUME /,VOLUME CASS,SNAPSHOTS,DATA,COMPACTIONS')
|
|
35
|
+
with cassandra(state) as pods:
|
|
36
|
+
pods.display_table(cols, header, show_out=show_out, backgrounded=backgrounded, msg='Checking storage')
|
|
37
|
+
|
|
38
|
+
return state
|
|
39
|
+
|
|
40
|
+
def completion(self, state: ReplState):
|
|
41
|
+
return super().completion(state, {'-s': {'&': None}, '&': None})
|
|
42
|
+
|
|
43
|
+
def help(self, state: ReplState):
|
|
44
|
+
return super().help(state, 'show storage overview -s show processing details', args='[-s]')
|
|
File without changes
|
|
@@ -3,14 +3,19 @@ import re
|
|
|
3
3
|
|
|
4
4
|
from adam.commands.reaper.utils_reaper import Reapers
|
|
5
5
|
from adam.config import Config
|
|
6
|
+
from adam.utils import log_timing
|
|
6
7
|
from adam.utils_k8s.kube_context import KubeContext
|
|
7
8
|
from adam.utils_k8s.secrets import Secrets
|
|
8
9
|
from adam.utils_k8s.statefulsets import StatefulSets
|
|
9
10
|
from adam.repl_state import ReplState
|
|
10
11
|
|
|
11
12
|
class CliCommands:
|
|
12
|
-
@functools.lru_cache()
|
|
13
13
|
def values(state: ReplState, collapse = False):
|
|
14
|
+
with log_timing('CliCommands.values'):
|
|
15
|
+
return CliCommands._values(state, collapse)
|
|
16
|
+
|
|
17
|
+
@functools.lru_cache()
|
|
18
|
+
def _values(state: ReplState, collapse = False):
|
|
14
19
|
# node-exec-?, nodetool-?, cql-?, reaper-exec, reaper-forward, reaper-ui, reaper-usernae, reaper-password
|
|
15
20
|
d = {}
|
|
16
21
|
|
|
@@ -3,9 +3,9 @@ import click
|
|
|
3
3
|
import pyperclip
|
|
4
4
|
|
|
5
5
|
from adam.commands import validate_args
|
|
6
|
+
from adam.commands.cli.cli_commands import CliCommands
|
|
6
7
|
from adam.commands.command import Command, InvalidArgumentsException
|
|
7
8
|
from adam.commands.command_helpers import ClusterOrPodCommandHelper
|
|
8
|
-
from adam.commands.cli_commands import CliCommands
|
|
9
9
|
from adam.repl_state import ReplState, RequiredState
|
|
10
10
|
from adam.utils import tabulize, log, log2
|
|
11
11
|
|
|
@@ -62,10 +62,10 @@ class ClipboardCopy(Command):
|
|
|
62
62
|
return state
|
|
63
63
|
|
|
64
64
|
def completion(self, state: ReplState):
|
|
65
|
-
return super().completion(state, lambda: {key: None for key in CliCommands.values(state).keys()})
|
|
65
|
+
return super().completion(state, lambda: {key: None for key in CliCommands.values(state).keys()}, auto_key='cli.cp-auto-complete')
|
|
66
66
|
|
|
67
|
-
def help(self,
|
|
68
|
-
return
|
|
67
|
+
def help(self, state: ReplState):
|
|
68
|
+
return super().help(state, 'copy a value to clipboard for conveninence', args='<key')
|
|
69
69
|
|
|
70
70
|
class CopyCommandHelper(click.Command):
|
|
71
71
|
def lines(self):
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
from adam.commands.cli.cli_commands import CliCommands
|
|
1
2
|
from adam.commands.command import Command
|
|
2
|
-
from adam.commands.cli_commands import CliCommands
|
|
3
3
|
from adam.repl_state import ReplState, RequiredState
|
|
4
|
-
from adam.utils import tabulize
|
|
4
|
+
from adam.utils import tabulize
|
|
5
5
|
|
|
6
6
|
class ShowKubectlCommands(Command):
|
|
7
7
|
COMMAND = 'show cli-commands'
|
|
@@ -22,7 +22,7 @@ class ShowKubectlCommands(Command):
|
|
|
22
22
|
return RequiredState.CLUSTER_OR_POD
|
|
23
23
|
|
|
24
24
|
def run(self, cmd: str, state: ReplState):
|
|
25
|
-
if not self.args(cmd):
|
|
25
|
+
if not (args := self.args(cmd)):
|
|
26
26
|
return super().run(cmd, state)
|
|
27
27
|
|
|
28
28
|
with self.validate(args, state) as (args, state):
|
|
@@ -52,5 +52,5 @@ class ShowKubectlCommands(Command):
|
|
|
52
52
|
def completion(self, state: ReplState):
|
|
53
53
|
return super().completion(state)
|
|
54
54
|
|
|
55
|
-
def help(self,
|
|
56
|
-
return
|
|
55
|
+
def help(self, state: ReplState):
|
|
56
|
+
return super().help(state, 'show kubectl commands')
|
adam/commands/code.py
CHANGED
|
@@ -53,5 +53,5 @@ class Code(Command):
|
|
|
53
53
|
def completion(self, state: ReplState):
|
|
54
54
|
return super().completion(state)
|
|
55
55
|
|
|
56
|
-
def help(self,
|
|
57
|
-
return
|
|
56
|
+
def help(self, state: ReplState):
|
|
57
|
+
return super().help(state, 'run interactive Python shell')
|
adam/commands/command.py
CHANGED
|
@@ -5,8 +5,10 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from typing import Union
|
|
7
7
|
|
|
8
|
+
from adam.config import Config
|
|
8
9
|
from adam.repl_state import ReplState, RequiredState
|
|
9
|
-
from adam.
|
|
10
|
+
from adam.sql.lark_completer import LarkCompleter
|
|
11
|
+
from adam.utils import log2
|
|
10
12
|
|
|
11
13
|
repl_cmds: list['Command'] = []
|
|
12
14
|
|
|
@@ -20,6 +22,9 @@ class Command:
|
|
|
20
22
|
def command(self) -> str:
|
|
21
23
|
pass
|
|
22
24
|
|
|
25
|
+
def aliases(self):
|
|
26
|
+
return None
|
|
27
|
+
|
|
23
28
|
# The chain of responsibility pattern
|
|
24
29
|
# Do not do child of child!!!
|
|
25
30
|
@abstractmethod
|
|
@@ -29,10 +34,10 @@ class Command:
|
|
|
29
34
|
|
|
30
35
|
return None
|
|
31
36
|
|
|
32
|
-
def completion(self, state: ReplState, leaf: dict[str, any] = None, pods: tuple[list[str], str] = None) -> dict[str, any]:
|
|
37
|
+
def completion(self, state: ReplState, leaf: dict[str, any] = None, pods: tuple[list[str], str] = None, auto: str = 'on', auto_key: str = None) -> dict[str, any]:
|
|
33
38
|
# pods is a tuple of list of pod names and the current pod repl is on
|
|
34
39
|
if not pods:
|
|
35
|
-
return self._completion(state, leaf)
|
|
40
|
+
return self._completion(state, leaf, auto=auto, auto_key=auto_key)
|
|
36
41
|
|
|
37
42
|
c = {}
|
|
38
43
|
|
|
@@ -40,23 +45,39 @@ class Command:
|
|
|
40
45
|
pod = pods[1]
|
|
41
46
|
|
|
42
47
|
if pod:
|
|
43
|
-
c |= self._completion(state, leaf)
|
|
48
|
+
c |= self._completion(state, leaf, auto=auto, auto_key=auto_key)
|
|
44
49
|
|
|
45
|
-
c |= {f'@{p}': self._completion(state, leaf, to_validate=False) for p in pod_names if p != pod}
|
|
50
|
+
c |= {f'@{p}': self._completion(state.with_pod(p), leaf, to_validate=False, auto=auto, auto_key=auto_key) for p in pod_names if p != pod}
|
|
46
51
|
|
|
47
52
|
return c
|
|
48
53
|
|
|
49
|
-
def _completion(self, state: ReplState, leaf: dict[str, any] = None, to_validate = True) -> dict[str, any]:
|
|
54
|
+
def _completion(self, state: ReplState, leaf: dict[str, any] = None, to_validate = True, auto: str = 'on', auto_key: str = None) -> dict[str, any]:
|
|
50
55
|
if to_validate and not self.validate_state(state, show_err=False):
|
|
51
56
|
return {}
|
|
52
57
|
|
|
53
|
-
if
|
|
54
|
-
|
|
58
|
+
if callable(leaf):
|
|
59
|
+
if auto_key:
|
|
60
|
+
auto_key = f'auto-complete.{auto_key}'
|
|
61
|
+
auto = Config().get(auto_key, 'off')
|
|
62
|
+
|
|
63
|
+
if auto == 'on':
|
|
64
|
+
leaf = leaf()
|
|
65
|
+
elif auto in ['lazy', 'jit']:
|
|
66
|
+
leaf = LarkCompleter.from_lambda(auto_key, leaf, auto=auto)
|
|
67
|
+
else:
|
|
68
|
+
leaf = None
|
|
55
69
|
|
|
56
70
|
d = leaf
|
|
57
71
|
for t in reversed(self.command().split(' ')):
|
|
58
72
|
d = {t: d}
|
|
59
73
|
|
|
74
|
+
if aliases := self.aliases():
|
|
75
|
+
for alias in aliases:
|
|
76
|
+
a = leaf
|
|
77
|
+
for t in reversed(alias.split(' ')):
|
|
78
|
+
a = {t: a}
|
|
79
|
+
d |= a
|
|
80
|
+
|
|
60
81
|
return d
|
|
61
82
|
|
|
62
83
|
def required(self) -> RequiredState:
|
|
@@ -68,16 +89,33 @@ class Command:
|
|
|
68
89
|
def validate_state(self, state: ReplState, show_err = True):
|
|
69
90
|
return state.validate(self.required(), show_err=show_err)
|
|
70
91
|
|
|
71
|
-
def help(self, _: ReplState
|
|
72
|
-
|
|
92
|
+
def help(self, _: ReplState, desc: str = None, command: str = None, args: str = None):
|
|
93
|
+
if not desc:
|
|
94
|
+
return None
|
|
95
|
+
|
|
96
|
+
if not command:
|
|
97
|
+
command = self.command()
|
|
98
|
+
if args:
|
|
99
|
+
args = f' {args}'
|
|
100
|
+
else:
|
|
101
|
+
args = ''
|
|
102
|
+
aliases = ' alias ' + ','.join(self.aliases()) if self.aliases() else ''
|
|
103
|
+
return f'{command}{args}{aliases}\t{desc}'
|
|
73
104
|
|
|
74
105
|
def args(self, cmd: str):
|
|
75
106
|
a = list(filter(None, cmd.split(' ')))
|
|
76
107
|
spec = self.command_tokens()
|
|
77
|
-
if spec
|
|
78
|
-
return
|
|
108
|
+
if spec == a[:len(spec)]:
|
|
109
|
+
return a
|
|
79
110
|
|
|
80
|
-
|
|
111
|
+
if aliases := self.aliases():
|
|
112
|
+
for alias in aliases:
|
|
113
|
+
a = list(filter(None, cmd.split(' ')))
|
|
114
|
+
spec = alias.split(' ')
|
|
115
|
+
if spec == a[:len(spec)]:
|
|
116
|
+
return a
|
|
117
|
+
|
|
118
|
+
return None
|
|
81
119
|
|
|
82
120
|
def apply_state(self, args: list[str], state: ReplState, resolve_pg = True, args_to_check = 6) -> tuple[ReplState, list[str]]:
|
|
83
121
|
"""
|
|
@@ -130,7 +168,7 @@ class Command:
|
|
|
130
168
|
options = [options]
|
|
131
169
|
|
|
132
170
|
if args and trailing:
|
|
133
|
-
while args[-1] in trailing:
|
|
171
|
+
while args and args[-1] in trailing:
|
|
134
172
|
found_trailing = True
|
|
135
173
|
args = args[:-1]
|
|
136
174
|
|
|
@@ -148,6 +186,8 @@ class Command:
|
|
|
148
186
|
return new_args, found_trailing, found_sequence, found_options
|
|
149
187
|
|
|
150
188
|
def extract_option_sequence(args, sequence):
|
|
189
|
+
new_args = args
|
|
190
|
+
|
|
151
191
|
len_sub = len(sequence)
|
|
152
192
|
len_main = len(args)
|
|
153
193
|
for i in range(len_main - len_sub + 1):
|
adam/commands/commands_utils.py
CHANGED
|
@@ -8,7 +8,7 @@ from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
|
8
8
|
from adam.utils_k8s.pods import Pods
|
|
9
9
|
from adam.utils_k8s.statefulsets import StatefulSets
|
|
10
10
|
from adam.repl_state import ReplState
|
|
11
|
-
from adam.utils import SORT, duration,
|
|
11
|
+
from adam.utils import SORT, duration, kaqing_log_file, tabulize, log2
|
|
12
12
|
|
|
13
13
|
def show_pods(pods: List[client.V1Pod], ns: str, show_namespace = True, show_host_id = True):
|
|
14
14
|
if len(pods) == 0:
|
|
@@ -59,14 +59,22 @@ def show_rollout(sts: str, ns: str):
|
|
|
59
59
|
else:
|
|
60
60
|
log2(f'Cluster has completed rollout {d} ago.')
|
|
61
61
|
|
|
62
|
-
def show_table(state: ReplState, pods: list[str], cols: str, header: str, show_out=False):
|
|
62
|
+
def show_table(state: ReplState, pods: list[str], cols: str, header: str, show_out=False, backgrounded = False):
|
|
63
63
|
columns = Columns.create_columns(cols)
|
|
64
64
|
|
|
65
65
|
results = run_checks(cluster=state.sts, pod=state.pod, namespace=state.namespace, checks=collect_checks(columns), show_out=show_out)
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
r = tabulize(pods, lambda p: ','.join([c.pod_value(results, p) for c in columns]), header=header, separator=',', sorted=SORT, to = 0 if backgrounded else 1)
|
|
68
|
+
|
|
69
|
+
if backgrounded:
|
|
70
|
+
r = write_to_kaqing_log_file(r)
|
|
71
|
+
|
|
72
|
+
IssuesUtils.show(results, state.in_repl)
|
|
73
|
+
|
|
74
|
+
return r
|
|
69
75
|
|
|
70
|
-
|
|
76
|
+
def write_to_kaqing_log_file(r: str):
|
|
77
|
+
with kaqing_log_file() as f:
|
|
78
|
+
f.write(r)
|
|
71
79
|
|
|
72
|
-
|
|
80
|
+
return f.name
|
|
File without changes
|
|
@@ -38,5 +38,5 @@ class GetParam(Command):
|
|
|
38
38
|
def completion(self, _: ReplState):
|
|
39
39
|
return {GetParam.COMMAND: {key: None for key in Config().keys()}}
|
|
40
40
|
|
|
41
|
-
def help(self,
|
|
42
|
-
return
|
|
41
|
+
def help(self, state: ReplState):
|
|
42
|
+
return super().help(state, "shows a Kaqing system parameter's value", args='<key>')
|
|
@@ -36,5 +36,5 @@ class SetParam(Command):
|
|
|
36
36
|
def completion(self, _: ReplState):
|
|
37
37
|
return {SetParam.COMMAND: {key: ({'true': None, 'false': None} if Config().get(key, None) in [True, False] else None) for key in Config().keys()}}
|
|
38
38
|
|
|
39
|
-
def help(self,
|
|
40
|
-
return
|
|
39
|
+
def help(self, state: ReplState):
|
|
40
|
+
return super().help(state, 'sets a Kaqing system parameter to a different value', args='<key> <value>')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from adam.commands.command import Command
|
|
2
2
|
from adam.config import Config
|
|
3
3
|
from adam.repl_state import ReplState
|
|
4
|
-
from adam.utils import tabulize
|
|
4
|
+
from adam.utils import tabulize
|
|
5
5
|
|
|
6
6
|
class ShowParams(Command):
|
|
7
7
|
COMMAND = 'show params'
|
|
@@ -27,5 +27,5 @@ class ShowParams(Command):
|
|
|
27
27
|
def completion(self, state: ReplState):
|
|
28
28
|
return super().completion(state)
|
|
29
29
|
|
|
30
|
-
def help(self,
|
|
31
|
-
return
|
|
30
|
+
def help(self, state: ReplState):
|
|
31
|
+
return super().help(state, 'show Kaqing system parameters')
|
|
@@ -59,8 +59,8 @@ class AlterTables(Command):
|
|
|
59
59
|
return state
|
|
60
60
|
|
|
61
61
|
def completion(self, _: ReplState) -> dict[str, any]:
|
|
62
|
-
# auto completion is taken care of by
|
|
62
|
+
# auto completion is taken care of by lark completer
|
|
63
63
|
return {}
|
|
64
64
|
|
|
65
|
-
def help(self,
|
|
66
|
-
return
|
|
65
|
+
def help(self, state: ReplState) -> str:
|
|
66
|
+
return super().help(state, 'alter schema on all tables', args='with <param=value>,... [--include-reaper]')
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from adam.commands.cql.utils_cql import cassandra_keyspaces, cassandra_table_names
|
|
2
|
+
from adam.commands.export.export_sessions import ExportSessions
|
|
3
|
+
from adam.commands.export.export_databases import ExportDatabases
|
|
4
|
+
from adam.config import Config
|
|
5
|
+
from adam.repl_state import ReplState
|
|
6
|
+
from adam.sql.lark_completer import LarkCompleter
|
|
7
|
+
from adam.utils import log_timing
|
|
8
|
+
from adam.utils_k8s.statefulsets import StatefulSets
|
|
9
|
+
|
|
10
|
+
def completions_c(state: ReplState) -> dict[str, any]:
|
|
11
|
+
ps = Config().get('cql.alter-tables.gc-grace-periods', '3600,86400,864000,7776000').split(',')
|
|
12
|
+
|
|
13
|
+
with log_timing('lark.completions'):
|
|
14
|
+
return LarkCompleter(
|
|
15
|
+
expandables = {
|
|
16
|
+
'tables': lambda x: cassandra_table_names(state),
|
|
17
|
+
'keyspaces': lambda x: cassandra_keyspaces(state.with_no_pod()),
|
|
18
|
+
'table-props': {
|
|
19
|
+
'GC_GRACE_SECONDS': ps
|
|
20
|
+
},
|
|
21
|
+
'table-props-value': lambda x: {None: None, 'GC_GRACE_SECONDS': ps}[x],
|
|
22
|
+
'export-database-types': ['athena', 'sqlite', 'csv'],
|
|
23
|
+
'export-databases': lambda x: ExportDatabases.database_names(),
|
|
24
|
+
'export-sessions': lambda x: ExportSessions.export_session_names(state.sts, state.pod, state.namespace),
|
|
25
|
+
'export-sessions-incomplete': lambda x: ExportSessions.export_session_names(state.sts, state.pod, state.namespace, export_state='pending_import'),
|
|
26
|
+
'hosts': lambda x: [f'@{p}' for p in StatefulSets.pod_names(state.sts, state.namespace)],
|
|
27
|
+
},
|
|
28
|
+
variant=ReplState.C
|
|
29
|
+
).completions_for_nesting()
|