kaqing 2.0.52__py3-none-any.whl → 2.0.184__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 +9 -12
- adam/apps.py +20 -6
- adam/batch.py +15 -19
- adam/checks/check_utils.py +19 -49
- adam/checks/compactionstats.py +1 -1
- adam/checks/cpu.py +9 -3
- adam/checks/cpu_metrics.py +52 -0
- adam/checks/disk.py +3 -4
- adam/checks/gossip.py +1 -1
- adam/checks/memory.py +3 -3
- adam/checks/status.py +1 -1
- 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 +24 -0
- adam/commands/alter_tables.py +37 -63
- adam/commands/app/app.py +38 -0
- adam/commands/{app_ping.py → app/app_ping.py} +8 -14
- adam/commands/app/show_app_actions.py +49 -0
- adam/commands/{show → app}/show_app_id.py +9 -12
- adam/commands/{show → app}/show_app_queues.py +8 -14
- adam/commands/app/utils_app.py +98 -0
- adam/commands/audit/audit.py +81 -0
- adam/commands/audit/audit_repair_tables.py +72 -0
- adam/commands/audit/audit_run.py +50 -0
- adam/commands/audit/show_last10.py +37 -0
- adam/commands/audit/show_slow10.py +36 -0
- adam/commands/audit/show_top10.py +36 -0
- adam/commands/audit/utils_show_top10.py +71 -0
- adam/commands/bash/__init__.py +5 -0
- adam/commands/bash/bash.py +36 -0
- adam/commands/bash/bash_completer.py +93 -0
- adam/commands/bash/utils_bash.py +16 -0
- adam/commands/cat.py +36 -0
- adam/commands/cd.py +14 -89
- adam/commands/check.py +18 -21
- adam/commands/cli_commands.py +5 -6
- adam/commands/clipboard_copy.py +86 -0
- adam/commands/code.py +57 -0
- adam/commands/command.py +197 -35
- adam/commands/commands_utils.py +15 -31
- adam/commands/cql/cql_completions.py +29 -8
- adam/commands/cql/cqlsh.py +12 -27
- adam/commands/cql/utils_cql.py +297 -0
- adam/commands/deploy/code_start.py +7 -10
- adam/commands/deploy/code_stop.py +4 -21
- adam/commands/deploy/code_utils.py +5 -5
- adam/commands/deploy/deploy.py +4 -21
- adam/commands/deploy/deploy_frontend.py +14 -17
- adam/commands/deploy/deploy_pg_agent.py +3 -6
- adam/commands/deploy/deploy_pod.py +71 -79
- adam/commands/deploy/deploy_utils.py +16 -26
- adam/commands/deploy/undeploy.py +4 -21
- adam/commands/deploy/undeploy_frontend.py +4 -7
- adam/commands/deploy/undeploy_pg_agent.py +6 -8
- adam/commands/deploy/undeploy_pod.py +15 -16
- adam/commands/devices/__init__.py +0 -0
- adam/commands/devices/device.py +123 -0
- adam/commands/devices/device_app.py +163 -0
- adam/commands/devices/device_auit_log.py +49 -0
- adam/commands/devices/device_cass.py +179 -0
- adam/commands/devices/device_export.py +84 -0
- adam/commands/devices/device_postgres.py +150 -0
- adam/commands/devices/devices.py +25 -0
- adam/commands/download_file.py +47 -0
- adam/commands/exit.py +1 -4
- adam/commands/export/__init__.py +0 -0
- adam/commands/export/clean_up_all_export_sessions.py +37 -0
- adam/commands/export/clean_up_export_sessions.py +39 -0
- adam/commands/export/download_export_session.py +39 -0
- adam/commands/export/drop_export_database.py +39 -0
- adam/commands/export/drop_export_databases.py +37 -0
- adam/commands/export/export.py +53 -0
- adam/commands/export/export_databases.py +245 -0
- adam/commands/export/export_select.py +59 -0
- adam/commands/export/export_select_x.py +54 -0
- adam/commands/export/export_sessions.py +209 -0
- adam/commands/export/export_use.py +49 -0
- adam/commands/export/exporter.py +332 -0
- adam/commands/export/import_files.py +44 -0
- adam/commands/export/import_session.py +44 -0
- adam/commands/export/importer.py +81 -0
- adam/commands/export/importer_athena.py +177 -0
- adam/commands/export/importer_sqlite.py +67 -0
- adam/commands/export/show_column_counts.py +45 -0
- adam/commands/export/show_export_databases.py +38 -0
- adam/commands/export/show_export_session.py +39 -0
- adam/commands/export/show_export_sessions.py +37 -0
- adam/commands/export/utils_export.py +343 -0
- adam/commands/find_files.py +51 -0
- adam/commands/find_processes.py +76 -0
- adam/commands/head.py +36 -0
- adam/commands/help.py +14 -9
- adam/commands/intermediate_command.py +49 -0
- adam/commands/issues.py +14 -40
- adam/commands/kubectl.py +38 -0
- adam/commands/login.py +26 -25
- adam/commands/logs.py +5 -7
- adam/commands/ls.py +11 -110
- adam/commands/medusa/medusa.py +4 -22
- adam/commands/medusa/medusa_backup.py +22 -29
- adam/commands/medusa/medusa_restore.py +40 -39
- adam/commands/medusa/medusa_show_backupjobs.py +19 -20
- adam/commands/medusa/medusa_show_restorejobs.py +15 -20
- adam/commands/nodetool.py +11 -15
- adam/commands/param_get.py +11 -14
- adam/commands/param_set.py +8 -12
- adam/commands/postgres/postgres.py +45 -46
- adam/commands/postgres/postgres_databases.py +269 -0
- adam/commands/postgres/postgres_ls.py +4 -8
- adam/commands/postgres/postgres_preview.py +5 -9
- adam/commands/postgres/psql_completions.py +4 -3
- adam/commands/postgres/utils_postgres.py +70 -0
- adam/commands/preview_table.py +10 -61
- adam/commands/pwd.py +14 -43
- adam/commands/reaper/reaper.py +4 -24
- adam/commands/reaper/reaper_forward.py +49 -56
- adam/commands/reaper/reaper_forward_session.py +6 -0
- adam/commands/reaper/reaper_forward_stop.py +10 -16
- adam/commands/reaper/reaper_restart.py +8 -15
- adam/commands/reaper/reaper_run_abort.py +8 -33
- adam/commands/reaper/reaper_runs.py +43 -58
- 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 +194 -0
- adam/commands/repair/repair.py +4 -22
- adam/commands/repair/repair_log.py +6 -12
- adam/commands/repair/repair_run.py +29 -36
- adam/commands/repair/repair_scan.py +33 -39
- adam/commands/repair/repair_stop.py +6 -12
- adam/commands/report.py +25 -21
- adam/commands/restart.py +27 -28
- adam/commands/rollout.py +20 -25
- adam/commands/shell.py +12 -4
- adam/commands/show/show.py +11 -23
- adam/commands/show/show_adam.py +3 -3
- adam/commands/show/show_cassandra_repairs.py +35 -0
- adam/commands/show/show_cassandra_status.py +34 -52
- adam/commands/show/show_cassandra_version.py +5 -18
- adam/commands/show/show_commands.py +20 -25
- adam/commands/show/show_host.py +33 -0
- adam/commands/show/show_login.py +23 -27
- adam/commands/show/show_params.py +2 -5
- adam/commands/show/show_processes.py +16 -20
- adam/commands/show/show_storage.py +10 -20
- adam/commands/watch.py +27 -30
- adam/config.py +7 -15
- adam/embedded_params.py +1 -1
- adam/log.py +4 -4
- adam/pod_exec_result.py +13 -5
- adam/repl.py +126 -119
- adam/repl_commands.py +63 -29
- adam/repl_state.py +320 -71
- adam/sql/sql_completer.py +98 -383
- adam/sql/sql_state_machine.py +630 -0
- adam/sql/term_completer.py +14 -4
- adam/sso/authn_ad.py +6 -8
- adam/sso/authn_okta.py +4 -6
- adam/sso/cred_cache.py +4 -6
- adam/sso/idp.py +10 -13
- adam/utils.py +511 -10
- adam/utils_athena.py +145 -0
- adam/utils_audits.py +102 -0
- adam/utils_issues.py +32 -0
- adam/utils_k8s/__init__.py +0 -0
- adam/utils_k8s/app_clusters.py +28 -0
- adam/utils_k8s/app_pods.py +36 -0
- adam/utils_k8s/cassandra_clusters.py +44 -0
- adam/{k8s_utils → utils_k8s}/cassandra_nodes.py +11 -4
- adam/{k8s_utils → utils_k8s}/custom_resources.py +16 -17
- adam/{k8s_utils → utils_k8s}/deployment.py +2 -2
- adam/{k8s_utils → utils_k8s}/ingresses.py +2 -2
- adam/{k8s_utils → utils_k8s}/jobs.py +7 -11
- adam/utils_k8s/k8s.py +87 -0
- adam/{k8s_utils → utils_k8s}/kube_context.py +2 -2
- adam/{k8s_utils → utils_k8s}/pods.py +109 -74
- adam/{k8s_utils → utils_k8s}/secrets.py +7 -3
- adam/{k8s_utils → utils_k8s}/service_accounts.py +5 -4
- adam/{k8s_utils → utils_k8s}/services.py +2 -2
- adam/{k8s_utils → utils_k8s}/statefulsets.py +3 -14
- adam/utils_local.py +4 -0
- adam/utils_net.py +24 -0
- adam/utils_repl/__init__.py +0 -0
- adam/utils_repl/automata_completer.py +48 -0
- adam/utils_repl/repl_completer.py +46 -0
- adam/utils_repl/state_machine.py +173 -0
- adam/utils_sqlite.py +137 -0
- adam/version.py +1 -1
- {kaqing-2.0.52.dist-info → kaqing-2.0.184.dist-info}/METADATA +1 -1
- kaqing-2.0.184.dist-info/RECORD +244 -0
- adam/commands/app.py +0 -67
- adam/commands/bash.py +0 -87
- adam/commands/cp.py +0 -95
- adam/commands/cql/cql_table_completer.py +0 -8
- adam/commands/cql/cql_utils.py +0 -109
- adam/commands/describe/describe.py +0 -46
- adam/commands/describe/describe_keyspace.py +0 -60
- adam/commands/describe/describe_keyspaces.py +0 -50
- adam/commands/describe/describe_table.py +0 -60
- adam/commands/describe/describe_tables.py +0 -50
- adam/commands/devices.py +0 -89
- adam/commands/postgres/postgres_session.py +0 -240
- adam/commands/postgres/postgres_utils.py +0 -31
- adam/commands/postgres/psql_table_completer.py +0 -11
- adam/commands/reaper/reaper_session.py +0 -159
- adam/commands/show/show_app_actions.py +0 -53
- adam/commands/show/show_repairs.py +0 -47
- adam/k8s_utils/cassandra_clusters.py +0 -35
- adam/sql/sql_utils.py +0 -5
- kaqing-2.0.52.dist-info/RECORD +0 -184
- /adam/commands/{describe → app}/__init__.py +0 -0
- /adam/{k8s_utils → commands/audit}/__init__.py +0 -0
- /adam/{k8s_utils → utils_k8s}/config_maps.py +0 -0
- /adam/{k8s_utils → utils_k8s}/volumes.py +0 -0
- {kaqing-2.0.52.dist-info → kaqing-2.0.184.dist-info}/WHEEL +0 -0
- {kaqing-2.0.52.dist-info → kaqing-2.0.184.dist-info}/entry_points.txt +0 -0
- {kaqing-2.0.52.dist-info → kaqing-2.0.184.dist-info}/top_level.txt +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
from adam.commands.command import Command
|
|
2
|
-
from adam.
|
|
3
|
-
from adam.
|
|
2
|
+
from adam.commands.reaper.utils_reaper import Reapers
|
|
3
|
+
from adam.utils_k8s.jobs import Jobs
|
|
4
|
+
from adam.utils_k8s.volumes import Volumes
|
|
4
5
|
from adam.repl_state import ReplState, RequiredState
|
|
5
6
|
from adam.config import Config
|
|
6
|
-
from adam.commands.reaper.reaper_session import ReaperSession
|
|
7
7
|
from adam.commands.reaper.reaper_runs_abort import ReaperRunsAbort
|
|
8
8
|
from adam.commands.reaper.reaper_schedule_stop import ReaperScheduleStop
|
|
9
|
-
from adam.utils import log2
|
|
9
|
+
from adam.utils import log2, log_exc
|
|
10
10
|
|
|
11
11
|
class RepairRun(Command):
|
|
12
12
|
COMMAND = 'repair run'
|
|
@@ -30,43 +30,36 @@ class RepairRun(Command):
|
|
|
30
30
|
if not(args := self.args(cmd)):
|
|
31
31
|
return super().run(cmd, state)
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
replace = False
|
|
38
|
-
if len(args) == 1:
|
|
39
|
-
replace = args[0] == 'replace'
|
|
33
|
+
with self.validate(args, state) as (args, state):
|
|
34
|
+
replace = False
|
|
35
|
+
if len(args) == 1:
|
|
36
|
+
replace = args[0] == 'replace'
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
state = ReaperRunsAbort().run('reaper abort runs', state)
|
|
38
|
+
with log_exc():
|
|
39
|
+
log2("Stopping all reaper schedules...")
|
|
40
|
+
for schedule_id in Reapers.cached_schedule_ids(state):
|
|
41
|
+
ReaperScheduleStop().run(f'reaper stop schedule {schedule_id}', state)
|
|
42
|
+
log2("Aborting all reaper runs...")
|
|
43
|
+
state = ReaperRunsAbort().run('reaper abort runs', state)
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
45
|
+
image = Config().get('repair.image', 'ci-registry.c3iot.io/cloudops/cassrepair:2.0.11')
|
|
46
|
+
secret = Config().get('repair.secret', 'ciregistryc3iotio')
|
|
47
|
+
log_path = Config().get('repair.log-path', '/home/cassrepair/logs/')
|
|
48
|
+
user, _ = state.user_pass()
|
|
49
|
+
ns = state.namespace
|
|
50
|
+
env = Config().get('repair.env', {})
|
|
51
|
+
env["cluster"] = ns
|
|
52
|
+
env_from = {"username": user, "password": user}
|
|
53
|
+
pvc_name ='cassrepair-log-' + state.sts
|
|
54
|
+
Volumes.create_pvc(pvc_name, 30, ns)
|
|
55
|
+
if replace:
|
|
56
|
+
Jobs.delete('cassrepair-'+state.sts, ns)
|
|
57
|
+
Jobs.create('cassrepair-'+state.sts, ns, image, secret, env, env_from, 'cassrepair', pvc_name, log_path)
|
|
62
58
|
|
|
63
|
-
|
|
59
|
+
return state
|
|
64
60
|
|
|
65
61
|
def completion(self, state: ReplState):
|
|
66
|
-
|
|
67
|
-
return super().completion(state)
|
|
68
|
-
|
|
69
|
-
return {}
|
|
62
|
+
return super().completion(state)
|
|
70
63
|
|
|
71
64
|
def help(self, _: ReplState):
|
|
72
65
|
return f'{RepairRun.COMMAND} [replace]\t start a repair job, default not replacing'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import time
|
|
2
2
|
|
|
3
3
|
from adam.commands.command import Command
|
|
4
|
-
from adam.
|
|
4
|
+
from adam.utils_k8s.pods import Pods
|
|
5
5
|
from adam.repl_state import ReplState, RequiredState
|
|
6
6
|
from adam.utils import log2
|
|
7
7
|
from adam.config import Config
|
|
@@ -28,47 +28,41 @@ class RepairScan(Command):
|
|
|
28
28
|
if not(args := self.args(cmd)):
|
|
29
29
|
return super().run(cmd, state)
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
31
|
+
with self.validate(args, state) as (args, state):
|
|
32
|
+
n = "7"
|
|
33
|
+
if len(args) == 1:
|
|
34
|
+
n = str(args[0])
|
|
35
|
+
image = Config().get('repair.image', 'ci-registry.c3iot.io/cloudops/cassrepair:2.0.11')
|
|
36
|
+
secret = Config().get('repair.secret', 'ciregistryc3iotio')
|
|
37
|
+
log_path = secret = Config().get('repair.log-path', '/home/cassrepair/logs/')
|
|
38
|
+
ns = state.namespace
|
|
39
|
+
pvc_name ='cassrepair-log-' + state.sts
|
|
40
|
+
pod_name = 'repair-scan'
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
Pods.create(ns, pod_name, image, ["sh", "-c", "tail -f /dev/null"],
|
|
44
|
+
secret=secret,
|
|
45
|
+
env={},
|
|
46
|
+
volume_name='cassrepair-log',
|
|
47
|
+
pvc_name=pvc_name,
|
|
48
|
+
mount_path='/home/cassrepair/logs/')
|
|
49
|
+
except Exception as e:
|
|
50
|
+
if e.status == 409:
|
|
51
|
+
log2(f"Pod {pod_name} already exists")
|
|
52
|
+
else:
|
|
53
|
+
log2("Exception when calling BatchV1Apii->create_namespaced_job: %s\n" % e)
|
|
54
|
+
|
|
55
|
+
Pods.wait_for_running(ns, pod_name, 'Waiting for the scanner pod to start up...')
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
Pods.exec(pod_name, pod_name, ns, f"find {log_path} -type f -mtime -{n} -print0 | xargs -0 grep failed")
|
|
59
|
+
finally:
|
|
60
|
+
Pods.delete(pod_name, ns)
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
Pods.exec(pod_name, pod_name, ns, f"find {log_path} -type f -mtime -{n} -print0 | xargs -0 grep failed")
|
|
62
|
-
finally:
|
|
63
|
-
Pods.delete(pod_name, ns)
|
|
64
|
-
|
|
65
|
-
return state
|
|
62
|
+
return state
|
|
66
63
|
|
|
67
64
|
def completion(self, state: ReplState):
|
|
68
|
-
|
|
69
|
-
return super().completion(state)
|
|
70
|
-
|
|
71
|
-
return {}
|
|
65
|
+
return super().completion(state)
|
|
72
66
|
|
|
73
67
|
def help(self, _: ReplState):
|
|
74
68
|
return f'{RepairScan.COMMAND} [n]\t scan last n days repair log, default 7 days'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from adam.commands.command import Command
|
|
2
|
-
from adam.
|
|
2
|
+
from adam.utils_k8s.jobs import Jobs
|
|
3
3
|
from adam.repl_state import ReplState, RequiredState
|
|
4
4
|
from adam.config import Config
|
|
5
5
|
|
|
@@ -25,20 +25,14 @@ class RepairStop(Command):
|
|
|
25
25
|
if not(args := self.args(cmd)):
|
|
26
26
|
return super().run(cmd, state)
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
ns = state.namespace
|
|
33
|
-
Jobs.delete('cassrepair-'+state.sts, ns)
|
|
28
|
+
with self.validate(args, state) as (args, state):
|
|
29
|
+
ns = state.namespace
|
|
30
|
+
Jobs.delete('cassrepair-'+state.sts, ns)
|
|
34
31
|
|
|
35
|
-
|
|
32
|
+
return state
|
|
36
33
|
|
|
37
34
|
def completion(self, state: ReplState):
|
|
38
|
-
|
|
39
|
-
return super().completion(state)
|
|
40
|
-
|
|
41
|
-
return {}
|
|
35
|
+
return super().completion(state)
|
|
42
36
|
|
|
43
37
|
def help(self, _: ReplState):
|
|
44
38
|
return f'{RepairStop.COMMAND}\t delete a repair job'
|
adam/commands/report.py
CHANGED
|
@@ -22,36 +22,40 @@ class Report(Command):
|
|
|
22
22
|
def command(self):
|
|
23
23
|
return Report.COMMAND
|
|
24
24
|
|
|
25
|
+
def required(self):
|
|
26
|
+
return ReplState.NON_L
|
|
27
|
+
|
|
25
28
|
def run(self, cmd: str, state: ReplState):
|
|
26
29
|
if not(args := self.args(cmd)):
|
|
27
30
|
return super().run(cmd, state)
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
with self.validate(args, state) as (args, state):
|
|
33
|
+
output: dict[str, any] = {}
|
|
34
|
+
|
|
35
|
+
if state.in_repl:
|
|
36
|
+
args, show = Command.extract_options(args, ['-s', '--show'])
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
args, redirect = Command.extract_options(args, ['>'])
|
|
39
|
+
if not redirect or not args:
|
|
40
|
+
log2('Please specify file name: e.g. report > /tmp/report.log')
|
|
41
|
+
return 'no-report-destination'
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
results = run_checks(state.sts, state.namespace, state.pod, show_out=show)
|
|
44
|
+
output = CheckResult.report(results)
|
|
45
|
+
with open(args[0], "w") as json_file:
|
|
46
|
+
json.dump(output, json_file, indent=2)
|
|
47
|
+
log2(f'Report stored in {args[0]}.')
|
|
48
|
+
else:
|
|
49
|
+
args, show = Command.extract_options(args, ['-s', '--show'])
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
results = run_checks(state.sts, state.namespace, state.pod, show_out=show)
|
|
52
|
+
output = CheckResult.report(results)
|
|
53
|
+
click.echo(json.dumps(output, indent=2))
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
return output
|
|
52
56
|
|
|
53
|
-
def completion(self,
|
|
54
|
-
return
|
|
57
|
+
def completion(self, state: ReplState):
|
|
58
|
+
return super().completion(state, {">": None})
|
|
55
59
|
|
|
56
60
|
def help(self, _: ReplState):
|
|
57
61
|
return f"{Report.COMMAND} > <file-name>\t generate report"
|
adam/commands/restart.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
from adam.commands import extract_options
|
|
1
2
|
from adam.commands.command import Command
|
|
2
|
-
from adam.
|
|
3
|
-
from adam.
|
|
3
|
+
from adam.utils_k8s.pods import Pods
|
|
4
|
+
from adam.utils_k8s.statefulsets import StatefulSets
|
|
4
5
|
from adam.repl_state import ReplState, RequiredState
|
|
5
6
|
from adam.utils import log2
|
|
6
7
|
|
|
@@ -26,34 +27,32 @@ class Restart(Command):
|
|
|
26
27
|
if not(args := self.args(cmd)):
|
|
27
28
|
return super().run(cmd, state)
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Pods.delete(arg, state.namespace)
|
|
49
|
-
|
|
50
|
-
return state
|
|
30
|
+
with self.validate(args, state) as (args, state):
|
|
31
|
+
with extract_options(args, '--force') as (args, forced):
|
|
32
|
+
if not args:
|
|
33
|
+
if state.pod:
|
|
34
|
+
log2(f'Restarting {state.pod}...')
|
|
35
|
+
Pods.delete(state.pod, state.namespace)
|
|
36
|
+
else:
|
|
37
|
+
if not forced:
|
|
38
|
+
log2('Please add --force for restarting all nodes in a cluster.')
|
|
39
|
+
return 'force-needed'
|
|
40
|
+
|
|
41
|
+
log2(f'Restarting all pods from {state.sts}...')
|
|
42
|
+
for pod_name in StatefulSets.pod_names(state.sts, state.namespace):
|
|
43
|
+
Pods.delete(pod_name, state.namespace)
|
|
44
|
+
else:
|
|
45
|
+
for arg in args:
|
|
46
|
+
Pods.delete(arg, state.namespace)
|
|
47
|
+
|
|
48
|
+
return state
|
|
51
49
|
|
|
52
50
|
def completion(self, state: ReplState):
|
|
53
|
-
if state
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
if super().completion(state):
|
|
52
|
+
if state.pod:
|
|
53
|
+
return {Restart.COMMAND: None}
|
|
54
|
+
elif state.sts:
|
|
55
|
+
return {Restart.COMMAND: {p: None for p in StatefulSets.pod_names(state.sts, state.namespace)}}
|
|
57
56
|
|
|
58
57
|
return {}
|
|
59
58
|
|
adam/commands/rollout.py
CHANGED
|
@@ -2,9 +2,10 @@ import datetime
|
|
|
2
2
|
from kubernetes import client
|
|
3
3
|
from kubernetes.client.rest import ApiException
|
|
4
4
|
|
|
5
|
+
from adam.commands import extract_options
|
|
5
6
|
from adam.commands.command import Command
|
|
6
7
|
from adam.commands.watch import Watch
|
|
7
|
-
from adam.
|
|
8
|
+
from adam.utils_k8s.statefulsets import StatefulSets
|
|
8
9
|
from adam.config import Config
|
|
9
10
|
from adam.repl_state import ReplState, RequiredState
|
|
10
11
|
from adam.utils import duration, log2
|
|
@@ -31,32 +32,28 @@ class RollOut(Command):
|
|
|
31
32
|
if not(args := self.args(cmd)):
|
|
32
33
|
return super().run(cmd, state)
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
with self.validate(args, state) as (args, state):
|
|
36
|
+
with extract_options(args, '--force') as (args, forced):
|
|
37
|
+
restarted, rollingout = StatefulSets.restarted_at(state.sts, state.namespace)
|
|
38
|
+
if rollingout and not forced:
|
|
39
|
+
log2(f"* Cluster is being rolled out for {duration(restarted)}. Please wait until it's done or use --force.")
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
return state
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
if rollingout and not forced:
|
|
42
|
-
log2(f"* Cluster is being rolled out for {duration(restarted)}. Please wait until it's done or use --force.")
|
|
43
|
+
self.rolling_restart(state.sts, state.namespace)
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
auto_watch = False
|
|
46
|
+
if (auto_watch_cmds := Config().get('watch.auto', 'rollout')):
|
|
47
|
+
cmds = [c.strip(' ') for c in auto_watch_cmds.split(',')]
|
|
48
|
+
if self.command() in cmds:
|
|
49
|
+
auto_watch = True
|
|
50
|
+
log2('Rolling out cluster with auto watch...')
|
|
51
|
+
Watch().run('watch', state)
|
|
45
52
|
|
|
46
|
-
|
|
53
|
+
if not auto_watch:
|
|
54
|
+
log2('Rolling out cluster...')
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
if (auto_watch_cmds := Config().get('watch.auto', 'rollout')):
|
|
50
|
-
cmds = [c.strip(' ') for c in auto_watch_cmds.split(',')]
|
|
51
|
-
if self.command() in cmds:
|
|
52
|
-
auto_watch = True
|
|
53
|
-
log2('Rolling out cluster with auto watch...')
|
|
54
|
-
Watch().run('watch', state)
|
|
55
|
-
|
|
56
|
-
if not auto_watch:
|
|
57
|
-
log2('Rolling out cluster...')
|
|
58
|
-
|
|
59
|
-
return state
|
|
56
|
+
return state
|
|
60
57
|
|
|
61
58
|
def rolling_restart(self, statefulset, namespace):
|
|
62
59
|
# kubectl rollout restart statefulset <statefulset-name>
|
|
@@ -82,9 +79,7 @@ class RollOut(Command):
|
|
|
82
79
|
log2("Exception when calling AppsV1Api->read_namespaced_statefulset_status: %s\n" % e)
|
|
83
80
|
|
|
84
81
|
def completion(self, state: ReplState):
|
|
85
|
-
if state
|
|
86
|
-
return {}
|
|
87
|
-
elif state.sts:
|
|
82
|
+
if super().completion(state):
|
|
88
83
|
return {RollOut.COMMAND: None}
|
|
89
84
|
|
|
90
85
|
return {}
|
adam/commands/shell.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import os
|
|
2
2
|
|
|
3
|
+
from adam.commands import validate_args
|
|
3
4
|
from adam.commands.command import Command
|
|
4
5
|
from adam.repl_state import ReplState
|
|
6
|
+
from adam.utils import log2
|
|
5
7
|
|
|
6
8
|
class Shell(Command):
|
|
7
9
|
COMMAND = ':sh'
|
|
@@ -18,13 +20,19 @@ class Shell(Command):
|
|
|
18
20
|
def command(self):
|
|
19
21
|
return Shell.COMMAND
|
|
20
22
|
|
|
21
|
-
def run(self, cmd: str,
|
|
23
|
+
def run(self, cmd: str, state: ReplState):
|
|
22
24
|
if not(args := self.args(cmd)):
|
|
23
|
-
return super().run(cmd,
|
|
25
|
+
return super().run(cmd, state)
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
with self.validate(args, state) as (args, _):
|
|
28
|
+
with validate_args(args, state, at_least=0) as args_str:
|
|
29
|
+
if args_str:
|
|
30
|
+
os.system(args_str)
|
|
31
|
+
log2()
|
|
32
|
+
else:
|
|
33
|
+
os.system('QING_DROPPED=true bash')
|
|
26
34
|
|
|
27
|
-
|
|
35
|
+
return state
|
|
28
36
|
|
|
29
37
|
def completion(self, state: ReplState):
|
|
30
38
|
return super().completion(state)
|
adam/commands/show/show.py
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
|
-
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
|
|
4
7
|
from adam.commands.medusa.medusa_show_backupjobs import MedusaShowBackupJobs
|
|
5
8
|
from adam.commands.medusa.medusa_show_restorejobs import MedusaShowRestoreJobs
|
|
6
|
-
from adam.commands.show.
|
|
7
|
-
from adam.commands.show.show_app_queues import ShowAppQueues
|
|
9
|
+
from adam.commands.show.show_host import ShowHost
|
|
8
10
|
from adam.commands.show.show_login import ShowLogin
|
|
9
11
|
from .show_params import ShowParams
|
|
10
|
-
from .show_app_id import ShowAppId
|
|
11
12
|
from .show_cassandra_status import ShowCassandraStatus
|
|
12
13
|
from .show_cassandra_version import ShowCassandraVersion
|
|
13
14
|
from .show_commands import ShowKubectlCommands
|
|
14
15
|
from .show_processes import ShowProcesses
|
|
15
|
-
from .
|
|
16
|
+
from .show_cassandra_repairs import ShowCassandraRepairs
|
|
16
17
|
from .show_storage import ShowStorage
|
|
17
18
|
from .show_adam import ShowAdam
|
|
18
|
-
from adam.repl_state import ReplState
|
|
19
19
|
|
|
20
|
-
class Show(
|
|
20
|
+
class Show(IntermediateCommand):
|
|
21
21
|
COMMAND = 'show'
|
|
22
22
|
|
|
23
23
|
# the singleton pattern
|
|
@@ -26,26 +26,14 @@ class Show(Command):
|
|
|
26
26
|
|
|
27
27
|
return cls.instance
|
|
28
28
|
|
|
29
|
-
def __init__(self, successor: Command=None):
|
|
30
|
-
super().__init__(successor)
|
|
31
|
-
|
|
32
29
|
def command(self):
|
|
33
30
|
return Show.COMMAND
|
|
34
31
|
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return super().intermediate_run(cmd, state, args, Show.cmd_list())
|
|
40
|
-
|
|
41
|
-
def cmd_list():
|
|
42
|
-
return [ShowAppActions(), ShowAppId(), ShowAppQueues(), ShowLogin(), ShowKubectlCommands(),
|
|
43
|
-
ShowParams(), ShowProcesses(), ShowRepairs(), ShowStorage(), ShowAdam(),
|
|
32
|
+
def cmd_list(self):
|
|
33
|
+
return [ShowAppActions(), ShowAppId(), ShowAppQueues(), ShowHost(), ShowLogin(), ShowKubectlCommands(),
|
|
34
|
+
ShowParams(), ShowProcesses(), ShowCassandraRepairs(), ShowStorage(), ShowAdam(),
|
|
44
35
|
ShowCassandraStatus(), ShowCassandraVersion(), MedusaShowRestoreJobs(), MedusaShowBackupJobs()]
|
|
45
36
|
|
|
46
|
-
def completion(self, state: ReplState):
|
|
47
|
-
return super().completion(state)
|
|
48
|
-
|
|
49
37
|
class ShowCommandHelper(click.Command):
|
|
50
38
|
def get_help(self, ctx: click.Context):
|
|
51
|
-
|
|
39
|
+
IntermediateCommand.intermediate_help(super().get_help(ctx), Show.COMMAND, Show().cmd_list(), show_cluster_help=True)
|
adam/commands/show/show_adam.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
|
-
from adam.utils import
|
|
4
|
+
from adam.utils import tabulize, log2
|
|
5
5
|
|
|
6
6
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
7
7
|
|
|
@@ -34,10 +34,10 @@ class ShowAdam(Command):
|
|
|
34
34
|
|
|
35
35
|
package = os.path.dirname(os.path.abspath(__file__))
|
|
36
36
|
package = package.split('/adam/')[0] + '/adam'
|
|
37
|
-
|
|
37
|
+
tabulize([
|
|
38
38
|
f'version\t{__version__}',
|
|
39
39
|
f'source\t{package}'
|
|
40
|
-
], separator='\t')
|
|
40
|
+
], separator='\t', to=2)
|
|
41
41
|
|
|
42
42
|
return state
|
|
43
43
|
|
|
@@ -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'
|