kaqing 2.0.145__py3-none-any.whl → 2.0.174__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/__init__.py +0 -2
- adam/app_session.py +8 -11
- adam/batch.py +3 -3
- adam/checks/check_utils.py +14 -46
- adam/checks/cpu.py +7 -1
- adam/checks/cpu_metrics.py +52 -0
- adam/checks/disk.py +2 -3
- adam/columns/columns.py +3 -1
- adam/columns/cpu.py +3 -1
- adam/columns/cpu_metrics.py +22 -0
- adam/columns/memory.py +3 -4
- adam/commands/__init__.py +22 -0
- adam/commands/alter_tables.py +33 -48
- adam/commands/audit/audit.py +22 -23
- adam/commands/audit/audit_repair_tables.py +14 -17
- adam/commands/audit/audit_run.py +15 -23
- adam/commands/audit/show_last10.py +10 -13
- adam/commands/audit/show_slow10.py +10 -13
- adam/commands/audit/show_top10.py +10 -13
- adam/commands/audit/utils_show_top10.py +2 -3
- adam/commands/bash/__init__.py +5 -0
- adam/commands/bash/bash.py +7 -104
- adam/commands/bash/utils_bash.py +16 -0
- adam/commands/cat.py +7 -23
- adam/commands/cd.py +7 -11
- adam/commands/check.py +14 -23
- adam/commands/cli_commands.py +2 -3
- adam/commands/code.py +20 -23
- adam/commands/command.py +152 -37
- adam/commands/commands_utils.py +8 -17
- adam/commands/cp.py +18 -32
- adam/commands/cql/cql_completions.py +11 -7
- adam/commands/cql/cqlsh.py +10 -30
- adam/commands/cql/{cql_utils.py → utils_cql.py} +147 -15
- adam/commands/deploy/code_start.py +7 -10
- adam/commands/deploy/code_stop.py +4 -21
- adam/commands/deploy/code_utils.py +3 -3
- adam/commands/deploy/deploy.py +4 -27
- adam/commands/deploy/deploy_frontend.py +14 -17
- adam/commands/deploy/deploy_pg_agent.py +2 -5
- adam/commands/deploy/deploy_pod.py +64 -68
- adam/commands/deploy/undeploy.py +4 -27
- adam/commands/deploy/undeploy_frontend.py +4 -7
- adam/commands/deploy/undeploy_pg_agent.py +4 -7
- adam/commands/deploy/undeploy_pod.py +9 -12
- adam/commands/devices/device.py +93 -2
- adam/commands/devices/device_app.py +37 -10
- adam/commands/devices/device_auit_log.py +8 -2
- adam/commands/devices/device_cass.py +47 -7
- adam/commands/devices/device_export.py +9 -11
- adam/commands/devices/device_postgres.py +41 -6
- adam/commands/exit.py +1 -4
- adam/commands/export/clean_up_all_export_sessions.py +37 -0
- adam/commands/export/clean_up_export_sessions.py +12 -8
- adam/commands/export/drop_export_database.py +7 -26
- adam/commands/export/drop_export_databases.py +5 -14
- adam/commands/export/export.py +8 -38
- adam/commands/export/export_databases.py +86 -27
- adam/commands/export/export_select.py +25 -27
- adam/commands/export/export_select_x.py +3 -3
- adam/commands/export/export_sessions.py +124 -0
- adam/commands/export/export_use.py +8 -17
- adam/commands/export/exporter.py +88 -158
- adam/commands/export/import_session.py +7 -35
- adam/commands/export/importer.py +12 -5
- adam/commands/export/importer_athena.py +21 -20
- adam/commands/export/importer_sqlite.py +16 -21
- adam/commands/export/show_column_counts.py +7 -25
- adam/commands/export/show_export_databases.py +4 -6
- adam/commands/export/show_export_session.py +7 -18
- adam/commands/export/show_export_sessions.py +9 -12
- adam/commands/export/utils_export.py +26 -1
- adam/commands/intermediate_command.py +49 -0
- adam/commands/issues.py +11 -43
- adam/commands/kubectl.py +3 -6
- adam/commands/login.py +22 -24
- adam/commands/logs.py +3 -6
- adam/commands/ls.py +8 -9
- adam/commands/medusa/medusa.py +4 -22
- adam/commands/medusa/medusa_backup.py +20 -25
- adam/commands/medusa/medusa_restore.py +34 -36
- adam/commands/medusa/medusa_show_backupjobs.py +14 -18
- adam/commands/medusa/medusa_show_restorejobs.py +11 -18
- adam/commands/nodetool.py +6 -15
- adam/commands/param_get.py +11 -13
- adam/commands/param_set.py +8 -12
- adam/commands/postgres/postgres.py +22 -38
- adam/commands/postgres/postgres_context.py +47 -23
- adam/commands/postgres/postgres_ls.py +4 -8
- adam/commands/postgres/postgres_preview.py +5 -9
- adam/commands/postgres/psql_completions.py +1 -1
- adam/commands/postgres/utils_postgres.py +70 -0
- adam/commands/preview_table.py +6 -45
- adam/commands/pwd.py +13 -16
- adam/commands/reaper/reaper.py +4 -27
- adam/commands/reaper/reaper_forward.py +48 -55
- adam/commands/reaper/reaper_forward_session.py +6 -0
- adam/commands/reaper/reaper_forward_stop.py +10 -16
- adam/commands/reaper/reaper_restart.py +7 -14
- adam/commands/reaper/reaper_run_abort.py +8 -33
- adam/commands/reaper/reaper_runs.py +42 -57
- adam/commands/reaper/reaper_runs_abort.py +29 -49
- adam/commands/reaper/reaper_schedule_activate.py +9 -32
- adam/commands/reaper/reaper_schedule_start.py +9 -32
- adam/commands/reaper/reaper_schedule_stop.py +9 -32
- adam/commands/reaper/reaper_schedules.py +4 -14
- adam/commands/reaper/reaper_status.py +8 -16
- adam/commands/reaper/utils_reaper.py +196 -0
- adam/commands/repair/repair.py +4 -22
- adam/commands/repair/repair_log.py +5 -11
- adam/commands/repair/repair_run.py +27 -34
- adam/commands/repair/repair_scan.py +32 -38
- adam/commands/repair/repair_stop.py +5 -11
- adam/commands/report.py +27 -29
- adam/commands/restart.py +25 -26
- adam/commands/rollout.py +19 -24
- adam/commands/shell.py +10 -4
- adam/commands/show/show.py +10 -26
- adam/commands/show/show_cassandra_repairs.py +35 -0
- adam/commands/show/show_cassandra_status.py +32 -43
- adam/commands/show/show_cassandra_version.py +5 -18
- adam/commands/show/show_commands.py +19 -24
- adam/commands/show/show_host.py +1 -1
- adam/commands/show/show_login.py +20 -27
- adam/commands/show/show_processes.py +15 -19
- adam/commands/show/show_storage.py +10 -20
- adam/commands/watch.py +26 -29
- adam/config.py +4 -16
- adam/embedded_params.py +1 -1
- adam/log.py +4 -4
- adam/pod_exec_result.py +3 -3
- adam/repl.py +31 -32
- adam/repl_commands.py +11 -11
- adam/repl_state.py +52 -26
- adam/sql/sql_completer.py +4 -6
- adam/sql/sql_state_machine.py +21 -14
- adam/sso/authn_ad.py +6 -8
- adam/sso/authn_okta.py +4 -6
- adam/sso/cred_cache.py +3 -5
- adam/sso/idp.py +9 -12
- adam/utils.py +393 -33
- adam/utils_athena.py +14 -13
- adam/utils_audits.py +12 -12
- adam/utils_issues.py +32 -0
- adam/utils_k8s/app_clusters.py +13 -18
- adam/utils_k8s/app_pods.py +2 -0
- adam/utils_k8s/cassandra_clusters.py +21 -18
- adam/utils_k8s/custom_resources.py +16 -17
- adam/utils_k8s/ingresses.py +2 -2
- adam/utils_k8s/jobs.py +7 -11
- adam/utils_k8s/k8s.py +87 -0
- adam/utils_k8s/pods.py +14 -76
- adam/utils_k8s/secrets.py +4 -4
- adam/utils_k8s/service_accounts.py +5 -4
- adam/utils_k8s/services.py +2 -2
- adam/utils_k8s/statefulsets.py +1 -12
- adam/utils_repl/state_machine.py +3 -3
- adam/utils_sqlite.py +78 -42
- adam/version.py +1 -1
- {kaqing-2.0.145.dist-info → kaqing-2.0.174.dist-info}/METADATA +1 -1
- kaqing-2.0.174.dist-info/RECORD +230 -0
- adam/commands/app.py +0 -67
- adam/commands/app_ping.py +0 -44
- adam/commands/export/clean_up_export_session.py +0 -53
- adam/commands/postgres/postgres_utils.py +0 -31
- adam/commands/reaper/reaper_session.py +0 -159
- adam/commands/show/show_app_actions.py +0 -56
- adam/commands/show/show_app_id.py +0 -47
- adam/commands/show/show_app_queues.py +0 -45
- adam/commands/show/show_repairs.py +0 -47
- kaqing-2.0.145.dist-info/RECORD +0 -227
- {kaqing-2.0.145.dist-info → kaqing-2.0.174.dist-info}/WHEEL +0 -0
- {kaqing-2.0.145.dist-info → kaqing-2.0.174.dist-info}/entry_points.txt +0 -0
- {kaqing-2.0.145.dist-info → kaqing-2.0.174.dist-info}/top_level.txt +0 -0
adam/commands/shell.py
CHANGED
|
@@ -2,6 +2,7 @@ import os
|
|
|
2
2
|
|
|
3
3
|
from adam.commands.command import Command
|
|
4
4
|
from adam.repl_state import ReplState
|
|
5
|
+
from adam.utils import log2
|
|
5
6
|
|
|
6
7
|
class Shell(Command):
|
|
7
8
|
COMMAND = ':sh'
|
|
@@ -18,13 +19,18 @@ class Shell(Command):
|
|
|
18
19
|
def command(self):
|
|
19
20
|
return Shell.COMMAND
|
|
20
21
|
|
|
21
|
-
def run(self, cmd: str,
|
|
22
|
+
def run(self, cmd: str, state: ReplState):
|
|
22
23
|
if not(args := self.args(cmd)):
|
|
23
|
-
return super().run(cmd,
|
|
24
|
+
return super().run(cmd, state)
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
with self.validate(args, state) as (args, _):
|
|
27
|
+
if args:
|
|
28
|
+
os.system(' '.join(args))
|
|
29
|
+
log2()
|
|
30
|
+
else:
|
|
31
|
+
os.system('QING_DROPPED=true bash')
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
return state
|
|
28
34
|
|
|
29
35
|
def completion(self, state: ReplState):
|
|
30
36
|
return super().completion(state)
|
adam/commands/show/show.py
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
|
-
from adam.commands.
|
|
4
|
-
from adam.commands.
|
|
5
|
-
from adam.commands.
|
|
3
|
+
from adam.commands.app.show_app_actions import ShowAppActions
|
|
4
|
+
from adam.commands.app.show_app_id import ShowAppId
|
|
5
|
+
from adam.commands.app.show_app_queues import ShowAppQueues
|
|
6
|
+
from adam.commands.intermediate_command import IntermediateCommand
|
|
6
7
|
from adam.commands.medusa.medusa_show_backupjobs import MedusaShowBackupJobs
|
|
7
8
|
from adam.commands.medusa.medusa_show_restorejobs import MedusaShowRestoreJobs
|
|
8
|
-
from adam.commands.show.show_app_actions import ShowAppActions
|
|
9
|
-
from adam.commands.show.show_app_queues import ShowAppQueues
|
|
10
9
|
from adam.commands.show.show_host import ShowHost
|
|
11
10
|
from adam.commands.show.show_login import ShowLogin
|
|
12
11
|
from .show_params import ShowParams
|
|
13
|
-
from .show_app_id import ShowAppId
|
|
14
12
|
from .show_cassandra_status import ShowCassandraStatus
|
|
15
13
|
from .show_cassandra_version import ShowCassandraVersion
|
|
16
14
|
from .show_commands import ShowKubectlCommands
|
|
17
15
|
from .show_processes import ShowProcesses
|
|
18
|
-
from .
|
|
16
|
+
from .show_cassandra_repairs import ShowCassandraRepairs
|
|
19
17
|
from .show_storage import ShowStorage
|
|
20
18
|
from .show_adam import ShowAdam
|
|
21
|
-
from adam.repl_state import ReplState
|
|
22
19
|
|
|
23
|
-
class Show(
|
|
20
|
+
class Show(IntermediateCommand):
|
|
24
21
|
COMMAND = 'show'
|
|
25
22
|
|
|
26
23
|
# the singleton pattern
|
|
@@ -29,27 +26,14 @@ class Show(Command):
|
|
|
29
26
|
|
|
30
27
|
return cls.instance
|
|
31
28
|
|
|
32
|
-
def __init__(self, successor: Command=None):
|
|
33
|
-
super().__init__(successor)
|
|
34
|
-
|
|
35
29
|
def command(self):
|
|
36
30
|
return Show.COMMAND
|
|
37
31
|
|
|
38
|
-
def
|
|
39
|
-
if not(args := self.args(cmd)):
|
|
40
|
-
return super().run(cmd, state)
|
|
41
|
-
|
|
42
|
-
return super().intermediate_run(cmd, state, args, Show.cmd_list())
|
|
43
|
-
|
|
44
|
-
def cmd_list():
|
|
32
|
+
def cmd_list(self):
|
|
45
33
|
return [ShowAppActions(), ShowAppId(), ShowAppQueues(), ShowHost(), ShowLogin(), ShowKubectlCommands(),
|
|
46
|
-
ShowParams(), ShowProcesses(),
|
|
47
|
-
ShowCassandraStatus(), ShowCassandraVersion(), MedusaShowRestoreJobs(), MedusaShowBackupJobs()
|
|
48
|
-
ShowLast10()]
|
|
49
|
-
|
|
50
|
-
def completion(self, state: ReplState):
|
|
51
|
-
return super().completion(state)
|
|
34
|
+
ShowParams(), ShowProcesses(), ShowCassandraRepairs(), ShowStorage(), ShowAdam(),
|
|
35
|
+
ShowCassandraStatus(), ShowCassandraVersion(), MedusaShowRestoreJobs(), MedusaShowBackupJobs()]
|
|
52
36
|
|
|
53
37
|
class ShowCommandHelper(click.Command):
|
|
54
38
|
def get_help(self, ctx: click.Context):
|
|
55
|
-
|
|
39
|
+
IntermediateCommand.intermediate_help(super().get_help(ctx), Show.COMMAND, Show().cmd_list(), show_cluster_help=True)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from adam.commands.command import Command
|
|
2
|
+
from adam.commands.cql.utils_cql import cassandra
|
|
3
|
+
from adam.repl_state import ReplState, RequiredState
|
|
4
|
+
|
|
5
|
+
class ShowCassandraRepairs(Command):
|
|
6
|
+
COMMAND = 'show cassandra repairs'
|
|
7
|
+
|
|
8
|
+
# the singleton pattern
|
|
9
|
+
def __new__(cls, *args, **kwargs):
|
|
10
|
+
if not hasattr(cls, 'instance'): cls.instance = super(ShowCassandraRepairs, cls).__new__(cls)
|
|
11
|
+
|
|
12
|
+
return cls.instance
|
|
13
|
+
|
|
14
|
+
def __init__(self, successor: Command=None):
|
|
15
|
+
super().__init__(successor)
|
|
16
|
+
|
|
17
|
+
def command(self):
|
|
18
|
+
return ShowCassandraRepairs.COMMAND
|
|
19
|
+
|
|
20
|
+
def required(self):
|
|
21
|
+
return RequiredState.CLUSTER_OR_POD
|
|
22
|
+
|
|
23
|
+
def run(self, cmd: str, state: ReplState):
|
|
24
|
+
if not(args := self.args(cmd)):
|
|
25
|
+
return super().run(cmd, state)
|
|
26
|
+
|
|
27
|
+
with self.validate(args, state) as (args, state):
|
|
28
|
+
with cassandra(state) as pods:
|
|
29
|
+
return pods.nodetool('repair_admin list')
|
|
30
|
+
|
|
31
|
+
def completion(self, state: ReplState):
|
|
32
|
+
return super().completion(state)
|
|
33
|
+
|
|
34
|
+
def help(self, _: ReplState):
|
|
35
|
+
return f'{ShowCassandraRepairs.COMMAND}\t show Cassandra repairs'
|
|
@@ -5,14 +5,14 @@ from adam.checks.check_utils import run_checks
|
|
|
5
5
|
from adam.checks.compactionstats import CompactionStats
|
|
6
6
|
from adam.checks.gossip import Gossip
|
|
7
7
|
from adam.columns.columns import Columns
|
|
8
|
+
from adam.commands import extract_options
|
|
8
9
|
from adam.commands.command import Command
|
|
9
|
-
from adam.commands.
|
|
10
|
+
from adam.commands.cql.utils_cql import cassandra
|
|
10
11
|
from adam.config import Config
|
|
11
|
-
from adam.
|
|
12
|
-
from adam.utils_k8s.secrets import Secrets
|
|
12
|
+
from adam.utils_issues import IssuesUtils
|
|
13
13
|
from adam.utils_k8s.statefulsets import StatefulSets
|
|
14
14
|
from adam.repl_state import ReplState, RequiredState
|
|
15
|
-
from adam.utils import lines_to_tabular, log, log2
|
|
15
|
+
from adam.utils import lines_to_tabular, log, log2, log_exc
|
|
16
16
|
from adam.checks.status import parse_nodetool_status
|
|
17
17
|
|
|
18
18
|
class ShowCassandraStatus(Command):
|
|
@@ -37,50 +37,42 @@ class ShowCassandraStatus(Command):
|
|
|
37
37
|
if not(args := self.args(cmd)):
|
|
38
38
|
return super().run(cmd, state)
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
with self.validate(args, state) as (args, state):
|
|
41
|
+
with extract_options(args, ['-s', '--show']) as (args, show_out):
|
|
42
|
+
if state.namespace and state.pod:
|
|
43
|
+
self.show_single_pod(state, show_out=show_out)
|
|
44
|
+
elif state.namespace and state.sts:
|
|
45
|
+
self.merge(state, Config().get('nodetool.samples', sys.maxsize), show_output=show_out)
|
|
43
46
|
|
|
44
|
-
|
|
47
|
+
return state
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def show_single_pod(self, statefulset: str, pod_name: str, ns: str, show_output = False):
|
|
55
|
-
pod_name = pod_name.split('(')[0]
|
|
56
|
-
user, pw = Secrets.get_user_pass(pod_name, ns)
|
|
57
|
-
try:
|
|
58
|
-
result = CassandraNodes.exec(pod_name, ns, f"nodetool -u {user} -pw {pw} status", show_out=False)
|
|
59
|
-
status = parse_nodetool_status(result.stdout)
|
|
60
|
-
check_results = run_checks(cluster=statefulset, namespace=ns, checks=[CompactionStats(), Gossip()], show_output=show_output)
|
|
61
|
-
self.show_table(status, check_results)
|
|
62
|
-
except Exception as e:
|
|
63
|
-
log2(e)
|
|
49
|
+
def show_single_pod(self, state: ReplState, show_out = False):
|
|
50
|
+
with log_exc(True):
|
|
51
|
+
with cassandra(state) as pods:
|
|
52
|
+
result = pods.nodetool('status', show_out=False)
|
|
53
|
+
status = parse_nodetool_status(result.stdout)
|
|
54
|
+
check_results = run_checks(cluster=state.sts, namespace=state.namespace, checks=[CompactionStats(), Gossip()], show_out=show_out)
|
|
55
|
+
self.show_table(status, check_results)
|
|
64
56
|
|
|
65
|
-
def merge(self,
|
|
57
|
+
def merge(self, state: ReplState, samples: int, show_output=False):
|
|
66
58
|
statuses: list[list[dict]] = []
|
|
59
|
+
|
|
60
|
+
pod_names = StatefulSets.pod_names(state.sts, state.namespace)
|
|
67
61
|
for pod_name in pod_names:
|
|
68
62
|
pod_name = pod_name.split('(')[0]
|
|
69
|
-
user, pw = Secrets.get_user_pass(pod_name, ns)
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
log2(e)
|
|
64
|
+
with log_exc(True):
|
|
65
|
+
with cassandra(state, pod=pod_name) as pods:
|
|
66
|
+
result = pods.nodetool('status', show_out=False)
|
|
67
|
+
status = parse_nodetool_status(result.stdout)
|
|
68
|
+
if status:
|
|
69
|
+
statuses.append(status)
|
|
70
|
+
if samples <= len(statuses) and len(pod_names) != len(statuses):
|
|
71
|
+
break
|
|
80
72
|
|
|
81
73
|
combined_status = self.merge_status(statuses)
|
|
82
74
|
log2(f'Showing merged status from {len(statuses)}/{len(pod_names)} nodes...')
|
|
83
|
-
check_results = run_checks(cluster=
|
|
75
|
+
check_results = run_checks(cluster=state.sts, namespace=state.namespace, checks=[CompactionStats(), Gossip()], show_out=show_output)
|
|
84
76
|
self.show_table(combined_status, check_results)
|
|
85
77
|
|
|
86
78
|
return combined_status
|
|
@@ -116,13 +108,10 @@ class ShowCassandraStatus(Command):
|
|
|
116
108
|
|
|
117
109
|
log(lines_to_tabular(lines, header, separator=','))
|
|
118
110
|
|
|
119
|
-
|
|
111
|
+
IssuesUtils.show(check_results)
|
|
120
112
|
|
|
121
113
|
def completion(self, state: ReplState):
|
|
122
|
-
|
|
123
|
-
return super().completion(state)
|
|
124
|
-
|
|
125
|
-
return {}
|
|
114
|
+
return super().completion(state, {'-s': None})
|
|
126
115
|
|
|
127
116
|
def help(self, _: ReplState):
|
|
128
117
|
return f'{ShowCassandraStatus.COMMAND} [-s]\t show merged nodetool status -s show commands on nodes'
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
from adam.commands.command import Command
|
|
2
|
-
from adam.
|
|
3
|
-
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
4
|
-
from adam.utils_k8s.secrets import Secrets
|
|
2
|
+
from adam.commands.cql.utils_cql import cassandra
|
|
5
3
|
from adam.repl_state import ReplState, RequiredState
|
|
6
4
|
|
|
7
5
|
class ShowCassandraVersion(Command):
|
|
@@ -26,23 +24,12 @@ class ShowCassandraVersion(Command):
|
|
|
26
24
|
if not(args := self.args(cmd)):
|
|
27
25
|
return super().run(cmd, state)
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
user, pw = Secrets.get_user_pass(state.sts if state.sts else state.pod, state.namespace, secret_path='cql.secret')
|
|
34
|
-
command = f'cqlsh -u {user} -p {pw} -e "show version"'
|
|
35
|
-
|
|
36
|
-
if state.pod:
|
|
37
|
-
return CassandraNodes.exec(state.pod, state.namespace, command)
|
|
38
|
-
else:
|
|
39
|
-
return CassandraClusters.exec(state.sts, state.namespace, command, action='cql')
|
|
27
|
+
with self.validate(args, state) as (_, state):
|
|
28
|
+
with cassandra(state) as pods:
|
|
29
|
+
return pods.cql('show version', show_out=True, on_any=True)
|
|
40
30
|
|
|
41
31
|
def completion(self, state: ReplState):
|
|
42
|
-
|
|
43
|
-
return super().completion(state)
|
|
44
|
-
|
|
45
|
-
return {}
|
|
32
|
+
return super().completion(state)
|
|
46
33
|
|
|
47
34
|
def help(self, _: ReplState):
|
|
48
35
|
return f'{ShowCassandraVersion.COMMAND}\t show Cassandra version'
|
|
@@ -25,36 +25,31 @@ class ShowKubectlCommands(Command):
|
|
|
25
25
|
if not self.args(cmd):
|
|
26
26
|
return super().run(cmd, state)
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
f'nodetool,{v["nodetool-?"]}',
|
|
36
|
-
f'cql,{v["cql-?"]}',
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
if 'reaper-exec' in v:
|
|
40
|
-
cmds += [
|
|
41
|
-
f'reaper,{v["reaper-exec"]}',
|
|
42
|
-
f',{v["reaper-forward"]} * should be run from your laptop',
|
|
43
|
-
f',{v["reaper-ui"]}',
|
|
44
|
-
f',{v["reaper-username"]}',
|
|
45
|
-
f',{v["reaper-password"]}',
|
|
28
|
+
with self.validate(args, state) as (args, state):
|
|
29
|
+
v = CliCommands.values(state, collapse=True)
|
|
30
|
+
# node-exec-?, nodetool-?, cql-?, reaper-exec, reaper-forward, reaper-ui, reaper-username, reaper-password
|
|
31
|
+
cmds = [
|
|
32
|
+
f'bash,{v["node-exec-?"]}',
|
|
33
|
+
f'nodetool,{v["nodetool-?"]}',
|
|
34
|
+
f'cql,{v["cql-?"]}',
|
|
46
35
|
]
|
|
47
36
|
|
|
48
|
-
|
|
37
|
+
if 'reaper-exec' in v:
|
|
38
|
+
cmds += [
|
|
39
|
+
f'reaper,{v["reaper-exec"]}',
|
|
40
|
+
f',{v["reaper-forward"]} * should be run from your laptop',
|
|
41
|
+
f',{v["reaper-ui"]}',
|
|
42
|
+
f',{v["reaper-username"]}',
|
|
43
|
+
f',{v["reaper-password"]}',
|
|
44
|
+
]
|
|
49
45
|
|
|
50
|
-
|
|
46
|
+
cmds += [f'{k},{v0}' for k, v0 in v.items() if k.startswith('pg-')]
|
|
51
47
|
|
|
52
|
-
|
|
48
|
+
log(lines_to_tabular(cmds, separator=','))
|
|
53
49
|
|
|
54
|
-
|
|
55
|
-
if not state.sts:
|
|
56
|
-
return {}
|
|
50
|
+
return cmds
|
|
57
51
|
|
|
52
|
+
def completion(self, state: ReplState):
|
|
58
53
|
return super().completion(state)
|
|
59
54
|
|
|
60
55
|
def help(self, _: ReplState):
|
adam/commands/show/show_host.py
CHANGED
adam/commands/show/show_login.py
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import time
|
|
2
|
-
import traceback
|
|
3
2
|
|
|
4
3
|
from adam.apps import Apps
|
|
5
|
-
from adam.config import Config
|
|
6
4
|
from adam.sso.idp import Idp
|
|
7
5
|
from adam.sso.idp_login import IdpLogin
|
|
8
6
|
from adam.commands.command import Command
|
|
9
7
|
from adam.repl_state import ReplState
|
|
10
|
-
from adam.utils import duration, lines_to_tabular, log, log2
|
|
8
|
+
from adam.utils import duration, lines_to_tabular, log, log2, log_exc
|
|
11
9
|
|
|
12
10
|
class ShowLogin(Command):
|
|
13
11
|
COMMAND = 'show login'
|
|
@@ -31,30 +29,25 @@ class ShowLogin(Command):
|
|
|
31
29
|
if not(args := self.args(cmd)):
|
|
32
30
|
return super().run(cmd, state)
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
log2(e)
|
|
54
|
-
if Config().is_debug():
|
|
55
|
-
log2(traceback.format_exc())
|
|
56
|
-
|
|
57
|
-
return state
|
|
32
|
+
with self.validate(args, state) as (args, state):
|
|
33
|
+
login: IdpLogin = None
|
|
34
|
+
with log_exc(True):
|
|
35
|
+
if not(host := Apps.app_host('c3', 'c3', state.namespace)):
|
|
36
|
+
log2('Cannot locate ingress for app.')
|
|
37
|
+
return state
|
|
38
|
+
|
|
39
|
+
login = Idp.login(host, use_token_from_env=True)
|
|
40
|
+
if login and login.id_token_obj:
|
|
41
|
+
it = login.id_token_obj
|
|
42
|
+
lines = [
|
|
43
|
+
f'email\t{it.email}',
|
|
44
|
+
f'user\t{it.username}',
|
|
45
|
+
f'IDP expires in\t{duration(time.time(), it.exp)}',
|
|
46
|
+
f'IDP Groups\t{",".join(it.groups)}'
|
|
47
|
+
]
|
|
48
|
+
log(lines_to_tabular(lines, separator='\t'))
|
|
49
|
+
|
|
50
|
+
return state
|
|
58
51
|
|
|
59
52
|
def completion(self, state: ReplState):
|
|
60
53
|
return super().completion(state)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
from adam.commands import extract_options, extract_sequence
|
|
1
2
|
from adam.commands.command import Command
|
|
2
3
|
from adam.commands.commands_utils import show_table
|
|
4
|
+
from adam.commands.cql.utils_cql import cassandra
|
|
3
5
|
from adam.config import Config
|
|
4
6
|
from adam.utils_k8s.statefulsets import StatefulSets
|
|
5
7
|
from adam.repl_state import ReplState, RequiredState
|
|
@@ -26,28 +28,22 @@ class ShowProcesses(Command):
|
|
|
26
28
|
if not(args := self.args(cmd)):
|
|
27
29
|
return super().run(cmd, state)
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
with self.validate(args, state) as (args, state):
|
|
32
|
+
with extract_options(args, ['-s', '--show']) as (args, show_out):
|
|
33
|
+
with extract_sequence(args, ['with', 'recipe', '=', 'qing']) as (_, recipe_qing):
|
|
34
|
+
cols = Config().get('processes.columns', 'pod,cpu-metrics,mem')
|
|
35
|
+
header = Config().get('processes.header', 'POD_NAME,M_CPU(USAGE/LIMIT),MEM/LIMIT')
|
|
36
|
+
if recipe_qing:
|
|
37
|
+
cols = Config().get('processes-qing.columns', 'pod,cpu,mem')
|
|
38
|
+
header = Config().get('processes-qing.header', 'POD_NAME,Q_CPU/TOTAL,MEM/LIMIT')
|
|
32
39
|
|
|
33
|
-
|
|
40
|
+
with cassandra(state) as pods:
|
|
41
|
+
pods.display_table(cols, header, show_out=show_out)
|
|
34
42
|
|
|
35
|
-
|
|
36
|
-
header = Config().get('processes.header', 'POD_NAME,CPU,MEM/LIMIT')
|
|
37
|
-
|
|
38
|
-
if state.pod:
|
|
39
|
-
show_table(state, [state.pod], cols, header, show_output=show_output)
|
|
40
|
-
elif state.sts:
|
|
41
|
-
pod_names = [pod.metadata.name for pod in StatefulSets.pods(state.sts, state.namespace)]
|
|
42
|
-
show_table(state, pod_names, cols, header, show_output=show_output)
|
|
43
|
-
|
|
44
|
-
return state
|
|
43
|
+
return state
|
|
45
44
|
|
|
46
45
|
def completion(self, state: ReplState):
|
|
47
|
-
|
|
48
|
-
return {}
|
|
49
|
-
|
|
50
|
-
return super().completion(state)
|
|
46
|
+
return super().completion(state, {'with': {'recipe': {'=': {'metrics': {'-s': None}, 'qing': {'-s': None}}}}, '-s': None})
|
|
51
47
|
|
|
52
48
|
def help(self, _: ReplState):
|
|
53
|
-
return f'{ShowProcesses.COMMAND} [-s]\t show process overview -s show commands on nodes'
|
|
49
|
+
return f'{ShowProcesses.COMMAND} [with recipe qing|metrics] [-s]\t show process overview -s show commands on nodes'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
from adam.commands import extract_options
|
|
1
2
|
from adam.commands.command import Command
|
|
2
|
-
from adam.commands.
|
|
3
|
+
from adam.commands.cql.utils_cql import cassandra
|
|
3
4
|
from adam.config import Config
|
|
4
|
-
from adam.utils_k8s.statefulsets import StatefulSets
|
|
5
5
|
from adam.repl_state import ReplState, RequiredState
|
|
6
6
|
|
|
7
7
|
class ShowStorage(Command):
|
|
@@ -26,27 +26,17 @@ class ShowStorage(Command):
|
|
|
26
26
|
if not(args := self.args(cmd)):
|
|
27
27
|
return super().run(cmd, state)
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
with self.validate(args, state) as (args, state):
|
|
30
|
+
with extract_options(args, ['-s', '--show']) as (args, show_out):
|
|
31
|
+
cols = Config().get('storage.columns', 'pod,volume_root,volume_cassandra,snapshots,data,compactions')
|
|
32
|
+
header = Config().get('storage.header', 'POD_NAME,VOLUME /,VOLUME CASS,SNAPSHOTS,DATA,COMPACTIONS')
|
|
33
|
+
with cassandra(state) as pods:
|
|
34
|
+
pods.display_table(cols, header, show_out=show_out)
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
cols = Config().get('storage.columns', 'pod,volume_root,volume_cassandra,snapshots,data,compactions')
|
|
36
|
-
header = Config().get('storage.header', 'POD_NAME,VOLUME /,VOLUME CASS,SNAPSHOTS,DATA,COMPACTIONS')
|
|
37
|
-
if state.pod:
|
|
38
|
-
show_table(state, [state.pod], cols, header, show_output=show_output)
|
|
39
|
-
elif state.sts:
|
|
40
|
-
pod_names = [pod.metadata.name for pod in StatefulSets.pods(state.sts, state.namespace)]
|
|
41
|
-
show_table(state, pod_names, cols, header, show_output=show_output)
|
|
42
|
-
|
|
43
|
-
return state
|
|
36
|
+
return state
|
|
44
37
|
|
|
45
38
|
def completion(self, state: ReplState):
|
|
46
|
-
|
|
47
|
-
return {}
|
|
48
|
-
|
|
49
|
-
return super().completion(state)
|
|
39
|
+
return super().completion(state, {'-s': None})
|
|
50
40
|
|
|
51
41
|
def help(self, _: ReplState):
|
|
52
42
|
return f'{ShowStorage.COMMAND} [-s]\t show storage overview -s show commands on nodes'
|
adam/commands/watch.py
CHANGED
|
@@ -8,10 +8,10 @@ from adam.commands.commands_utils import show_pods, show_rollout
|
|
|
8
8
|
from adam.config import Config
|
|
9
9
|
from adam.utils_k8s.statefulsets import StatefulSets
|
|
10
10
|
from adam.repl_state import ReplState, RequiredState
|
|
11
|
-
from adam.utils import
|
|
11
|
+
from adam.utils import log2
|
|
12
12
|
|
|
13
13
|
class Watch(Command):
|
|
14
|
-
COMMAND = 'watch'
|
|
14
|
+
COMMAND = 'watch cassandra pods'
|
|
15
15
|
|
|
16
16
|
# the singleton pattern
|
|
17
17
|
def __new__(cls, *args, **kwargs):
|
|
@@ -26,37 +26,34 @@ class Watch(Command):
|
|
|
26
26
|
return Watch.COMMAND
|
|
27
27
|
|
|
28
28
|
def required(self):
|
|
29
|
-
return RequiredState.
|
|
29
|
+
return RequiredState.NAMESPACE
|
|
30
30
|
|
|
31
31
|
def run(self, cmd: str, state: ReplState):
|
|
32
32
|
if not(args := self.args(cmd)):
|
|
33
33
|
return super().run(cmd, state)
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if not pods:
|
|
41
|
-
log2("No pods are found.")
|
|
42
|
-
return state
|
|
35
|
+
with self.validate(args, state) as (args, state):
|
|
36
|
+
pods = StatefulSets.pods(state.sts, state.namespace)
|
|
37
|
+
if not pods:
|
|
38
|
+
log2("No pods are found.")
|
|
39
|
+
return state
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
stop_event = threading.Event()
|
|
42
|
+
thread = threading.Thread(target=self.loop, args=(stop_event, state.sts, pods, state.namespace), daemon=True)
|
|
43
|
+
thread.start()
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
try:
|
|
46
|
+
log2(f"Press Ctrl+C to break.")
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
time.sleep(Config().get('watch.timeout', 3600 * 1))
|
|
49
|
+
except KeyboardInterrupt:
|
|
50
|
+
pass
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
log2("Stopping watch...")
|
|
53
|
+
stop_event.set()
|
|
54
|
+
thread.join()
|
|
58
55
|
|
|
59
|
-
|
|
56
|
+
return state
|
|
60
57
|
|
|
61
58
|
def loop(self, stop_flag: threading.Event, sts: str, pods: List[client.V1Pod], ns: str):
|
|
62
59
|
show_pods(pods, ns)
|
|
@@ -73,13 +70,13 @@ class Watch(Command):
|
|
|
73
70
|
cnt = Config().get('watch.interval', 10)
|
|
74
71
|
|
|
75
72
|
def completion(self, state: ReplState):
|
|
76
|
-
if state
|
|
77
|
-
|
|
73
|
+
if sc := super().completion(state):
|
|
74
|
+
if state.sts:
|
|
75
|
+
return sc
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
return {Watch.COMMAND: {n: None for n in StatefulSets.list_sts_names()}}
|
|
77
|
+
return super().completion(state, {n: None for n in StatefulSets.list_sts_names()})
|
|
81
78
|
|
|
82
|
-
return {
|
|
79
|
+
return {}
|
|
83
80
|
|
|
84
81
|
def help(self, _: ReplState):
|
|
85
|
-
return f'{Watch.COMMAND}\t watch pod changes'
|
|
82
|
+
return f'{Watch.COMMAND}\t watch Cassandra pod changes'
|
adam/config.py
CHANGED
|
@@ -3,15 +3,15 @@ from typing import TypeVar, cast
|
|
|
3
3
|
import yaml
|
|
4
4
|
|
|
5
5
|
from . import __version__
|
|
6
|
-
from adam.utils import copy_config_file, get_deep_keys, log2
|
|
6
|
+
from adam.utils import LogConfig, copy_config_file, get_deep_keys, log2
|
|
7
7
|
|
|
8
8
|
T = TypeVar('T')
|
|
9
9
|
|
|
10
10
|
class Config:
|
|
11
11
|
EMBEDDED_PARAMS = {}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
LogConfig.is_debug = lambda: Config().is_debug()
|
|
14
|
+
LogConfig.is_debug_timing = lambda: Config().get('debugs.timings', False)
|
|
15
15
|
|
|
16
16
|
# the singleton pattern
|
|
17
17
|
def __new__(cls, *args, **kwargs):
|
|
@@ -44,10 +44,6 @@ class Config:
|
|
|
44
44
|
def is_debug(self):
|
|
45
45
|
return os.getenv('QING_DEV', 'false').lower() == 'true' or Config().get('debug', False)
|
|
46
46
|
|
|
47
|
-
def debug(self, s: None):
|
|
48
|
-
if self.is_debug():
|
|
49
|
-
log2(f'DEBUG {s}')
|
|
50
|
-
|
|
51
47
|
def get(self, key: str, default: T) -> T:
|
|
52
48
|
# params['nodetool']['status']['max-nodes']
|
|
53
49
|
d = self.params
|
|
@@ -88,12 +84,4 @@ class Config:
|
|
|
88
84
|
log2(f'incorrect path: {key}')
|
|
89
85
|
return None
|
|
90
86
|
|
|
91
|
-
return v if v else 'false'
|
|
92
|
-
|
|
93
|
-
def wait_log(self, msg: str):
|
|
94
|
-
if hasattr(self, 'wait_log_flag') and not self.wait_log_flag:
|
|
95
|
-
log2(msg)
|
|
96
|
-
self.wait_log_flag = True
|
|
97
|
-
|
|
98
|
-
def clear_wait_log_flag(self):
|
|
99
|
-
self.wait_log_flag = False
|
|
87
|
+
return v if v else 'false'
|