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
adam/app_session.py
CHANGED
|
@@ -8,7 +8,7 @@ from adam.log import Log
|
|
|
8
8
|
from adam.sso.idp import Idp
|
|
9
9
|
from adam.sso.idp_login import IdpLogin
|
|
10
10
|
from adam.config import Config
|
|
11
|
-
from adam.utils import debug, debug_trace, json_to_csv, tabulize,
|
|
11
|
+
from adam.utils import debug, debug_trace, json_to_csv, tabulize, log2, log_exc
|
|
12
12
|
from adam.apps import Apps
|
|
13
13
|
|
|
14
14
|
class AppLogin:
|
adam/batch.py
CHANGED
|
@@ -2,28 +2,28 @@ import click
|
|
|
2
2
|
|
|
3
3
|
from adam.commands.audit.audit import Audit, AuditCommandHelper
|
|
4
4
|
from adam.commands.bash.bash import Bash
|
|
5
|
-
from adam.commands.
|
|
6
|
-
from adam.commands.
|
|
5
|
+
from adam.commands.cassandra.restart_nodes import RestartNodes
|
|
6
|
+
from adam.commands.cassandra.rollout import RollOut
|
|
7
|
+
from adam.commands.cassandra.watch import Watch
|
|
8
|
+
from adam.commands.cli.clipboard_copy import ClipboardCopy, CopyCommandHelper
|
|
7
9
|
from adam.commands.command import Command
|
|
8
10
|
from adam.commands.command_helpers import ClusterCommandHelper, ClusterOrPodCommandHelper, PodCommandHelper
|
|
9
11
|
from adam.commands.cql.cqlsh import CqlCommandHelper, Cqlsh
|
|
10
12
|
from adam.commands.deploy.deploy import Deploy, DeployCommandHelper
|
|
11
13
|
from adam.commands.deploy.undeploy import Undeploy, UndeployCommandHelper
|
|
12
|
-
from adam.commands.
|
|
13
|
-
from adam.commands.
|
|
14
|
-
from adam.commands.
|
|
15
|
-
from adam.commands.
|
|
14
|
+
from adam.commands.app.login import Login
|
|
15
|
+
from adam.commands.cassandra.download_cassandra_log import DownloadCassandraLog
|
|
16
|
+
from adam.commands.diag.check import Check, CheckCommandHelper
|
|
17
|
+
from adam.commands.diag.generate_report import GenerateReport
|
|
18
|
+
from adam.commands.diag.issues import Issues
|
|
19
|
+
from adam.commands.fs.ls import Ls
|
|
16
20
|
from adam.commands.medusa.medusa import Medusa
|
|
17
|
-
from adam.commands.nodetool import NodeTool, NodeToolCommandHelper
|
|
21
|
+
from adam.commands.nodetool.nodetool import NodeTool, NodeToolCommandHelper
|
|
18
22
|
from adam.commands.postgres.postgres import Postgres, PostgresCommandHelper
|
|
19
23
|
from adam.commands.preview_table import PreviewTable
|
|
20
24
|
from adam.commands.reaper.reaper import Reaper, ReaperCommandHelper
|
|
21
25
|
from adam.commands.repair.repair import Repair, RepairCommandHelper
|
|
22
|
-
from adam.commands.
|
|
23
|
-
from adam.commands.restart import Restart
|
|
24
|
-
from adam.commands.rollout import RollOut
|
|
25
|
-
from adam.commands.show.show import Show, ShowCommandHelper
|
|
26
|
-
from adam.commands.watch import Watch
|
|
26
|
+
from adam.commands.show import Show, ShowCommandHelper
|
|
27
27
|
from adam.utils_k8s.kube_context import KubeContext
|
|
28
28
|
from adam.repl import enter_repl
|
|
29
29
|
from adam.repl_state import ReplState
|
|
@@ -128,7 +128,7 @@ def login(kubeconfig: str, config: str, param: list[str], namespace: str, pod: s
|
|
|
128
128
|
@click.option('--pod', '-p', required=False, metavar='pod', help='Kubernetes pod name')
|
|
129
129
|
@click.argument('extra_args', nargs=-1, metavar='<pod>', type=click.UNPROCESSED)
|
|
130
130
|
def logs(kubeconfig: str, config: str, param: list[str], namespace: str, pod: str, extra_args):
|
|
131
|
-
run_command(
|
|
131
|
+
run_command(DownloadCassandraLog(), kubeconfig, config, param, None, namespace, pod, extra_args)
|
|
132
132
|
|
|
133
133
|
|
|
134
134
|
@cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=ClusterCommandHelper, help='List statefulset or pods.')
|
|
@@ -221,7 +221,7 @@ def repair(kubeconfig: str, config: str, param: list[str], cluster: str, namespa
|
|
|
221
221
|
@click.option('--show', '-s', is_flag=True, help='show output from Cassandra nodes')
|
|
222
222
|
@click.argument('extra_args', nargs=-1, metavar='[cluster|pod]', type=click.UNPROCESSED)
|
|
223
223
|
def report(kubeconfig: str, config: str, param: list[str], cluster: str, namespace: str, pod: str, show: bool, extra_args):
|
|
224
|
-
run_command(
|
|
224
|
+
run_command(GenerateReport(), kubeconfig, config, param, cluster, namespace, pod, ('-s',) + extra_args if show else extra_args)
|
|
225
225
|
|
|
226
226
|
|
|
227
227
|
@cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=ClusterOrPodCommandHelper, help='Restart Cassandra Cluster or Node')
|
|
@@ -234,7 +234,7 @@ def report(kubeconfig: str, config: str, param: list[str], cluster: str, namespa
|
|
|
234
234
|
@click.option('--force', is_flag=True, help='need for restarting the whole cluster')
|
|
235
235
|
@click.argument('extra_args', nargs=-1, metavar='<cluster|pod>', type=click.UNPROCESSED)
|
|
236
236
|
def restart(kubeconfig: str, config: str, param: list[str], cluster: str, namespace: str, pod: str, force: bool, extra_args):
|
|
237
|
-
run_command(
|
|
237
|
+
run_command(RestartNodes(), kubeconfig, config, param, cluster, namespace, pod, ('--force',) + extra_args if force else extra_args)
|
|
238
238
|
|
|
239
239
|
|
|
240
240
|
@cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=ClusterOrPodCommandHelper, help='Rolling restart Cassandra Cluster.')
|
adam/checks/compactionstats.py
CHANGED
|
@@ -5,6 +5,7 @@ from adam.checks.check_context import CheckContext
|
|
|
5
5
|
from adam.checks.check_result import CheckResult
|
|
6
6
|
from adam.checks.issue import Issue
|
|
7
7
|
from adam.config import Config
|
|
8
|
+
from adam.utils import Color
|
|
8
9
|
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
9
10
|
|
|
10
11
|
class CompactionStats(Check):
|
|
@@ -15,7 +16,7 @@ class CompactionStats(Check):
|
|
|
15
16
|
issues: list[Issue] = []
|
|
16
17
|
|
|
17
18
|
try:
|
|
18
|
-
result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"nodetool -u {ctx.user} -pw {ctx.pw} compactionstats", show_out=ctx.show_output)
|
|
19
|
+
result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"nodetool -u {ctx.user} -pw {ctx.pw} compactionstats", show_out=ctx.show_output, text_color=Color.gray)
|
|
19
20
|
compactions = parse_nodetool_compactionstats(result.stdout)
|
|
20
21
|
pod_details = {
|
|
21
22
|
'name': ctx.pod,
|
adam/checks/cpu.py
CHANGED
|
@@ -5,6 +5,7 @@ from adam.checks.check_context import CheckContext
|
|
|
5
5
|
from adam.checks.check_result import CheckResult
|
|
6
6
|
from adam.checks.issue import Issue
|
|
7
7
|
from adam.config import Config
|
|
8
|
+
from adam.utils import Color
|
|
8
9
|
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
9
10
|
from adam.utils_k8s.custom_resources import CustomResources
|
|
10
11
|
from adam.utils_k8s.pods import Pods
|
|
@@ -31,7 +32,7 @@ class Cpu(Check):
|
|
|
31
32
|
details['limit'] = container.resources.limits["cpu"]
|
|
32
33
|
|
|
33
34
|
idle = 'Unknown'
|
|
34
|
-
result = CassandraNodes.exec(ctx.pod, ctx.namespace, "mpstat 5 2 | grep Average | awk '{print $NF}'", show_out=ctx.show_output)
|
|
35
|
+
result = CassandraNodes.exec(ctx.pod, ctx.namespace, "mpstat 5 2 | grep Average | awk '{print $NF}'", show_out=ctx.show_output, text_color=Color.gray)
|
|
35
36
|
lines = result.stdout.strip(' \r\n').split('\n')
|
|
36
37
|
line = lines[len(lines) - 1].strip(' \r')
|
|
37
38
|
idle = details['idle'] = line
|
adam/checks/disk.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import re
|
|
2
2
|
from pathlib import Path
|
|
3
|
+
import traceback
|
|
3
4
|
|
|
4
5
|
from adam.checks.check import Check
|
|
5
6
|
from adam.checks.check_context import CheckContext
|
|
6
7
|
from adam.checks.check_result import CheckResult
|
|
7
8
|
from adam.checks.issue import Issue
|
|
8
9
|
from adam.config import Config
|
|
9
|
-
from adam.utils import log_exc
|
|
10
|
+
from adam.utils import Color, log_exc
|
|
10
11
|
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
11
12
|
|
|
12
13
|
class Disk(Check):
|
|
@@ -19,16 +20,16 @@ class Disk(Check):
|
|
|
19
20
|
|
|
20
21
|
try:
|
|
21
22
|
cass_data_path = Config().get('checks.cassandra-data-path', '/c3/cassandra')
|
|
22
|
-
df_result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"df -h | grep -e '{cass_data_path}' -e 'overlay'", show_out=ctx.show_output)
|
|
23
|
+
df_result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"df -h | grep -e '{cass_data_path}' -e 'overlay'", show_out=ctx.show_output, text_color=Color.gray)
|
|
23
24
|
|
|
24
25
|
snapshot_size = Config().get('checks.snapshot-size-cmd', "ls /c3/cassandra/data/data/*/*/snapshots | grep snapshots | sed 's/:$//g' | xargs -I {} du -sk {} | awk '{print $1}' | awk '{s+=$1} END {print s}'")
|
|
25
|
-
ss_result = CassandraNodes.exec(ctx.pod, ctx.namespace, snapshot_size, show_out=ctx.show_output)
|
|
26
|
+
ss_result = CassandraNodes.exec(ctx.pod, ctx.namespace, snapshot_size, show_out=ctx.show_output, text_color=Color.gray)
|
|
26
27
|
|
|
27
28
|
data_sizes = Config().get('checks.data-size-cmd', "du -sh /c3/cassandra/data/data")
|
|
28
|
-
ds_result = CassandraNodes.exec(ctx.pod, ctx.namespace, data_sizes, show_out=ctx.show_output)
|
|
29
|
+
ds_result = CassandraNodes.exec(ctx.pod, ctx.namespace, data_sizes, show_out=ctx.show_output, text_color=Color.gray)
|
|
29
30
|
|
|
30
31
|
table_sizes = Config().get('checks.table-sizes-cmd', "ls -Al /c3/cassandra/data/data/ | awk '{print $9}' | sed 's/\^r//g' | xargs -I {} du -sk /c3/cassandra/data/data/{}")
|
|
31
|
-
ts_result = CassandraNodes.exec(ctx.pod, ctx.namespace, table_sizes, show_out=ctx.show_output)
|
|
32
|
+
ts_result = CassandraNodes.exec(ctx.pod, ctx.namespace, table_sizes, show_out=ctx.show_output, text_color=Color.gray)
|
|
32
33
|
|
|
33
34
|
result = self.build_details(ctx, df_result.stdout, ss_result.stdout, ds_result.stdout, ts_result.stdout)
|
|
34
35
|
|
adam/checks/gossip.py
CHANGED
|
@@ -4,6 +4,7 @@ from adam.checks.check import Check
|
|
|
4
4
|
from adam.checks.check_context import CheckContext
|
|
5
5
|
from adam.checks.check_result import CheckResult
|
|
6
6
|
from adam.checks.issue import Issue
|
|
7
|
+
from adam.utils import Color
|
|
7
8
|
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
8
9
|
|
|
9
10
|
class Gossip(Check):
|
|
@@ -32,7 +33,7 @@ class Gossip(Check):
|
|
|
32
33
|
# TOKENS:21:<hidden>
|
|
33
34
|
# STATUS line missing -> NORMAL
|
|
34
35
|
# user, pw = get_user_pass(pod_name, ns)
|
|
35
|
-
result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"nodetool -u {ctx.user} -pw {ctx.pw} gossipinfo", show_out=ctx.show_output)
|
|
36
|
+
result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"nodetool -u {ctx.user} -pw {ctx.pw} gossipinfo", show_out=ctx.show_output, text_color=Color.gray)
|
|
36
37
|
|
|
37
38
|
nodes = self.parse_gossipinfo(result.stdout)
|
|
38
39
|
details = {
|
adam/checks/memory.py
CHANGED
|
@@ -2,6 +2,7 @@ from adam.checks.check import Check
|
|
|
2
2
|
from adam.checks.check_context import CheckContext
|
|
3
3
|
from adam.checks.check_result import CheckResult
|
|
4
4
|
from adam.checks.issue import Issue
|
|
5
|
+
from adam.utils import Color
|
|
5
6
|
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
6
7
|
from adam.utils_k8s.custom_resources import CustomResources
|
|
7
8
|
from adam.utils_k8s.pods import Pods
|
|
@@ -47,7 +48,7 @@ class Memory(Check):
|
|
|
47
48
|
|
|
48
49
|
def find_error(self, ctx: CheckContext, pattern: str, issue_desc: str):
|
|
49
50
|
escaped = pattern.replace('"', '\"')
|
|
50
|
-
result = CassandraNodes.exec(ctx.pod, ctx.namespace, f'tac /c3/cassandra/logs/system.log | grep "{escaped}" | head -1', show_out=ctx.show_output)
|
|
51
|
+
result = CassandraNodes.exec(ctx.pod, ctx.namespace, f'tac /c3/cassandra/logs/system.log | grep "{escaped}" | head -1', show_out=ctx.show_output, text_color=Color.gray)
|
|
51
52
|
if result.stdout.find(pattern) > 0:
|
|
52
53
|
return Issue(
|
|
53
54
|
statefulset=ctx.statefulset,
|
adam/checks/status.py
CHANGED
|
@@ -4,6 +4,7 @@ from adam.checks.check import Check
|
|
|
4
4
|
from adam.checks.check_context import CheckContext
|
|
5
5
|
from adam.checks.check_result import CheckResult
|
|
6
6
|
from adam.checks.issue import Issue
|
|
7
|
+
from adam.utils import Color
|
|
7
8
|
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
8
9
|
|
|
9
10
|
class Status(Check):
|
|
@@ -14,7 +15,7 @@ class Status(Check):
|
|
|
14
15
|
issues: list[Issue] = []
|
|
15
16
|
|
|
16
17
|
try:
|
|
17
|
-
result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"nodetool -u {ctx.user} -pw {ctx.pw} status", show_out=ctx.show_output)
|
|
18
|
+
result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"nodetool -u {ctx.user} -pw {ctx.pw} status", show_out=ctx.show_output, text_color=Color.gray)
|
|
18
19
|
status = parse_nodetool_status(result.stdout)
|
|
19
20
|
pod_details = {
|
|
20
21
|
'name': ctx.pod,
|
adam/commands/app/app.py
CHANGED
|
@@ -31,8 +31,8 @@ class App(Command):
|
|
|
31
31
|
|
|
32
32
|
return state
|
|
33
33
|
|
|
34
|
-
def completion(self,
|
|
35
|
-
return
|
|
34
|
+
def completion(self, _: ReplState):
|
|
35
|
+
return {}
|
|
36
36
|
|
|
37
|
-
def help(self,
|
|
38
|
-
return
|
|
37
|
+
def help(self, state: ReplState):
|
|
38
|
+
return super().help(state, "post app action use 'show app actions' for registered actions --force refresh session", command='<AppType>.<AppAction>', args='<args> [--force]')
|
adam/commands/app/app_ping.py
CHANGED
|
@@ -34,5 +34,5 @@ class AppPing(Command):
|
|
|
34
34
|
def completion(self, state: ReplState):
|
|
35
35
|
return super().completion(state, {'--force': None})
|
|
36
36
|
|
|
37
|
-
def help(self,
|
|
38
|
-
return
|
|
37
|
+
def help(self, state: ReplState):
|
|
38
|
+
return super().help(state, 'ping app server with Echo.echoStatic() --force refresh session', args='[--force]')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from adam.app_session import AppSession
|
|
2
|
-
from adam.apps import
|
|
2
|
+
from adam.apps import Apps
|
|
3
3
|
from adam.commands.command import Command
|
|
4
4
|
from adam.config import Config
|
|
5
5
|
from adam.repl_state import ReplState
|
|
@@ -45,5 +45,5 @@ class ShowAppActions(Command):
|
|
|
45
45
|
def completion(self, state: ReplState):
|
|
46
46
|
return super().completion(state)
|
|
47
47
|
|
|
48
|
-
def help(self,
|
|
49
|
-
return
|
|
48
|
+
def help(self, state: ReplState):
|
|
49
|
+
return super().help(state, 'show registered app actions')
|
adam/commands/app/show_app_id.py
CHANGED
|
@@ -40,5 +40,5 @@ class ShowAppId(Command):
|
|
|
40
40
|
def completion(self, state: ReplState):
|
|
41
41
|
return super().completion(state)
|
|
42
42
|
|
|
43
|
-
def help(self,
|
|
44
|
-
return
|
|
43
|
+
def help(self, state: ReplState):
|
|
44
|
+
return super().help(state, 'show app id for the Cassandra cluster')
|
|
@@ -34,5 +34,5 @@ class ShowAppQueues(Command):
|
|
|
34
34
|
def completion(self, state: ReplState):
|
|
35
35
|
return super().completion(state, {'--force': None})
|
|
36
36
|
|
|
37
|
-
def help(self,
|
|
38
|
-
return
|
|
37
|
+
def help(self, state: ReplState):
|
|
38
|
+
return super().help(state, 'show invalidation queue counts --force refresh session', args='[--force]')
|
|
@@ -5,7 +5,7 @@ from adam.sso.idp import Idp
|
|
|
5
5
|
from adam.sso.idp_login import IdpLogin
|
|
6
6
|
from adam.commands.command import Command
|
|
7
7
|
from adam.repl_state import ReplState
|
|
8
|
-
from adam.utils import duration, tabulize,
|
|
8
|
+
from adam.utils import duration, tabulize, log2, log_exc
|
|
9
9
|
|
|
10
10
|
class ShowLogin(Command):
|
|
11
11
|
COMMAND = 'show login'
|
|
@@ -52,5 +52,5 @@ class ShowLogin(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 SSO login details')
|
adam/commands/app/utils_app.py
CHANGED
|
@@ -3,12 +3,20 @@ from typing import Union
|
|
|
3
3
|
|
|
4
4
|
from adam.app_session import AppSession
|
|
5
5
|
from adam.apps import Apps
|
|
6
|
-
from adam.pod_exec_result import PodExecResult
|
|
6
|
+
from adam.utils_k8s.pod_exec_result import PodExecResult
|
|
7
7
|
from adam.repl_state import ReplState
|
|
8
8
|
from adam.utils import log2
|
|
9
9
|
from adam.utils_k8s.app_clusters import AppClusters
|
|
10
10
|
from adam.utils_k8s.app_pods import AppPods
|
|
11
11
|
|
|
12
|
+
def app_cd_dirs(state: ReplState):
|
|
13
|
+
if state.app_app:
|
|
14
|
+
return ['..'] + AppPods.pod_names(state.namespace, state.app_env, state.app_app)
|
|
15
|
+
elif state.app_env:
|
|
16
|
+
return ['..'] + [app[0].split('-')[1] for app in Apps.apps(state.app_env)]
|
|
17
|
+
else:
|
|
18
|
+
return [env[0] for env in Apps.envs()]
|
|
19
|
+
|
|
12
20
|
class AppRestHandler:
|
|
13
21
|
def __init__(self, state: ReplState, forced = False):
|
|
14
22
|
self.state = state
|
adam/commands/audit/audit.py
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
3
|
from adam.commands import validate_args
|
|
4
|
+
from adam.commands.audit.completions_l import completions_l
|
|
4
5
|
from adam.commands.audit.audit_repair_tables import AuditRepairTables
|
|
5
6
|
from adam.commands.audit.audit_run import AuditRun
|
|
6
7
|
from adam.commands.audit.show_last10 import ShowLast10
|
|
7
8
|
from adam.commands.audit.show_slow10 import ShowSlow10
|
|
8
9
|
from adam.commands.audit.show_top10 import ShowTop10
|
|
9
|
-
from adam.commands.audit.utils_show_top10 import show_top10_completions_for_nesting
|
|
10
10
|
from adam.commands.command import Command
|
|
11
11
|
from adam.commands.intermediate_command import IntermediateCommand
|
|
12
12
|
from adam.repl_state import ReplState
|
|
13
|
-
from adam.
|
|
14
|
-
from adam.utils import log2, wait_log
|
|
13
|
+
from adam.utils import log2
|
|
15
14
|
from adam.utils_athena import Athena
|
|
16
15
|
|
|
17
16
|
class Audit(IntermediateCommand):
|
|
@@ -50,31 +49,16 @@ class Audit(IntermediateCommand):
|
|
|
50
49
|
return state
|
|
51
50
|
|
|
52
51
|
def completion(self, state: ReplState):
|
|
53
|
-
if state.device
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
# warm up the caches first time when l: drive is accessed
|
|
58
|
-
Athena.table_names()
|
|
59
|
-
Athena.column_names()
|
|
60
|
-
Athena.column_names(partition_cols_only=True)
|
|
61
|
-
|
|
62
|
-
return super().completion(state) | show_top10_completions_for_nesting() | SqlCompleter(
|
|
63
|
-
lambda: Athena.table_names(),
|
|
64
|
-
expandables={
|
|
65
|
-
'columns': lambda table: Athena.column_names(),
|
|
66
|
-
'partition_columns': lambda table: Athena.column_names(partition_cols_only=True)
|
|
67
|
-
},
|
|
68
|
-
variant=SqlVariant.ATHENA
|
|
69
|
-
).completions_for_nesting()
|
|
70
|
-
|
|
71
|
-
return {}
|
|
52
|
+
if state.device != ReplState.L:
|
|
53
|
+
return {}
|
|
54
|
+
|
|
55
|
+
return completions_l()
|
|
72
56
|
|
|
73
57
|
def cmd_list(self):
|
|
74
58
|
return [AuditRepairTables(), AuditRun(), ShowLast10(), ShowSlow10(), ShowTop10()]
|
|
75
59
|
|
|
76
|
-
def help(self,
|
|
77
|
-
return
|
|
60
|
+
def help(self, state: ReplState):
|
|
61
|
+
return super().help(state, 'run SQL queries on Athena audit database', command='[audit] [<sql-statements>]')
|
|
78
62
|
|
|
79
63
|
class AuditCommandHelper(click.Command):
|
|
80
64
|
def get_help(self, ctx: click.Context):
|
|
@@ -46,7 +46,7 @@ class AuditRepairTables(Command):
|
|
|
46
46
|
with Audits.offload() as exec:
|
|
47
47
|
exec.submit(lambda: self.auto_repair(hours))
|
|
48
48
|
|
|
49
|
-
return super().completion(state)
|
|
49
|
+
# return super().completion(state)
|
|
50
50
|
|
|
51
51
|
return {}
|
|
52
52
|
|
|
@@ -68,5 +68,5 @@ class AuditRepairTables(Command):
|
|
|
68
68
|
exec.submit(Athena.query, f'MSCK REPAIR TABLE {table}', None,)
|
|
69
69
|
exec.submit(Audits.put_meta, Audits.PARTITIONS_ADDED, meta,)
|
|
70
70
|
|
|
71
|
-
def help(self,
|
|
72
|
-
return
|
|
71
|
+
def help(self, state: ReplState):
|
|
72
|
+
return super().help(state, 'run MSCK REPAIR to discover new partitions')
|
adam/commands/audit/audit_run.py
CHANGED
|
@@ -44,7 +44,7 @@ class AuditRun(Command):
|
|
|
44
44
|
return state
|
|
45
45
|
|
|
46
46
|
def completion(self, state: ReplState):
|
|
47
|
-
return
|
|
47
|
+
return {}
|
|
48
48
|
|
|
49
|
-
def help(self,
|
|
50
|
-
return
|
|
49
|
+
def help(self, state: ReplState):
|
|
50
|
+
return super().help(state, 'run audit')
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from adam.repl_state import ReplState
|
|
2
|
+
from adam.sql.lark_completer import LarkCompleter
|
|
3
|
+
from adam.utils_athena import Athena
|
|
4
|
+
|
|
5
|
+
def completions_l():
|
|
6
|
+
return LarkCompleter(
|
|
7
|
+
expandables={
|
|
8
|
+
'tables': lambda x: Athena.table_names(),
|
|
9
|
+
'columns': lambda table: Athena.column_names(),
|
|
10
|
+
'partition-columns': lambda table: Athena.column_names(partition_cols_only=True),
|
|
11
|
+
'topn-counts': lambda x: ['10'],
|
|
12
|
+
'topn-types': lambda x: ['last', 'slow', 'top'],
|
|
13
|
+
'topn-windows': lambda x: ['day', 'month'],
|
|
14
|
+
}, variant=ReplState.L
|
|
15
|
+
).completions_for_nesting()
|
|
@@ -30,8 +30,7 @@ class ShowLast10(Command):
|
|
|
30
30
|
return state
|
|
31
31
|
|
|
32
32
|
def completion(self, _: ReplState):
|
|
33
|
-
|
|
34
33
|
return {}
|
|
35
34
|
|
|
36
|
-
def help(self,
|
|
37
|
-
return
|
|
35
|
+
def help(self, state: ReplState):
|
|
36
|
+
return super().help(state, 'show last <limit> audit lines <limit> defaults to 10', args='[limit]')
|
|
@@ -32,5 +32,5 @@ class ShowSlow10(Command):
|
|
|
32
32
|
def completion(self, _: ReplState):
|
|
33
33
|
return {}
|
|
34
34
|
|
|
35
|
-
def help(self,
|
|
36
|
-
return
|
|
35
|
+
def help(self, state: ReplState):
|
|
36
|
+
return super().help(state, 'show slow <limit> audit lines <limit> default to 10', args='[limit]')
|
|
@@ -32,5 +32,5 @@ class ShowTop10(Command):
|
|
|
32
32
|
def completion(self, _: ReplState):
|
|
33
33
|
return {}
|
|
34
34
|
|
|
35
|
-
def help(self,
|
|
36
|
-
return
|
|
35
|
+
def help(self, state: ReplState):
|
|
36
|
+
return super().help(state, 'show top <limit> audit lines <limit> default to 10', args='[limit]')
|
adam/commands/bash/bash.py
CHANGED
|
@@ -30,7 +30,7 @@ class Bash(Command):
|
|
|
30
30
|
return exec(args)
|
|
31
31
|
|
|
32
32
|
def completion(self, state: ReplState):
|
|
33
|
-
return
|
|
33
|
+
return super().completion(state, {c : {'&': None} for c in ['ls', 'cat', 'head']}, pods=Devices.of(state).pods(state, '-'))
|
|
34
34
|
|
|
35
|
-
def help(self,
|
|
36
|
-
return
|
|
35
|
+
def help(self, state: ReplState):
|
|
36
|
+
return super().help(state, 'run bash on Cassandra nodes', args='[bash-commands] [&]')
|
adam/commands/bash/utils_bash.py
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from adam.commands.command import Command
|
|
2
|
+
from adam.commands.devices.devices import Devices
|
|
3
|
+
from adam.config import Config
|
|
4
|
+
from adam.utils_k8s.pod_exec_result import PodExecResult
|
|
5
|
+
from adam.utils import log2
|
|
6
|
+
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
7
|
+
from adam.repl_state import ReplState, RequiredState
|
|
8
|
+
from adam.utils_k8s.pods import Pods
|
|
9
|
+
|
|
10
|
+
class DownloadCassandraLog(Command):
|
|
11
|
+
COMMAND = 'download cassandra log'
|
|
12
|
+
|
|
13
|
+
# the singleton pattern
|
|
14
|
+
def __new__(cls, *args, **kwargs):
|
|
15
|
+
if not hasattr(cls, 'instance'): cls.instance = super(DownloadCassandraLog, cls).__new__(cls)
|
|
16
|
+
|
|
17
|
+
return cls.instance
|
|
18
|
+
|
|
19
|
+
def __init__(self, successor: Command=None):
|
|
20
|
+
super().__init__(successor)
|
|
21
|
+
|
|
22
|
+
def command(self):
|
|
23
|
+
return DownloadCassandraLog.COMMAND
|
|
24
|
+
|
|
25
|
+
def required(self):
|
|
26
|
+
return RequiredState.POD
|
|
27
|
+
|
|
28
|
+
def run(self, cmd: str, state: ReplState):
|
|
29
|
+
if not(args := self.args(cmd)):
|
|
30
|
+
return super().run(cmd, state)
|
|
31
|
+
|
|
32
|
+
with self.validate(args, state) as (args, state):
|
|
33
|
+
path = Config().get('logs.path', '/c3/cassandra/logs/system.log')
|
|
34
|
+
r: PodExecResult = CassandraNodes.exec(state.pod, state.namespace, f'cat {path}', backgrounded=True, history=False)
|
|
35
|
+
|
|
36
|
+
to_file = Pods.download_file(state.pod, 'cassandra', state.namespace, path)
|
|
37
|
+
log2(f'Downloaded to {to_file}.')
|
|
38
|
+
|
|
39
|
+
return r
|
|
40
|
+
|
|
41
|
+
def completion(self, state: ReplState):
|
|
42
|
+
return super().completion(state, pods=Devices.of(state).pods(state, '-'), auto='jit')
|
|
43
|
+
|
|
44
|
+
def help(self, state: ReplState):
|
|
45
|
+
return super().help(state, 'download cassandra system log')
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from adam.commands import extract_options
|
|
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 RestartCluster(Command):
|
|
9
|
+
COMMAND = 'restart cluster'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(RestartCluster, 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 RestartCluster.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) as (args, state):
|
|
31
|
+
with extract_options(args, '--force') as (args, forced):
|
|
32
|
+
if not forced:
|
|
33
|
+
log2('Please add --force for restarting all nodes in a cluster.')
|
|
34
|
+
|
|
35
|
+
return 'force-needed'
|
|
36
|
+
|
|
37
|
+
log2(f'Restarting all pods from {state.sts}...')
|
|
38
|
+
for pod_name in StatefulSets.pod_names(state.sts, state.namespace):
|
|
39
|
+
Pods.delete(pod_name, state.namespace)
|
|
40
|
+
|
|
41
|
+
return state
|
|
42
|
+
|
|
43
|
+
def completion(self, state: ReplState):
|
|
44
|
+
return super().completion(state, {'--force': None})
|
|
45
|
+
|
|
46
|
+
def help(self, state: ReplState):
|
|
47
|
+
return super().help(state, 'restart all the nodes in the cluster', args='--force')
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from adam.commands import extract_options
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.commands.devices.devices import Devices
|
|
4
|
+
from adam.utils_k8s.pods import Pods
|
|
5
|
+
from adam.repl_state import ReplState, RequiredState
|
|
6
|
+
from adam.utils import log2
|
|
7
|
+
|
|
8
|
+
class RestartNode(Command):
|
|
9
|
+
COMMAND = 'restart node'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(RestartNode, 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 RestartNode.COMMAND
|
|
22
|
+
|
|
23
|
+
def required(self):
|
|
24
|
+
return RequiredState.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
|
+
if not state.pod:
|
|
32
|
+
log2("'pod' is required")
|
|
33
|
+
|
|
34
|
+
return 'pod-needed'
|
|
35
|
+
|
|
36
|
+
with extract_options(args, '--force') as (args, forced):
|
|
37
|
+
if not forced:
|
|
38
|
+
log2('Please add --force for restarting pod.')
|
|
39
|
+
|
|
40
|
+
return 'force-needed'
|
|
41
|
+
|
|
42
|
+
log2(f'Restarting {state.pod}...')
|
|
43
|
+
Pods.delete(state.pod, state.namespace)
|
|
44
|
+
|
|
45
|
+
return state
|
|
46
|
+
|
|
47
|
+
def completion(self, state: ReplState):
|
|
48
|
+
return super().completion(state, {'--force': None}, pods=Devices.of(state).pods(state, '-'))
|
|
49
|
+
|
|
50
|
+
def help(self, state: ReplState):
|
|
51
|
+
return super().help(state, 'restart the node', args='--force')
|