kaqing 2.0.55__tar.gz → 2.0.152__tar.gz
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.
- {kaqing-2.0.55 → kaqing-2.0.152}/PKG-INFO +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/apps.py +2 -2
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/batch.py +12 -16
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/checks/check_utils.py +4 -4
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/checks/compactionstats.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/checks/cpu.py +9 -3
- kaqing-2.0.152/adam/checks/cpu_metrics.py +52 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/checks/disk.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/checks/gossip.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/checks/memory.py +3 -3
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/checks/status.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/columns.py +3 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/cpu.py +3 -1
- kaqing-2.0.152/adam/columns/cpu_metrics.py +22 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/alter_tables.py +4 -15
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/app.py +3 -3
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/app_ping.py +2 -2
- kaqing-2.0.152/adam/commands/audit/audit.py +86 -0
- kaqing-2.0.152/adam/commands/audit/audit_repair_tables.py +77 -0
- kaqing-2.0.152/adam/commands/audit/audit_run.py +58 -0
- kaqing-2.0.152/adam/commands/audit/show_last10.py +51 -0
- kaqing-2.0.152/adam/commands/audit/show_slow10.py +50 -0
- kaqing-2.0.152/adam/commands/audit/show_top10.py +48 -0
- kaqing-2.0.152/adam/commands/audit/utils_show_top10.py +59 -0
- kaqing-2.0.152/adam/commands/bash/bash.py +133 -0
- kaqing-2.0.152/adam/commands/bash/bash_completer.py +93 -0
- kaqing-2.0.152/adam/commands/cat.py +56 -0
- kaqing-2.0.152/adam/commands/cd.py +45 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/check.py +6 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/cli_commands.py +3 -3
- kaqing-2.0.152/adam/commands/code.py +60 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/command.py +22 -12
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/commands_utils.py +4 -5
- kaqing-2.0.152/adam/commands/cql/cql_completions.py +29 -0
- kaqing-2.0.152/adam/commands/cql/cql_utils.py +208 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/cql/cqlsh.py +11 -5
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/deploy/code_utils.py +2 -2
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/deploy/deploy.py +7 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/deploy/deploy_pg_agent.py +2 -2
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/deploy/deploy_pod.py +21 -25
- kaqing-2.0.152/adam/commands/deploy/deploy_utils.py +29 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/deploy/undeploy.py +7 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/deploy/undeploy_pg_agent.py +4 -3
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/deploy/undeploy_pod.py +11 -9
- kaqing-2.0.152/adam/commands/devices/device.py +27 -0
- kaqing-2.0.152/adam/commands/devices/device_app.py +146 -0
- kaqing-2.0.152/adam/commands/devices/device_auit_log.py +43 -0
- kaqing-2.0.152/adam/commands/devices/device_cass.py +145 -0
- kaqing-2.0.152/adam/commands/devices/device_export.py +86 -0
- kaqing-2.0.152/adam/commands/devices/device_postgres.py +108 -0
- kaqing-2.0.152/adam/commands/devices/devices.py +25 -0
- kaqing-2.0.152/adam/commands/export/clean_up_export_session.py +53 -0
- kaqing-2.0.152/adam/commands/export/clean_up_export_sessions.py +40 -0
- kaqing-2.0.152/adam/commands/export/drop_export_database.py +58 -0
- kaqing-2.0.152/adam/commands/export/drop_export_databases.py +46 -0
- kaqing-2.0.152/adam/commands/export/export.py +83 -0
- kaqing-2.0.152/adam/commands/export/export_databases.py +170 -0
- kaqing-2.0.152/adam/commands/export/export_select.py +85 -0
- kaqing-2.0.152/adam/commands/export/export_select_x.py +54 -0
- kaqing-2.0.152/adam/commands/export/export_use.py +55 -0
- kaqing-2.0.152/adam/commands/export/exporter.py +364 -0
- kaqing-2.0.152/adam/commands/export/import_session.py +68 -0
- kaqing-2.0.152/adam/commands/export/importer.py +67 -0
- kaqing-2.0.152/adam/commands/export/importer_athena.py +80 -0
- kaqing-2.0.152/adam/commands/export/importer_sqlite.py +47 -0
- kaqing-2.0.152/adam/commands/export/show_column_counts.py +63 -0
- kaqing-2.0.152/adam/commands/export/show_export_databases.py +39 -0
- kaqing-2.0.152/adam/commands/export/show_export_session.py +51 -0
- kaqing-2.0.152/adam/commands/export/show_export_sessions.py +47 -0
- kaqing-2.0.152/adam/commands/export/utils_export.py +291 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/help.py +12 -7
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/issues.py +6 -0
- kaqing-2.0.152/adam/commands/kubectl.py +41 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/login.py +6 -3
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/logs.py +2 -1
- kaqing-2.0.152/adam/commands/ls.py +42 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/medusa/medusa_backup.py +4 -3
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/medusa/medusa_restore.py +4 -4
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/medusa/medusa_show_backupjobs.py +7 -3
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/medusa/medusa_show_restorejobs.py +2 -2
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/nodetool.py +9 -4
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/postgres/postgres.py +21 -6
- kaqing-2.0.55/adam/commands/postgres/postgres_session.py → kaqing-2.0.152/adam/commands/postgres/postgres_context.py +42 -34
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/postgres/postgres_utils.py +8 -8
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/postgres/psql_completions.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/preview_table.py +18 -32
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/pwd.py +2 -28
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper.py +3 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper_restart.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper_session.py +3 -3
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/repair/repair.py +3 -3
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/repair/repair_log.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/repair/repair_run.py +2 -2
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/repair/repair_scan.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/repair/repair_stop.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/report.py +6 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/restart.py +2 -2
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/rollout.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/show/show.py +8 -4
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/show/show_app_actions.py +3 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/show/show_app_id.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/show/show_app_queues.py +3 -2
- kaqing-2.0.55/adam/commands/show/show_repairs.py → kaqing-2.0.152/adam/commands/show/show_cassandra_repairs.py +6 -6
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/show/show_cassandra_status.py +4 -4
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/show/show_cassandra_version.py +3 -3
- kaqing-2.0.152/adam/commands/show/show_host.py +33 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/show/show_login.py +3 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/show/show_processes.py +11 -5
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/show/show_storage.py +2 -2
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/watch.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/config.py +7 -11
- kaqing-2.0.152/adam/embedded_params.py +2 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/pod_exec_result.py +10 -2
- kaqing-2.0.152/adam/repl.py +179 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/repl_commands.py +50 -23
- kaqing-2.0.152/adam/repl_state.py +432 -0
- kaqing-2.0.152/adam/sql/__init__.py +0 -0
- kaqing-2.0.152/adam/sql/sql_completer.py +120 -0
- kaqing-2.0.152/adam/sql/sql_state_machine.py +617 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/sql/term_completer.py +14 -4
- kaqing-2.0.152/adam/sso/__init__.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/sso/cred_cache.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/sso/idp.py +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/utils.py +168 -6
- kaqing-2.0.152/adam/utils_athena.py +145 -0
- kaqing-2.0.152/adam/utils_audits.py +102 -0
- kaqing-2.0.152/adam/utils_k8s/__init__.py +0 -0
- kaqing-2.0.152/adam/utils_k8s/app_clusters.py +33 -0
- kaqing-2.0.152/adam/utils_k8s/app_pods.py +33 -0
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/cassandra_clusters.py +6 -8
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/cassandra_nodes.py +11 -4
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/custom_resources.py +5 -0
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/deployment.py +2 -2
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/pods.py +91 -12
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/secrets.py +5 -1
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/statefulsets.py +5 -4
- kaqing-2.0.152/adam/utils_net.py +24 -0
- kaqing-2.0.152/adam/utils_repl/__init__.py +0 -0
- kaqing-2.0.152/adam/utils_repl/automata_completer.py +48 -0
- kaqing-2.0.152/adam/utils_repl/repl_completer.py +46 -0
- kaqing-2.0.152/adam/utils_repl/state_machine.py +173 -0
- kaqing-2.0.152/adam/utils_sqlite.py +101 -0
- kaqing-2.0.152/adam/version.py +5 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/kaqing.egg-info/PKG-INFO +1 -1
- {kaqing-2.0.55 → kaqing-2.0.152}/kaqing.egg-info/SOURCES.txt +73 -28
- {kaqing-2.0.55 → kaqing-2.0.152}/setup.py +1 -1
- kaqing-2.0.55/adam/commands/bash.py +0 -87
- kaqing-2.0.55/adam/commands/cd.py +0 -116
- kaqing-2.0.55/adam/commands/cql/cql_completions.py +0 -11
- kaqing-2.0.55/adam/commands/cql/cql_table_completer.py +0 -8
- kaqing-2.0.55/adam/commands/cql/cql_utils.py +0 -109
- kaqing-2.0.55/adam/commands/deploy/deploy_utils.py +0 -39
- kaqing-2.0.55/adam/commands/describe/describe.py +0 -46
- kaqing-2.0.55/adam/commands/describe/describe_keyspace.py +0 -60
- kaqing-2.0.55/adam/commands/describe/describe_keyspaces.py +0 -50
- kaqing-2.0.55/adam/commands/describe/describe_table.py +0 -60
- kaqing-2.0.55/adam/commands/describe/describe_tables.py +0 -50
- kaqing-2.0.55/adam/commands/devices.py +0 -89
- kaqing-2.0.55/adam/commands/ls.py +0 -140
- kaqing-2.0.55/adam/commands/postgres/psql_table_completer.py +0 -11
- kaqing-2.0.55/adam/embedded_params.py +0 -2
- kaqing-2.0.55/adam/repl.py +0 -173
- kaqing-2.0.55/adam/repl_state.py +0 -223
- kaqing-2.0.55/adam/sql/sql_completer.py +0 -544
- kaqing-2.0.55/adam/sql/sql_utils.py +0 -5
- kaqing-2.0.55/adam/version.py +0 -5
- {kaqing-2.0.55 → kaqing-2.0.152}/README +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/__init__.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/app_session.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/checks/__init__.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/checks/check.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/checks/check_context.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/checks/check_result.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/checks/issue.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/cli.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/cli_group.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/__init__.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/column.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/compactions.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/dir_data.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/dir_snapshots.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/gossip.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/host_id.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/memory.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/node_address.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/node_load.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/node_owns.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/node_status.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/node_tokens.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/node_utils.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/pod_name.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/volume_cassandra.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/columns/volume_root.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/__init__.py +0 -0
- {kaqing-2.0.55/adam/commands/cql → kaqing-2.0.152/adam/commands/audit}/__init__.py +0 -0
- {kaqing-2.0.55/adam/commands/deploy → kaqing-2.0.152/adam/commands/bash}/__init__.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/command_helpers.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/cp.py +0 -0
- {kaqing-2.0.55/adam/commands/describe → kaqing-2.0.152/adam/commands/cql}/__init__.py +0 -0
- {kaqing-2.0.55/adam/commands/medusa → kaqing-2.0.152/adam/commands/deploy}/__init__.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/deploy/code_start.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/deploy/code_stop.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/deploy/deploy_frontend.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/deploy/undeploy_frontend.py +0 -0
- {kaqing-2.0.55/adam/commands/postgres → kaqing-2.0.152/adam/commands/devices}/__init__.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/exit.py +0 -0
- {kaqing-2.0.55/adam/commands/reaper → kaqing-2.0.152/adam/commands/export}/__init__.py +0 -0
- {kaqing-2.0.55/adam/commands/repair → kaqing-2.0.152/adam/commands/medusa}/__init__.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/medusa/medusa.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/nodetool_commands.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/param_get.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/param_set.py +0 -0
- {kaqing-2.0.55/adam/commands/show → kaqing-2.0.152/adam/commands/postgres}/__init__.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/postgres/postgres_ls.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/postgres/postgres_preview.py +0 -0
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/commands/reaper}/__init__.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper_forward.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper_forward_stop.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper_run_abort.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper_runs.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper_runs_abort.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper_schedule_activate.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper_schedule_start.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper_schedule_stop.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper_schedules.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/reaper/reaper_status.py +0 -0
- {kaqing-2.0.55/adam/sql → kaqing-2.0.152/adam/commands/repair}/__init__.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/shell.py +0 -0
- {kaqing-2.0.55/adam/sso → kaqing-2.0.152/adam/commands/show}/__init__.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/show/show_adam.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/show/show_commands.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/commands/show/show_params.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/embedded_apps.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/log.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/repl_session.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/sso/authenticator.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/sso/authn_ad.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/sso/authn_okta.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/sso/id_token.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/sso/idp_login.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/sso/idp_session.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/adam/sso/sso_config.py +0 -0
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/config_maps.py +0 -0
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/ingresses.py +0 -0
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/jobs.py +0 -0
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/kube_context.py +0 -0
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/service_accounts.py +0 -0
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/services.py +0 -0
- {kaqing-2.0.55/adam/k8s_utils → kaqing-2.0.152/adam/utils_k8s}/volumes.py +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/kaqing.egg-info/dependency_links.txt +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/kaqing.egg-info/entry_points.txt +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/kaqing.egg-info/top_level.txt +0 -0
- {kaqing-2.0.55 → kaqing-2.0.152}/setup.cfg +0 -0
|
@@ -5,10 +5,10 @@ from typing import cast
|
|
|
5
5
|
import yaml
|
|
6
6
|
|
|
7
7
|
from adam.config import Config
|
|
8
|
-
from adam.
|
|
8
|
+
from adam.utils_k8s.ingresses import Ingresses
|
|
9
9
|
|
|
10
10
|
from . import __version__
|
|
11
|
-
from adam.
|
|
11
|
+
from adam.utils_k8s.services import Services
|
|
12
12
|
from adam.utils import copy_config_file
|
|
13
13
|
|
|
14
14
|
class AppAction:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
|
-
from adam.commands.
|
|
3
|
+
from adam.commands.audit.audit import Audit, AuditCommandHelper
|
|
4
|
+
from adam.commands.bash.bash import Bash
|
|
4
5
|
from adam.commands.check import Check, CheckCommandHelper
|
|
5
6
|
from adam.commands.cp import ClipboardCopy, CopyCommandHelper
|
|
6
7
|
from adam.commands.command import Command
|
|
@@ -8,7 +9,6 @@ from adam.commands.command_helpers import ClusterCommandHelper, ClusterOrPodComm
|
|
|
8
9
|
from adam.commands.cql.cqlsh import CqlCommandHelper, Cqlsh
|
|
9
10
|
from adam.commands.deploy.deploy import Deploy, DeployCommandHelper
|
|
10
11
|
from adam.commands.deploy.undeploy import Undeploy, UndeployCommandHelper
|
|
11
|
-
from adam.commands.describe.describe import Describe, DescribeCommandHelper
|
|
12
12
|
from adam.commands.issues import Issues
|
|
13
13
|
from adam.commands.login import Login
|
|
14
14
|
from adam.commands.logs import Logs
|
|
@@ -24,11 +24,20 @@ from adam.commands.restart import Restart
|
|
|
24
24
|
from adam.commands.rollout import RollOut
|
|
25
25
|
from adam.commands.show.show import Show, ShowCommandHelper
|
|
26
26
|
from adam.commands.watch import Watch
|
|
27
|
-
from adam.
|
|
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
|
|
30
30
|
from adam.cli_group import cli
|
|
31
31
|
|
|
32
|
+
@cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=AuditCommandHelper, help='Run audit functions.')
|
|
33
|
+
@click.option('--kubeconfig', '-k', required=False, metavar='path', help='path to kubeconfig file')
|
|
34
|
+
@click.option('--config', default='params.yaml', metavar='path', help='path to kaqing parameters file')
|
|
35
|
+
@click.option('--param', '-v', multiple=True, metavar='<key>=<value>', help='parameter override')
|
|
36
|
+
@click.argument('extra_args', nargs=-1, metavar='repair', type=click.UNPROCESSED)
|
|
37
|
+
def audit(kubeconfig: str, config: str, param: list[str], extra_args):
|
|
38
|
+
run_command(Audit(), kubeconfig, config, param, None, None, None, extra_args)
|
|
39
|
+
|
|
40
|
+
|
|
32
41
|
@cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=ClusterOrPodCommandHelper, help='Run a single bash command.')
|
|
33
42
|
@click.option('--kubeconfig', '-k', required=False, metavar='path', help='path to kubeconfig file')
|
|
34
43
|
@click.option('--config', default='params.yaml', metavar='path', help='path to kaqing parameters file')
|
|
@@ -87,19 +96,6 @@ def deploy(kubeconfig: str, config: str, param: list[str], namespace: str, extra
|
|
|
87
96
|
run_command(Deploy(), kubeconfig, config, param, None, namespace, None, extra_args)
|
|
88
97
|
|
|
89
98
|
|
|
90
|
-
@cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=DescribeCommandHelper, help='Describe keyspace(s) or table(s).')
|
|
91
|
-
@click.option('--kubeconfig', '-k', required=False, metavar='path', help='path to kubeconfig file')
|
|
92
|
-
@click.option('--config', default='params.yaml', metavar='path', help='path to kaqing parameters file')
|
|
93
|
-
@click.option('--param', '-v', multiple=True, metavar='<key>=<value>', help='parameter override')
|
|
94
|
-
@click.option('--cluster', '-c', required=False, metavar='statefulset', help='Kubernetes statefulset name')
|
|
95
|
-
@click.option('--namespace', '-n', required=False, metavar='namespace', help='Kubernetes namespace')
|
|
96
|
-
@click.option('--pod', '-p', required=False, metavar='pod', help='Kubernetes pod name')
|
|
97
|
-
@click.option('--all-nodes', '-a', is_flag=True, help='execute on all Cassandra nodes')
|
|
98
|
-
@click.argument('extra_args', nargs=-1, metavar='<cluster|pod>', type=click.UNPROCESSED)
|
|
99
|
-
def describe(kubeconfig: str, config: str, param: list[str], cluster: str, namespace: str, pod: str, all_nodes: bool, extra_args):
|
|
100
|
-
run_command(Describe(), kubeconfig, config, param, cluster, namespace, pod, ('--all-nodes',) + extra_args if all_nodes else extra_args)
|
|
101
|
-
|
|
102
|
-
|
|
103
99
|
@cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=ClusterOrPodCommandHelper, help="Print Qing's issues.")
|
|
104
100
|
@click.option('--kubeconfig', '-k', required=False, metavar='path', help='path to kubeconfig file')
|
|
105
101
|
@click.option('--config', default='params.yaml', metavar='path', help='path to kaqing parameters file')
|
|
@@ -13,10 +13,10 @@ from adam.checks.issue import Issue
|
|
|
13
13
|
from adam.checks.memory import Memory
|
|
14
14
|
from adam.checks.status import Status
|
|
15
15
|
from adam.config import Config
|
|
16
|
-
from adam.
|
|
17
|
-
from adam.
|
|
18
|
-
from adam.
|
|
19
|
-
from adam.
|
|
16
|
+
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
17
|
+
from adam.utils_k8s.kube_context import KubeContext
|
|
18
|
+
from adam.utils_k8s.secrets import Secrets
|
|
19
|
+
from adam.utils_k8s.statefulsets import StatefulSets
|
|
20
20
|
from adam.utils import elapsed_time, log2
|
|
21
21
|
|
|
22
22
|
def all_checks() -> list[Check]:
|
|
@@ -5,7 +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.
|
|
8
|
+
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
9
9
|
|
|
10
10
|
class CompactionStats(Check):
|
|
11
11
|
def name(self):
|
|
@@ -5,8 +5,9 @@ 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.
|
|
9
|
-
from adam.
|
|
8
|
+
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
9
|
+
from adam.utils_k8s.custom_resources import CustomResources
|
|
10
|
+
from adam.utils_k8s.pods import Pods
|
|
10
11
|
|
|
11
12
|
class Cpu(Check):
|
|
12
13
|
def name(self):
|
|
@@ -20,10 +21,15 @@ class Cpu(Check):
|
|
|
20
21
|
'namespace': ctx.namespace,
|
|
21
22
|
'statefulset': ctx.statefulset,
|
|
22
23
|
'cpu': 'Unknown',
|
|
23
|
-
'idle': 'Unknown'
|
|
24
|
+
'idle': 'Unknown',
|
|
25
|
+
'limit': 'NA'
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
try:
|
|
29
|
+
container = Pods.get_container(ctx.namespace, ctx.pod, container_name='cassandra')
|
|
30
|
+
if container.resources.limits and "cpu" in container.resources.limits:
|
|
31
|
+
details['limit'] = container.resources.limits["cpu"]
|
|
32
|
+
|
|
27
33
|
idle = 'Unknown'
|
|
28
34
|
result = CassandraNodes.exec(ctx.pod, ctx.namespace, "mpstat 5 2 | grep Average | awk '{print $NF}'", show_out=ctx.show_output)
|
|
29
35
|
lines = result.stdout.strip(' \r\n').split('\n')
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from kubernetes.utils import parse_quantity
|
|
2
|
+
|
|
3
|
+
from adam.checks.check import Check
|
|
4
|
+
from adam.checks.check_context import CheckContext
|
|
5
|
+
from adam.checks.check_result import CheckResult
|
|
6
|
+
from adam.checks.issue import Issue
|
|
7
|
+
from adam.config import Config
|
|
8
|
+
from adam.utils_k8s.custom_resources import CustomResources
|
|
9
|
+
from adam.utils_k8s.pods import Pods
|
|
10
|
+
|
|
11
|
+
class CpuMetrics(Check):
|
|
12
|
+
def name(self):
|
|
13
|
+
return 'cpu-metrics'
|
|
14
|
+
|
|
15
|
+
def check(self, ctx: CheckContext) -> CheckResult:
|
|
16
|
+
issues: list[Issue] = []
|
|
17
|
+
|
|
18
|
+
details = {
|
|
19
|
+
'name': ctx.pod,
|
|
20
|
+
'namespace': ctx.namespace,
|
|
21
|
+
'statefulset': ctx.statefulset,
|
|
22
|
+
'cpu': 'Unknown',
|
|
23
|
+
'limit': 'NA'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
container = Pods.get_container(ctx.namespace, ctx.pod, container_name='cassandra')
|
|
28
|
+
if container.resources.limits and "cpu" in container.resources.limits:
|
|
29
|
+
details['limit'] = container.resources.limits["cpu"]
|
|
30
|
+
|
|
31
|
+
metrics = CustomResources.get_metrics(ctx.namespace, ctx.pod, container_name='cassandra')
|
|
32
|
+
usage = 'Unknown'
|
|
33
|
+
if metrics:
|
|
34
|
+
usage = details['cpu'] = metrics["usage"]["cpu"]
|
|
35
|
+
|
|
36
|
+
cpu_threshold = Config().get('checks.cpu-threshold', 0.0)
|
|
37
|
+
if cpu_threshold != 0.0 and usage != "Unknown" and parse_quantity(usage) > cpu_threshold:
|
|
38
|
+
issues.append(Issue(
|
|
39
|
+
statefulset=ctx.statefulset,
|
|
40
|
+
namespace=ctx.namespace,
|
|
41
|
+
pod=ctx.pod,
|
|
42
|
+
category='cpu',
|
|
43
|
+
desc=f'CPU is too busy: {usage}',
|
|
44
|
+
suggestion=f"qing restart {ctx.pod}@{ctx.namespace}"
|
|
45
|
+
))
|
|
46
|
+
except Exception as e:
|
|
47
|
+
issues.append(self.issue_from_err(sts_name=ctx.statefulset, ns=ctx.namespace, pod_name=ctx.pod, exception=e))
|
|
48
|
+
|
|
49
|
+
return CheckResult(self.name(), details, issues)
|
|
50
|
+
|
|
51
|
+
def help(self):
|
|
52
|
+
return f'{CpuMetrics().name()}: check cpu busy percentage with metrics'
|
|
@@ -6,7 +6,7 @@ from adam.checks.check_context import CheckContext
|
|
|
6
6
|
from adam.checks.check_result import CheckResult
|
|
7
7
|
from adam.checks.issue import Issue
|
|
8
8
|
from adam.config import Config
|
|
9
|
-
from adam.
|
|
9
|
+
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
10
10
|
|
|
11
11
|
class Disk(Check):
|
|
12
12
|
def name(self):
|
|
@@ -4,7 +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.
|
|
7
|
+
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
8
8
|
|
|
9
9
|
class Gossip(Check):
|
|
10
10
|
def name(self):
|
|
@@ -2,9 +2,9 @@ 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.
|
|
6
|
-
from adam.
|
|
7
|
-
from adam.
|
|
5
|
+
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
6
|
+
from adam.utils_k8s.custom_resources import CustomResources
|
|
7
|
+
from adam.utils_k8s.pods import Pods
|
|
8
8
|
|
|
9
9
|
class Memory(Check):
|
|
10
10
|
def name(self):
|
|
@@ -4,7 +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.
|
|
7
|
+
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
8
8
|
|
|
9
9
|
class Status(Check):
|
|
10
10
|
def name(self):
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from adam.columns.column import Column
|
|
2
2
|
from adam.columns.compactions import Compactions
|
|
3
3
|
from adam.columns.cpu import Cpu
|
|
4
|
+
from adam.columns.cpu_metrics import CpuMetrics
|
|
4
5
|
from adam.columns.dir_data import DataDir
|
|
5
6
|
from adam.columns.dir_snapshots import SnapshotsDir
|
|
6
7
|
from adam.columns.gossip import Gossip
|
|
@@ -23,7 +24,7 @@ class Columns:
|
|
|
23
24
|
COLUMNS_BY_NAME = None
|
|
24
25
|
|
|
25
26
|
def all_columns():
|
|
26
|
-
return [Compactions(), Cpu(), DataDir(), SnapshotsDir(), Gossip(), HostId(), Memory(),
|
|
27
|
+
return [Compactions(), Cpu(), CpuMetrics(), DataDir(), SnapshotsDir(), Gossip(), HostId(), Memory(),
|
|
27
28
|
NodeAddress(), NodeLoad(), NodeOwns(), NodeStatus(),NodeTokens(), PodName(), CassandraVolume(), RootVolume()]
|
|
28
29
|
|
|
29
30
|
def columns_by_name():
|
|
@@ -38,6 +39,7 @@ class Columns:
|
|
|
38
39
|
name = name.strip(' ')
|
|
39
40
|
if not name in Columns.COLUMNS_BY_NAME:
|
|
40
41
|
return None
|
|
42
|
+
|
|
41
43
|
cols.append(Columns.COLUMNS_BY_NAME[name]())
|
|
42
44
|
|
|
43
45
|
return cols
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from kubernetes.utils.quantity import parse_quantity
|
|
2
|
+
|
|
1
3
|
from adam.checks.check_result import CheckResult
|
|
2
4
|
from adam.checks.cpu import Cpu as CpuCheck
|
|
3
5
|
from adam.columns.column import Column
|
|
@@ -14,4 +16,4 @@ class Cpu(Column):
|
|
|
14
16
|
cpu = r.details[CpuCheck().name()]
|
|
15
17
|
busy = 100.0 - float(cpu['idle'])
|
|
16
18
|
|
|
17
|
-
return f'{round(busy)}%'
|
|
19
|
+
return f'{round(busy)}%/{parse_quantity(cpu["limit"]) * 100}%'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from kubernetes.utils.quantity import parse_quantity
|
|
2
|
+
|
|
3
|
+
from adam.checks.check_result import CheckResult
|
|
4
|
+
from adam.checks.cpu_metrics import CpuMetrics as CpuCheck
|
|
5
|
+
from adam.columns.column import Column
|
|
6
|
+
|
|
7
|
+
class CpuMetrics(Column):
|
|
8
|
+
def name(self):
|
|
9
|
+
return 'cpu-metrics'
|
|
10
|
+
|
|
11
|
+
def checks(self):
|
|
12
|
+
return [CpuCheck()]
|
|
13
|
+
|
|
14
|
+
def pod_value(self, check_results: list[CheckResult], pod_name: str):
|
|
15
|
+
r = self.result_by_pod(check_results, pod_name)
|
|
16
|
+
cpu = r.details[CpuCheck().name()]
|
|
17
|
+
|
|
18
|
+
cpu_decimal = parse_quantity(cpu['cpu'])
|
|
19
|
+
cpu_limit = parse_quantity(cpu['limit'])
|
|
20
|
+
business = cpu_decimal * 100 / cpu_limit
|
|
21
|
+
|
|
22
|
+
return f"{business:.2f}%({cpu_decimal}/{cpu_limit})"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from adam.commands.command import Command
|
|
2
|
-
from adam.commands.cql.cql_utils import
|
|
2
|
+
from adam.commands.cql.cql_utils import cassandra_tables as get_tables, run_cql
|
|
3
3
|
from adam.config import Config
|
|
4
|
-
from adam.pod_exec_result import PodExecResult
|
|
5
4
|
from adam.repl_state import ReplState, RequiredState
|
|
6
5
|
from adam.utils import log2
|
|
7
6
|
|
|
@@ -44,11 +43,6 @@ class AlterTables(Command):
|
|
|
44
43
|
args, include_reaper = Command.extract_options(args, '--include-reaper')
|
|
45
44
|
arg_str = ' '.join(args)
|
|
46
45
|
|
|
47
|
-
# r: list[PodExecResult] = run_cql(state, 'describe tables', show_out=False, on_any=True)
|
|
48
|
-
# if not r:
|
|
49
|
-
# log2('No pod is available')
|
|
50
|
-
# return 'no-pod'
|
|
51
|
-
|
|
52
46
|
excludes = [e.strip(' \r\n') for e in Config().get(
|
|
53
47
|
'cql.alter-tables.excludes',
|
|
54
48
|
'system_auth,system_traces,reaper_db,system_distributed,system_views,system,system_schema,system_virtual_schema').split(',')]
|
|
@@ -79,14 +73,9 @@ class AlterTables(Command):
|
|
|
79
73
|
# do not continue to cql route
|
|
80
74
|
return state
|
|
81
75
|
|
|
82
|
-
def completion(self,
|
|
83
|
-
|
|
84
|
-
ps = Config().get('cql.alter-tables.gc-grace-periods', '3600,86400,864000,7776000').split(',')
|
|
85
|
-
return super().completion(state, {
|
|
86
|
-
'GC_GRACE_SECONDS': {'=': {p.strip(' \r\n'): {'--include-reaper': None} for p in ps}},
|
|
87
|
-
})
|
|
88
|
-
|
|
76
|
+
def completion(self, _: ReplState) -> dict[str, any]:
|
|
77
|
+
# auto completion is taken care of by sql completer
|
|
89
78
|
return {}
|
|
90
79
|
|
|
91
80
|
def help(self, _: ReplState) -> str:
|
|
92
|
-
return f'{AlterTables.COMMAND} <param = value> [--include-reaper] \t alter on all tables'
|
|
81
|
+
return f'{AlterTables.COMMAND} <param = value> [--include-reaper] \t alter schema on all tables'
|
|
@@ -22,14 +22,14 @@ class App(Command):
|
|
|
22
22
|
return App.COMMAND
|
|
23
23
|
|
|
24
24
|
def required(self):
|
|
25
|
-
return RequiredState.
|
|
25
|
+
return RequiredState.APP_APP
|
|
26
26
|
|
|
27
27
|
def run(self, cmd: str, state: ReplState):
|
|
28
28
|
if not(args := self.args(cmd)):
|
|
29
29
|
return super().run(cmd, state)
|
|
30
30
|
|
|
31
31
|
state, args = self.apply_state(args, state)
|
|
32
|
-
if not self.validate_state(state
|
|
32
|
+
if not self.validate_state(state):
|
|
33
33
|
return state
|
|
34
34
|
|
|
35
35
|
args, forced = Command.extract_options(args, '--force')
|
|
@@ -64,4 +64,4 @@ class App(Command):
|
|
|
64
64
|
return {}
|
|
65
65
|
|
|
66
66
|
def help(self, _: ReplState):
|
|
67
|
-
return f"
|
|
67
|
+
return f"<AppType>.<AppAction> <args> [--force]\t post app action; check with 'show app actions' command"
|
|
@@ -18,14 +18,14 @@ class AppPing(Command):
|
|
|
18
18
|
return AppPing.COMMAND
|
|
19
19
|
|
|
20
20
|
def required(self):
|
|
21
|
-
return RequiredState.
|
|
21
|
+
return RequiredState.APP_APP
|
|
22
22
|
|
|
23
23
|
def run(self, cmd: str, state: ReplState):
|
|
24
24
|
if not(args := self.args(cmd)):
|
|
25
25
|
return super().run(cmd, state)
|
|
26
26
|
|
|
27
27
|
state, args = self.apply_state(args, state)
|
|
28
|
-
if not self.validate_state(state
|
|
28
|
+
if not self.validate_state(state):
|
|
29
29
|
return state
|
|
30
30
|
|
|
31
31
|
_, forced = Command.extract_options(args, '--force')
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from adam.commands.audit.audit_repair_tables import AuditRepairTables
|
|
4
|
+
from adam.commands.audit.audit_run import AuditRun
|
|
5
|
+
from adam.commands.audit.show_last10 import ShowLast10
|
|
6
|
+
from adam.commands.audit.show_slow10 import ShowSlow10
|
|
7
|
+
from adam.commands.audit.show_top10 import ShowTop10
|
|
8
|
+
from adam.commands.audit.utils_show_top10 import show_top10_completions_for_nesting
|
|
9
|
+
from adam.commands.command import Command
|
|
10
|
+
from adam.repl_state import ReplState
|
|
11
|
+
from adam.sql.sql_completer import SqlCompleter, SqlVariant
|
|
12
|
+
from adam.utils import log2, wait_log
|
|
13
|
+
from adam.utils_athena import Athena
|
|
14
|
+
|
|
15
|
+
class Audit(Command):
|
|
16
|
+
COMMAND = 'audit'
|
|
17
|
+
|
|
18
|
+
# the singleton pattern
|
|
19
|
+
def __new__(cls, *args, **kwargs):
|
|
20
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Audit, cls).__new__(cls)
|
|
21
|
+
|
|
22
|
+
return cls.instance
|
|
23
|
+
|
|
24
|
+
def __init__(self, successor: Command=None):
|
|
25
|
+
super().__init__(successor)
|
|
26
|
+
self.schema_read = False
|
|
27
|
+
|
|
28
|
+
def command(self):
|
|
29
|
+
return Audit.COMMAND
|
|
30
|
+
|
|
31
|
+
def required(self):
|
|
32
|
+
return ReplState.L
|
|
33
|
+
|
|
34
|
+
def run(self, cmd: str, state: ReplState):
|
|
35
|
+
if not(args := self.args(cmd)):
|
|
36
|
+
return super().run(cmd, state)
|
|
37
|
+
|
|
38
|
+
state, args = self.apply_state(args, state)
|
|
39
|
+
if not self.validate_state(state):
|
|
40
|
+
return state
|
|
41
|
+
|
|
42
|
+
r = None
|
|
43
|
+
if len(args) > 0:
|
|
44
|
+
r = super().intermediate_run(cmd, state, args, Audit.cmd_list(), display_help=False)
|
|
45
|
+
|
|
46
|
+
if not r or isinstance(r, str) and r == 'command-missing':
|
|
47
|
+
sql = 'select * from audit order by ts desc limit 10'
|
|
48
|
+
if args:
|
|
49
|
+
sql = ' '.join(args)
|
|
50
|
+
else:
|
|
51
|
+
log2(sql)
|
|
52
|
+
|
|
53
|
+
Athena.run_query(sql)
|
|
54
|
+
|
|
55
|
+
return state
|
|
56
|
+
|
|
57
|
+
def completion(self, state: ReplState):
|
|
58
|
+
if state.device == ReplState.L:
|
|
59
|
+
if not self.schema_read:
|
|
60
|
+
wait_log(f'Inspecting audit database schema...')
|
|
61
|
+
self.schema_read = True
|
|
62
|
+
# warm up the caches first time when l: drive is accessed
|
|
63
|
+
Athena.table_names()
|
|
64
|
+
Athena.column_names()
|
|
65
|
+
Athena.column_names(partition_cols_only=True)
|
|
66
|
+
|
|
67
|
+
return super().completion(state) | show_top10_completions_for_nesting() | SqlCompleter(
|
|
68
|
+
lambda: Athena.table_names(),
|
|
69
|
+
expandables={
|
|
70
|
+
'columns': lambda table: Athena.column_names(),
|
|
71
|
+
'partition_columns': lambda table: Athena.column_names(partition_cols_only=True)
|
|
72
|
+
},
|
|
73
|
+
variant=SqlVariant.ATHENA
|
|
74
|
+
).completions_for_nesting()
|
|
75
|
+
|
|
76
|
+
return {}
|
|
77
|
+
|
|
78
|
+
def cmd_list():
|
|
79
|
+
return [AuditRepairTables(), AuditRun(), ShowLast10(), ShowSlow10(), ShowTop10()]
|
|
80
|
+
|
|
81
|
+
def help(self, _: ReplState):
|
|
82
|
+
return f'[{Audit.COMMAND}] [<sql-statements>]\t run SQL queries on Authena audit database'
|
|
83
|
+
|
|
84
|
+
class AuditCommandHelper(click.Command):
|
|
85
|
+
def get_help(self, ctx: click.Context):
|
|
86
|
+
Command.intermediate_help(super().get_help(ctx), Audit.COMMAND, Audit.cmd_list(), show_cluster_help=False)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import concurrent
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
from adam.commands.command import Command
|
|
5
|
+
from adam.config import Config
|
|
6
|
+
from adam.repl_state import ReplState
|
|
7
|
+
from adam.utils import log, log2
|
|
8
|
+
from adam.utils_athena import Athena
|
|
9
|
+
from adam.utils_audits import AuditMeta, Audits
|
|
10
|
+
|
|
11
|
+
class AuditRepairTables(Command):
|
|
12
|
+
COMMAND = 'audit repair'
|
|
13
|
+
|
|
14
|
+
# the singleton pattern
|
|
15
|
+
def __new__(cls, *args, **kwargs):
|
|
16
|
+
if not hasattr(cls, 'instance'): cls.instance = super(AuditRepairTables, cls).__new__(cls)
|
|
17
|
+
|
|
18
|
+
return cls.instance
|
|
19
|
+
|
|
20
|
+
def __init__(self, successor: Command=None):
|
|
21
|
+
super().__init__(successor)
|
|
22
|
+
self.auto_repaired = False
|
|
23
|
+
|
|
24
|
+
def command(self):
|
|
25
|
+
return AuditRepairTables.COMMAND
|
|
26
|
+
|
|
27
|
+
def required(self):
|
|
28
|
+
return ReplState.L
|
|
29
|
+
|
|
30
|
+
def run(self, cmd: str, state: ReplState):
|
|
31
|
+
if not(args := self.args(cmd)):
|
|
32
|
+
return super().run(cmd, state)
|
|
33
|
+
|
|
34
|
+
state, args = self.apply_state(args, state)
|
|
35
|
+
if not self.validate_state(state):
|
|
36
|
+
return state
|
|
37
|
+
|
|
38
|
+
tables = Config().get('audit.athena.repair-partition-tables', 'audit').split(',')
|
|
39
|
+
if args:
|
|
40
|
+
tables = args
|
|
41
|
+
|
|
42
|
+
meta = Audits.get_meta()
|
|
43
|
+
self.repair(tables, meta)
|
|
44
|
+
|
|
45
|
+
return state
|
|
46
|
+
|
|
47
|
+
def completion(self, state: ReplState):
|
|
48
|
+
if state.device == ReplState.L:
|
|
49
|
+
if not self.auto_repaired:
|
|
50
|
+
if hours := Config().get('audit.athena.auto-repair.elapsed_hours', 12):
|
|
51
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=Config().get('audit.workers', 3)) as executor:
|
|
52
|
+
executor.submit(self.auto_repair, hours,)
|
|
53
|
+
|
|
54
|
+
return super().completion(state)
|
|
55
|
+
|
|
56
|
+
return {}
|
|
57
|
+
|
|
58
|
+
def auto_repair(self, hours: int):
|
|
59
|
+
self.auto_repaired = True
|
|
60
|
+
|
|
61
|
+
meta: AuditMeta = Audits.get_meta()
|
|
62
|
+
if meta.partitions_last_checked + hours * 60 * 60 < time.time():
|
|
63
|
+
tables = Config().get('audit.athena.repair-partition-tables', 'audit').split(',')
|
|
64
|
+
self.repair(tables, meta, show_sql=True)
|
|
65
|
+
log2(f'Audit tables have been auto-repaired.')
|
|
66
|
+
|
|
67
|
+
def repair(self, tables: list[str], meta: AuditMeta, show_sql = False):
|
|
68
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=Config().get('audit.workers', 3)) as executor:
|
|
69
|
+
for table in tables:
|
|
70
|
+
if show_sql:
|
|
71
|
+
log(f'MSCK REPAIR TABLE {table}')
|
|
72
|
+
|
|
73
|
+
executor.submit(Athena.run_query, f'MSCK REPAIR TABLE {table}', None,)
|
|
74
|
+
executor.submit(Audits.put_meta, Audits.PARTITIONS_ADDED, meta,)
|
|
75
|
+
|
|
76
|
+
def help(self, _: ReplState):
|
|
77
|
+
return f"{AuditRepairTables.COMMAND} \t run MSCK REPAIR command for new partition discovery"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import concurrent
|
|
2
|
+
|
|
3
|
+
from adam.commands.command import Command
|
|
4
|
+
from adam.config import Config
|
|
5
|
+
from adam.repl_state import ReplState
|
|
6
|
+
from adam.utils import log2
|
|
7
|
+
from adam.utils_athena import Athena
|
|
8
|
+
from adam.utils_audits import AuditMeta, Audits
|
|
9
|
+
|
|
10
|
+
class AuditRun(Command):
|
|
11
|
+
COMMAND = 'audit run'
|
|
12
|
+
|
|
13
|
+
# the singleton pattern
|
|
14
|
+
def __new__(cls, *args, **kwargs):
|
|
15
|
+
if not hasattr(cls, 'instance'): cls.instance = super(AuditRun, cls).__new__(cls)
|
|
16
|
+
|
|
17
|
+
return cls.instance
|
|
18
|
+
|
|
19
|
+
def __init__(self, successor: Command=None):
|
|
20
|
+
super().__init__(successor)
|
|
21
|
+
self.auto_repaired = False
|
|
22
|
+
|
|
23
|
+
def command(self):
|
|
24
|
+
return AuditRun.COMMAND
|
|
25
|
+
|
|
26
|
+
def required(self):
|
|
27
|
+
return ReplState.L
|
|
28
|
+
|
|
29
|
+
def run(self, cmd: str, state: ReplState):
|
|
30
|
+
if not(args := self.args(cmd)):
|
|
31
|
+
return super().run(cmd, state)
|
|
32
|
+
|
|
33
|
+
state, args = self.apply_state(args, state)
|
|
34
|
+
if not self.validate_state(state):
|
|
35
|
+
return state
|
|
36
|
+
|
|
37
|
+
meta: AuditMeta = Audits.get_meta()
|
|
38
|
+
clusters = Audits.find_new_clusters(meta.cluster_last_checked)
|
|
39
|
+
Audits.put_meta(Audits.ADD_CLUSTERS, meta, clusters=clusters)
|
|
40
|
+
if clusters:
|
|
41
|
+
log2(f'Added {len(clusters)} new clusters.')
|
|
42
|
+
tables = Config().get('audit.athena.repair-cluster-tables', 'cluster').split(',')
|
|
43
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=Config().get('audit.workers', 3)) as executor:
|
|
44
|
+
for table in tables:
|
|
45
|
+
executor.submit(Athena.run_query, f'MSCK REPAIR TABLE {table}', None,)
|
|
46
|
+
else:
|
|
47
|
+
log2(f'No new clusters were found.')
|
|
48
|
+
|
|
49
|
+
return state
|
|
50
|
+
|
|
51
|
+
def completion(self, state: ReplState):
|
|
52
|
+
if state.device == ReplState.L:
|
|
53
|
+
return super().completion(state)
|
|
54
|
+
|
|
55
|
+
return {}
|
|
56
|
+
|
|
57
|
+
def help(self, _: ReplState):
|
|
58
|
+
return f"{AuditRun.COMMAND} \t run"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from adam.commands.audit.utils_show_top10 import extract_limit_and_duration
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.repl_state import ReplState
|
|
4
|
+
from adam.utils import log2
|
|
5
|
+
from adam.utils_athena import Athena
|
|
6
|
+
from adam.utils_audits import Audits
|
|
7
|
+
|
|
8
|
+
class ShowLast10(Command):
|
|
9
|
+
COMMAND = 'show last'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(ShowLast10, 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 ShowLast10.COMMAND
|
|
22
|
+
|
|
23
|
+
def required(self):
|
|
24
|
+
return ReplState.L
|
|
25
|
+
|
|
26
|
+
def run(self, cmd: str, state: ReplState):
|
|
27
|
+
if not(args := self.args(cmd)):
|
|
28
|
+
return super().run(cmd, state)
|
|
29
|
+
|
|
30
|
+
state, args = self.apply_state(args, state)
|
|
31
|
+
if not self.validate_state(state):
|
|
32
|
+
return state
|
|
33
|
+
|
|
34
|
+
limit, date_condition = extract_limit_and_duration(args)
|
|
35
|
+
|
|
36
|
+
query = '\n '.join([
|
|
37
|
+
"SELECT * FROM audit",
|
|
38
|
+
f"WHERE drive <> 'z' and ({date_condition})",
|
|
39
|
+
f"ORDER BY ts DESC LIMIT {limit};"])
|
|
40
|
+
log2(query)
|
|
41
|
+
log2()
|
|
42
|
+
Athena.run_query(query)
|
|
43
|
+
|
|
44
|
+
return state
|
|
45
|
+
|
|
46
|
+
def completion(self, _: ReplState):
|
|
47
|
+
|
|
48
|
+
return {}
|
|
49
|
+
|
|
50
|
+
def help(self, _: ReplState):
|
|
51
|
+
return f'{ShowLast10.COMMAND} [limit]\t show last <limit> audit lines'
|