kaqing 2.0.89__py3-none-any.whl → 2.0.91__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/commands/bash.py CHANGED
@@ -38,8 +38,7 @@ class Bash(Command):
38
38
 
39
39
  return r
40
40
  else:
41
- a = ' '.join(args)
42
- command = f'bash -c "{a}"'
41
+ command = ' '.join(args)
43
42
 
44
43
  if state.pod:
45
44
  CassandraNodes.exec(state.pod, state.namespace, command, show_out=True)
@@ -65,15 +64,16 @@ class Bash(Command):
65
64
  if pwd := state.bash_session.pwd(state):
66
65
  args = ['cd', pwd, '&&'] + args
67
66
 
68
- a = ' '.join(args)
69
- command = f'bash -c "{a}"'
67
+ command = ' '.join(args)
70
68
 
71
69
  rs = []
72
70
 
73
71
  if state.pod:
74
- rs = [CassandraNodes.exec(state.pod, state.namespace, command, show_out=not session_just_created)]
72
+ rs = [CassandraNodes.exec(state.pod, state.namespace, command,
73
+ show_out=not session_just_created, shell='bash')]
75
74
  elif state.sts:
76
- rs = CassandraClusters.exec(state.sts, state.namespace, command, action='bash', show_out=not session_just_created)
75
+ rs = CassandraClusters.exec(state.sts, state.namespace, command, action='bash',
76
+ show_out=not session_just_created, shell='bash')
77
77
 
78
78
  return rs
79
79
 
adam/commands/cat.py ADDED
@@ -0,0 +1,54 @@
1
+ from adam.commands.command import Command
2
+ from adam.k8s_utils.cassandra_nodes import CassandraNodes
3
+ from adam.repl_state import ReplState, RequiredState
4
+ from adam.utils import log2
5
+
6
+ class Cat(Command):
7
+ COMMAND = 'cat'
8
+
9
+ # the singleton pattern
10
+ def __new__(cls, *args, **kwargs):
11
+ if not hasattr(cls, 'instance'): cls.instance = super(Cat, cls).__new__(cls)
12
+
13
+ return cls.instance
14
+
15
+ def __init__(self, successor: Command=None):
16
+ super().__init__(successor)
17
+
18
+ def command(self):
19
+ return Cat.COMMAND
20
+
21
+ def required(self):
22
+ return RequiredState.NAMESPACE
23
+
24
+ def run(self, cmd: str, state: ReplState):
25
+ if not(args := self.args(cmd)):
26
+ return super().run(cmd, state)
27
+
28
+ state, args = self.apply_state(args, state)
29
+ if not self.validate_state(state):
30
+ return state
31
+
32
+ if len(args) < 1:
33
+ if state.in_repl:
34
+ log2('File name is required.')
35
+ else:
36
+ log2('* File name is missing.')
37
+ Command.display_help()
38
+
39
+ return 'command-missing'
40
+
41
+ arg = args[0]
42
+ if '@' in arg:
43
+ path_and_pod = arg.split('@')
44
+ CassandraNodes.exec(path_and_pod[1], state.namespace, f'cat {path_and_pod[0]}')
45
+ else:
46
+ CassandraNodes.exec(state.pod, state.namespace, f'cat {arg}')
47
+
48
+ return state
49
+
50
+ def completion(self, state: ReplState):
51
+ return super().completion(state)
52
+
53
+ def help(self, _: ReplState):
54
+ return f'{Cat.COMMAND} <path>[@<pod>] \t print content of the file'
@@ -11,7 +11,10 @@ from adam.utils import log2
11
11
 
12
12
  @functools.lru_cache()
13
13
  def keyspaces(state: ReplState, on_any=False):
14
- Config().wait_log('Inspecting Cassandra Keyspaces...')
14
+ if state.pod:
15
+ Config().wait_log(f'Inspecting Cassandra Keyspaces on {state.pod}...')
16
+ else:
17
+ Config().wait_log(f'Inspecting Cassandra Keyspaces...')
15
18
 
16
19
  r: list[PodExecResult] = run_cql(state, 'describe keyspaces', show_out=False, on_any=on_any)
17
20
  if not r:
adam/commands/nodetool.py CHANGED
@@ -6,8 +6,10 @@ from adam.commands.nodetool_commands import NODETOOL_COMMANDS
6
6
  from adam.config import Config
7
7
  from adam.k8s_utils.cassandra_clusters import CassandraClusters
8
8
  from adam.k8s_utils.cassandra_nodes import CassandraNodes
9
+ from adam.pod_exec_result import PodExecResult
10
+ from adam.repl_session import ReplSession
9
11
  from adam.repl_state import ReplState, RequiredState
10
- from adam.utils import log
12
+ from adam.utils import log, random_alphanumeric
11
13
 
12
14
  class NodeTool(Command):
13
15
  COMMAND = 'nodetool'
@@ -39,9 +41,17 @@ class NodeTool(Command):
39
41
  command = f"nodetool -u {user} -pw {pw} {' '.join(args)}"
40
42
 
41
43
  if state.pod:
42
- return CassandraNodes.exec(state.pod, state.namespace, command, show_out=True)
44
+ results: PodExecResult = CassandraNodes.exec(state.pod, state.namespace, command, show_out=True)
45
+ if results and results.log_file and Config().get('repl.history.push-cat-remote-log-file', True):
46
+ ReplSession().prompt_session.history.append_string(f'cat {results.log_file}')
43
47
  elif state.sts:
44
- return CassandraClusters.exec(state.sts, state.namespace, command, action='nodetool', show_out=True)
48
+ results: list[PodExecResult] = CassandraClusters.exec(state.sts, state.namespace, command, action='nodetool', show_out=True)
49
+ if results and Config().get('repl.history.push-cat-remote-log-file', True):
50
+ for result in results:
51
+ if result.log_file:
52
+ ReplSession().prompt_session.history.append_string(f'cat {result.log_file}@{result.pod}')
53
+
54
+ return results
45
55
 
46
56
  def completion(self, state: ReplState):
47
57
  if state.pod or state.sts:
adam/embedded_params.py CHANGED
@@ -1,2 +1,2 @@
1
1
  def config():
2
- return {'app': {'console-endpoint': 'https://{host}/{env}/{app}/static/console/index.html', 'cr': {'cluster-regex': '(.*?-.*?)-.*', 'group': 'ops.c3.ai', 'v': 'v2', 'plural': 'c3cassandras'}, 'label': 'c3__app_id-0', 'login': {'admin-group': '{host}/C3.ClusterAdmin', 'ingress': '{app_id}-k8singr-appleader-001', 'timeout': 5, 'session-check-url': 'https://{host}/{env}/{app}/api/8/C3/userSessionToken', 'cache-creds': True, 'cache-username': True, 'url': 'https://{host}/{env}/{app}', 'another': "You're logged in to {has}. However, for this app, you need to log in to {need}.", 'token-server-url': 'http://localhost:{port}', 'password-max-length': 128}, 'strip': '0'}, 'audit': {'endpoint': 'https://4psvtaxlcb.execute-api.us-west-2.amazonaws.com/prod/', 'workers': 3, 'timeout': 10, 'log-audit-queries': False, 'athena': {'region': 'us-west-2', 'catalog': 'AwsDataCatalog', 'database': 'audit', 'tables': 'audit', 'output': 's3://s3.ops--audit/ddl/results'}}, 'bash': {'workers': 32}, 'cassandra': {'service-name': 'all-pods-service'}, 'cql': {'workers': 32, 'samples': 3, 'secret': {'cluster-regex': '(.*?-.*?)-.*', 'name': '{cluster}-superuser', 'password-item': 'password'}, 'alter-tables': {'excludes': 'system_auth,system_traces,reaper_db,system_distributed,system_views,system,system_schema,system_virtual_schema', 'gc-grace-periods': '3600,86400,864000,7776000', 'batching': True}}, 'checks': {'compactions-threshold': 250, 'cpu-busy-threshold': 98.0, 'cpu-threshold': 0.0, 'cassandra-data-path': '/c3/cassandra', 'root-disk-threshold': 50, 'cassandra-disk-threshold': 50, '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}'", 'snapshot-size-threshold': '40G', 'table-sizes-cmd': "ls -Al /c3/cassandra/data/data/ | awk '{print $9}' | sed 's/\\^r//g' | xargs -I {} du -sk /c3/cassandra/data/data/{}"}, 'get-host-id': {'workers': 32}, 'idps': {'ad': {'email-pattern': '.*@c3.ai', 'uri': 'https://login.microsoftonline.com/53ad779a-93e7-485c-ba20-ac8290d7252b/oauth2/v2.0/authorize?response_type=id_token&response_mode=form_post&client_id=00ff94a8-6b0a-4715-98e0-95490012d818&scope=openid+email+profile&redirect_uri=https%3A%2F%2Fplat.c3ci.cloud%2Fc3%2Fc3%2Foidc%2Flogin&nonce={nonce}&state=EMPTY', 'jwks-uri': 'https://login.microsoftonline.com/common/discovery/keys', 'contact': 'Please contact ted.tran@c3.ai.', 'whitelist-file': '/kaqing/members'}, 'okta': {'default': True, 'email-pattern': '.*@c3iot.com', 'uri': 'https://c3energy.okta.com/oauth2/v1/authorize?response_type=id_token&response_mode=form_post&client_id={client_id}&scope=openid+email+profile+groups&redirect_uri=https%3A%2F%2F{host}%2Fc3%2Fc3%2Foidc%2Flogin&nonce={nonce}&state=EMPTY', 'jwks-uri': 'https://c3energy.okta.com/oauth2/v1/keys'}}, 'issues': {'workers': 32}, 'logs': {'path': '/c3/cassandra/logs/system.log'}, 'medusa': {'restore-auto-complete': False}, 'nodetool': {'workers': 32, 'samples': 3, 'commands_in_line': 40}, 'pg': {'name-pattern': '^{namespace}.*-k8spg-.*', 'excludes': '.helm., -admin-secret', 'agent': {'name': 'ops-pg-agent', 'just-in-time': False, 'timeout': 86400, 'image': 'seanahnsf/kaqing'}, 'default-db': 'postgres', 'default-schema': 'postgres', 'secret': {'endpoint-key': 'postgres-db-endpoint', 'port-key': 'postgres-db-port', 'username-key': 'postgres-admin-username', 'password-key': 'postgres-admin-password'}}, 'pod': {'name': 'ops', 'image': 'seanahnsf/kaqing-cloud', 'sa': {'name': 'ops', 'proto': 'c3', 'additional-cluster-roles': 'c3aiops-k8ssandra-operator'}, 'label-selector': 'run=ops'}, 'preview': {'rows': 10}, 'processes': {'columns': 'pod,cpu,mem', 'header': 'POD_NAME,CPU,MEM/LIMIT'}, 'reaper': {'service-name': 'reaper-service', 'port-forward': {'timeout': 86400, 'local-port': 9001}, 'abort-runs-batch': 10, 'show-runs-batch': 100, 'pod': {'cluster-regex': '(.*?-.*?-.*?-.*?)-.*', 'label-selector': 'k8ssandra.io/reaper={cluster}-reaper'}, 'secret': {'cluster-regex': '(.*?-.*?)-.*', 'name': '{cluster}-reaper-ui', 'password-item': 'password'}}, 'repair': {'log-path': '/home/cassrepair/logs/', 'image': 'ci-registry.c3iot.io/cloudops/cassrepair:2.0.14', 'secret': 'ciregistryc3iotio', 'env': {'interval': 24, 'timeout': 60, 'pr': False, 'runs': 1}}, 'repl': {'start-drive': 'a', 'auto-enter-app': 'c3/c3', 'auto-enter-only-cluster': True}, 'status': {'columns': 'status,address,load,tokens,owns,host_id,gossip,compactions', 'header': '--,Address,Load,Tokens,Owns,Host ID,GOSSIP,COMPACTIONS'}, 'storage': {'columns': 'pod,volume_root,volume_cassandra,snapshots,data,compactions', 'header': 'POD_NAME,VOLUME /,VOLUME CASS,SNAPSHOTS,DATA,COMPACTIONS'}, 'watch': {'auto': 'rollout', 'timeout': 3600, 'interval': 10}, 'debug': False, 'debugs': {'timings': False, 'exit-on-error': False, 'show-parallelism': False}}
2
+ return {'app': {'console-endpoint': 'https://{host}/{env}/{app}/static/console/index.html', 'cr': {'cluster-regex': '(.*?-.*?)-.*', 'group': 'ops.c3.ai', 'v': 'v2', 'plural': 'c3cassandras'}, 'label': 'c3__app_id-0', 'login': {'admin-group': '{host}/C3.ClusterAdmin', 'ingress': '{app_id}-k8singr-appleader-001', 'timeout': 5, 'session-check-url': 'https://{host}/{env}/{app}/api/8/C3/userSessionToken', 'cache-creds': True, 'cache-username': True, 'url': 'https://{host}/{env}/{app}', 'another': "You're logged in to {has}. However, for this app, you need to log in to {need}.", 'token-server-url': 'http://localhost:{port}', 'password-max-length': 128}, 'strip': '0'}, 'audit': {'endpoint': 'https://4psvtaxlcb.execute-api.us-west-2.amazonaws.com/prod/', 'workers': 3, 'timeout': 10, 'log-audit-queries': False, 'athena': {'region': 'us-west-2', 'catalog': 'AwsDataCatalog', 'database': 'audit', 'tables': 'audit', 'output': 's3://s3.ops--audit/ddl/results'}}, 'bash': {'workers': 32}, 'cassandra': {'service-name': 'all-pods-service'}, 'cql': {'workers': 32, 'samples': 3, 'secret': {'cluster-regex': '(.*?-.*?)-.*', 'name': '{cluster}-superuser', 'password-item': 'password'}, 'alter-tables': {'excludes': 'system_auth,system_traces,reaper_db,system_distributed,system_views,system,system_schema,system_virtual_schema', 'gc-grace-periods': '3600,86400,864000,7776000', 'batching': True}}, 'checks': {'compactions-threshold': 250, 'cpu-busy-threshold': 98.0, 'cpu-threshold': 0.0, 'cassandra-data-path': '/c3/cassandra', 'root-disk-threshold': 50, 'cassandra-disk-threshold': 50, '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}'", 'snapshot-size-threshold': '40G', 'table-sizes-cmd': "ls -Al /c3/cassandra/data/data/ | awk '{print $9}' | sed 's/\\^r//g' | xargs -I {} du -sk /c3/cassandra/data/data/{}"}, 'get-host-id': {'workers': 32}, 'idps': {'ad': {'email-pattern': '.*@c3.ai', 'uri': 'https://login.microsoftonline.com/53ad779a-93e7-485c-ba20-ac8290d7252b/oauth2/v2.0/authorize?response_type=id_token&response_mode=form_post&client_id=00ff94a8-6b0a-4715-98e0-95490012d818&scope=openid+email+profile&redirect_uri=https%3A%2F%2Fplat.c3ci.cloud%2Fc3%2Fc3%2Foidc%2Flogin&nonce={nonce}&state=EMPTY', 'jwks-uri': 'https://login.microsoftonline.com/common/discovery/keys', 'contact': 'Please contact ted.tran@c3.ai.', 'whitelist-file': '/kaqing/members'}, 'okta': {'default': True, 'email-pattern': '.*@c3iot.com', 'uri': 'https://c3energy.okta.com/oauth2/v1/authorize?response_type=id_token&response_mode=form_post&client_id={client_id}&scope=openid+email+profile+groups&redirect_uri=https%3A%2F%2F{host}%2Fc3%2Fc3%2Foidc%2Flogin&nonce={nonce}&state=EMPTY', 'jwks-uri': 'https://c3energy.okta.com/oauth2/v1/keys'}}, 'issues': {'workers': 32}, 'logs': {'path': '/c3/cassandra/logs/system.log'}, 'medusa': {'restore-auto-complete': False}, 'nodetool': {'workers': 32, 'samples': 3, 'commands_in_line': 40}, 'pg': {'name-pattern': '^{namespace}.*-k8spg-.*', 'excludes': '.helm., -admin-secret', 'agent': {'name': 'ops-pg-agent', 'just-in-time': False, 'timeout': 86400, 'image': 'seanahnsf/kaqing'}, 'default-db': 'postgres', 'default-schema': 'postgres', 'secret': {'endpoint-key': 'postgres-db-endpoint', 'port-key': 'postgres-db-port', 'username-key': 'postgres-admin-username', 'password-key': 'postgres-admin-password'}}, 'pod': {'name': 'ops', 'image': 'seanahnsf/kaqing-cloud', 'sa': {'name': 'ops', 'proto': 'c3', 'additional-cluster-roles': 'c3aiops-k8ssandra-operator'}, 'label-selector': 'run=ops'}, 'preview': {'rows': 10}, 'processes': {'columns': 'pod,cpu,mem', 'header': 'POD_NAME,CPU,MEM/LIMIT'}, 'reaper': {'service-name': 'reaper-service', 'port-forward': {'timeout': 86400, 'local-port': 9001}, 'abort-runs-batch': 10, 'show-runs-batch': 100, 'pod': {'cluster-regex': '(.*?-.*?-.*?-.*?)-.*', 'label-selector': 'k8ssandra.io/reaper={cluster}-reaper'}, 'secret': {'cluster-regex': '(.*?-.*?)-.*', 'name': '{cluster}-reaper-ui', 'password-item': 'password'}}, 'repair': {'log-path': '/home/cassrepair/logs/', 'image': 'ci-registry.c3iot.io/cloudops/cassrepair:2.0.14', 'secret': 'ciregistryc3iotio', 'env': {'interval': 24, 'timeout': 60, 'pr': False, 'runs': 1}}, 'repl': {'start-drive': 'a', 'auto-enter-app': 'c3/c3', 'auto-enter-only-cluster': 'cluster', 'history': {'push-cat-remote-log-file': True}}, 'status': {'columns': 'status,address,load,tokens,owns,host_id,gossip,compactions', 'header': '--,Address,Load,Tokens,Owns,Host ID,GOSSIP,COMPACTIONS'}, 'storage': {'columns': 'pod,volume_root,volume_cassandra,snapshots,data,compactions', 'header': 'POD_NAME,VOLUME /,VOLUME CASS,SNAPSHOTS,DATA,COMPACTIONS'}, 'watch': {'auto': 'rollout', 'timeout': 3600, 'interval': 10}, 'debug': False, 'debugs': {'timings': False, 'exit-on-error': False, 'show-parallelism': False}}
@@ -1,9 +1,7 @@
1
- from collections.abc import Callable
2
1
  from concurrent.futures import ThreadPoolExecutor
3
2
  import sys
4
3
  from typing import TypeVar
5
4
 
6
- from adam.config import Config
7
5
  from adam.k8s_utils.cassandra_nodes import CassandraNodes
8
6
  from adam.pod_exec_result import PodExecResult
9
7
  from adam.utils import log2
@@ -15,10 +13,11 @@ T = TypeVar('T')
15
13
 
16
14
  # utility collection on cassandra clusters; methods are all static
17
15
  class CassandraClusters:
18
- def exec(statefulset: str, namespace: str, command: str, action: str = 'action', max_workers=0, show_out=True, on_any = False) -> list[PodExecResult]:
16
+ def exec(statefulset: str, namespace: str, command: str, action: str = 'action',
17
+ max_workers=0, show_out=True, on_any = False, shell = '/bin/sh') -> list[PodExecResult]:
19
18
  def body(executor: ThreadPoolExecutor, pod: str, namespace: str, show_out: bool):
20
19
  if executor:
21
- return executor.submit(CassandraNodes.exec, pod, namespace, command, False, False,)
20
+ return executor.submit(CassandraNodes.exec, pod, namespace, command, False, False, shell)
22
21
 
23
22
  return CassandraNodes.exec(pod, namespace, command, show_out=show_out)
24
23
 
@@ -5,8 +5,8 @@ from adam.pod_exec_result import PodExecResult
5
5
 
6
6
  # utility collection on cassandra nodes; methods are all static
7
7
  class CassandraNodes:
8
- def exec(pod_name: str, namespace: str, command: str, show_out = True, throw_err = False) -> PodExecResult:
9
- return Pods.exec(pod_name, "cassandra", namespace, command, show_out, throw_err)
8
+ def exec(pod_name: str, namespace: str, command: str, show_out = True, throw_err = False, shell = '/bin/sh') -> PodExecResult:
9
+ return Pods.exec(pod_name, "cassandra", namespace, command, show_out = show_out, throw_err = throw_err, shell = shell)
10
10
 
11
11
  def get_host_id(pod_name: str, ns: str):
12
12
  try:
adam/k8s_utils/pods.py CHANGED
@@ -10,7 +10,7 @@ from kubernetes.stream.ws_client import ERROR_CHANNEL
10
10
  from adam.config import Config
11
11
  from adam.k8s_utils.volumes import ConfigMapMount
12
12
  from adam.pod_exec_result import PodExecResult
13
- from adam.utils import elapsed_time, log2
13
+ from adam.utils import elapsed_time, log2, random_alphanumeric
14
14
  from .kube_context import KubeContext
15
15
 
16
16
  T = TypeVar('T')
@@ -93,16 +93,26 @@ class Pods:
93
93
 
94
94
  return results
95
95
 
96
- def exec(pod_name: str, container: str, namespace: str, command: str, show_out = True, throw_err = False, interaction: Callable[[any, list[str]], any] = None):
96
+ def exec(pod_name: str, container: str, namespace: str, command: str, show_out = True, throw_err = False, shell = '/bin/sh',
97
+ interaction: Callable[[any, list[str]], any] = None):
97
98
  if _TEST_POD_EXEC_OUTS:
98
99
  return _TEST_POD_EXEC_OUTS
99
100
 
100
101
  show_out = KubeContext.show_out(show_out)
101
102
 
102
103
  api = client.CoreV1Api()
103
-
104
- exec_command = ["/bin/sh", "-c", command]
105
- k_command = f'kubectl exec {pod_name} -c {container} -n {namespace} -- {command}'
104
+ log_file = None
105
+
106
+ tty = True
107
+ exec_command = [shell, '-c', command]
108
+ if command.endswith(' &'):
109
+ log_file = f'/tmp/qing-{random_alphanumeric(6)}.log'
110
+ command = f"nohup {command.strip(' &')} > {log_file} 2>&1 &"
111
+ exec_command = [shell, '-c', command]
112
+ # should be false for starting a backgroud process
113
+ tty = False
114
+
115
+ k_command = f'kubectl exec {pod_name} -c {container} -n {namespace} -- {shell} -c "{command}"'
106
116
  if show_out:
107
117
  print(k_command)
108
118
 
@@ -115,7 +125,7 @@ class Pods:
115
125
  stderr=True,
116
126
  stdin=True,
117
127
  stdout=True,
118
- tty=True,
128
+ tty=tty,
119
129
  _preload_content=False,
120
130
  )
121
131
 
@@ -140,7 +150,7 @@ class Pods:
140
150
  try:
141
151
  # get the exit code from server
142
152
  error_output = resp.read_channel(ERROR_CHANNEL)
143
- except Exception:
153
+ except Exception as e:
144
154
  pass
145
155
  except Exception as e:
146
156
  if throw_err:
@@ -150,7 +160,7 @@ class Pods:
150
160
  finally:
151
161
  resp.close()
152
162
 
153
- return PodExecResult("".join(stdout), "".join(stderr), k_command, error_output)
163
+ return PodExecResult("".join(stdout), "".join(stderr), k_command, error_output, pod=pod_name, log_file=log_file)
154
164
 
155
165
  def get_container(namespace: str, pod_name: str, container_name: str):
156
166
  pod = Pods.get(namespace, pod_name)
adam/k8s_utils/secrets.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import base64
2
+ import functools
2
3
  import re
3
4
  from typing import cast
4
5
  from kubernetes import client
@@ -9,6 +10,7 @@ from adam.utils import log2
9
10
 
10
11
  # utility collection on secrets; methods are all static
11
12
  class Secrets:
13
+ @functools.lru_cache()
12
14
  def list_secrets(namespace: str = None, name_pattern: str = None):
13
15
  Config().wait_log('Inspecting Cassandra Instances...')
14
16
 
adam/pod_exec_result.py CHANGED
@@ -15,12 +15,14 @@ class PodExecResult:
15
15
  # ]
16
16
  # }
17
17
  # }
18
- def __init__(self, stdout: str, stderr: str, command: str = None, error_output: str = None):
18
+ def __init__(self, stdout: str, stderr: str, command: str = None, error_output: str = None, pod: str = None, log_file: str = None):
19
19
  self.stdout: str = stdout
20
20
  self.stderr: str = stderr
21
21
  self.command: str = command
22
22
  if error_output:
23
23
  self.error = yaml.safe_load(error_output)
24
+ self.pod = pod
25
+ self.log_file = log_file
24
26
 
25
27
  def exit_code(self) -> int:
26
28
  code = 0
adam/repl.py CHANGED
@@ -69,13 +69,16 @@ def enter_repl(state: ReplState):
69
69
  Log.log2(f'kaqing {__version__}')
70
70
 
71
71
  if state.device == ReplState.C:
72
+ auto_enter = Config().get('repl.auto-enter-only-cluster', 'cluster')
72
73
  ss = StatefulSets.list_sts_name_and_ns()
73
74
  if not ss:
74
75
  raise Exception("no Cassandra clusters found")
75
- elif not state.sts and len(ss) == 1 and Config().get('repl.auto-enter-only-cluster', True):
76
+ elif not state.sts and len(ss) == 1 and auto_enter in ['cluster', 'first-pod']:
76
77
  cluster = ss[0]
77
78
  state.sts = cluster[0]
78
79
  state.namespace = cluster[1]
80
+ if auto_enter == 'first-pod':
81
+ state.pod = f'{state.sts}-0'
79
82
  if KubeContext().in_cluster_namespace:
80
83
  Config().wait_log(f'Moving to the only Cassandra cluster: {state.sts}...')
81
84
  else:
adam/repl_commands.py CHANGED
@@ -3,6 +3,7 @@ from adam.commands.app import App
3
3
  from adam.commands.app_ping import AppPing
4
4
  from adam.commands.audit.audit import Audit
5
5
  from adam.commands.audit.audit_repair_tables import AuditRepairTables
6
+ from adam.commands.cat import Cat
6
7
  from adam.commands.deploy.code_start import CodeStart
7
8
  from adam.commands.deploy.code_stop import CodeStop
8
9
  from adam.commands.deploy.deploy import Deploy
@@ -79,7 +80,7 @@ class ReplCommands:
79
80
  return deduped
80
81
 
81
82
  def navigation() -> list[Command]:
82
- return [Ls(), PreviewTable(), DeviceApp(), DevicePostgres(), DeviceCass(), DeviceAuditLog(), Cd(), Pwd(), ClipboardCopy(),
83
+ return [Ls(), PreviewTable(), DeviceApp(), DevicePostgres(), DeviceCass(), DeviceAuditLog(), Cd(), Pwd(), Cat(), ClipboardCopy(),
83
84
  GetParam(), SetParam(), ShowParams(), ShowKubectlCommands(), ShowLogin(), ShowAdam(), ShowHost()]
84
85
 
85
86
  def cassandra_check() -> list[Command]:
adam/version.py CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- __version__ = "2.0.89" #: the working version
4
+ __version__ = "2.0.91" #: the working version
5
5
  __release__ = "1.0.0" #: the release version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kaqing
3
- Version: 2.0.89
3
+ Version: 2.0.91
4
4
  Summary: UNKNOWN
5
5
  Home-page: UNKNOWN
6
6
  License: UNKNOWN
@@ -6,17 +6,17 @@ adam/cli.py,sha256=03pIZdomAu7IL-GSP6Eun_PKwwISShRAmfx6eVRPGC0,458
6
6
  adam/cli_group.py,sha256=W3zy1BghCtVcEXizq8fBH-93ZRVVwgAyGPzy0sHno1Y,593
7
7
  adam/config.py,sha256=hDxd86MbKVVKoHhTT077L3YRKYcr0i6xVADLlnoE684,2818
8
8
  adam/embedded_apps.py,sha256=lKPx63mKzJbNmwz0rgL4gF76M9fDGxraYTtNAIGnZ_s,419
9
- adam/embedded_params.py,sha256=FRG1eCyTHX5ynyt3Q8gc3EF2FeelBhW_mh94SSc6PXE,4878
9
+ adam/embedded_params.py,sha256=LObTQtC5A6sfRPjHNNcJZr2GUVYoQ1TNAR-zPmQoZRc,4930
10
10
  adam/log.py,sha256=gg5DK52wLPc9cjykeh0WFHyAk1qI3HEpGaAK8W2dzXY,1146
11
- adam/pod_exec_result.py,sha256=nq0xnCNOpUGBSijGF0H-YNrwBc9vUQs4DkvLMIFS5LQ,951
12
- adam/repl.py,sha256=xDG3l76O4LXyWhobmyvOd-Txs9ND-pQrTB0I9uhMU1I,9407
13
- adam/repl_commands.py,sha256=1AFE8AJoyQdJd0tlcwtMnwMjV5G7jL9MDkxJZxdo150,4963
11
+ adam/pod_exec_result.py,sha256=WBXJSvxzXp9TfsfXeHtIvgz8GvfMAAcH5M03GISLqzw,1046
12
+ adam/repl.py,sha256=G2d9cMZfYQ7BMABCNXgc4RSdRhAPBhS5h3hFENTGRVM,9559
13
+ adam/repl_commands.py,sha256=yJVVBAememAXU6NAIYOiOC7qwNsm3m1OYjoBlLKwG3Y,5004
14
14
  adam/repl_session.py,sha256=uIogcvWBh7wd8QQ-p_JgLsyJ8YJgINw5vOd6JIsd7Vo,472
15
15
  adam/repl_state.py,sha256=dXyGlWXcSsfCjrYwMhU44PVn_oThSZ8dhJ5HCVE8-qU,8743
16
16
  adam/utils.py,sha256=sbsNZP3qGJtb6fXCa4dDXHry5ay9ev583cCZIQzy07s,7382
17
17
  adam/utils_athena.py,sha256=tU6Arg4g7eKV6ei9SLgakOJJqxKgSCsII-7a68OI7_g,3199
18
18
  adam/utils_net.py,sha256=65fhBnWMCkhGtyHqz95qcHaCo35q-WX1RBkkXG8dKpI,416
19
- adam/version.py,sha256=H3TCYnY3G88xMwcXM90yFCb-hqjnB-GoHYaNQZENX38,139
19
+ adam/version.py,sha256=TE_FtcdQhHRvd4huualymKiwOVRcNwzqlVHBnhLSyV8,139
20
20
  adam/checks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  adam/checks/check.py,sha256=Qopr3huYcMu2bzQgb99dEUYjFzkjKHRI76S6KA9b9Rk,702
22
22
  adam/checks/check_context.py,sha256=FEHkQ32jY1EDopQ2uYWqy9v7aEEX1orLpJWhopwAlh4,402
@@ -52,7 +52,8 @@ adam/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
52
  adam/commands/alter_tables.py,sha256=Q5vXHE4_1_6v6wtYwqST7_QwpXINb1xq0Sm448Z2Y7Q,3582
53
53
  adam/commands/app.py,sha256=7alV8wK801t67_rUe6EmhtHJTl-6K7fGCm6Uz1dDgpM,1963
54
54
  adam/commands/app_ping.py,sha256=Xk7cfefphXM2w-UvpnhNUTZ3BU38f0deehUb2FEyLCI,1337
55
- adam/commands/bash.py,sha256=1O9cCl9JHQdttqNAgdB44rO0NjCqHzHv4psAEQMJcjw,2714
55
+ adam/commands/bash.py,sha256=rWYY_dZ0ZaEsAHLVorCD5gPckjkKWH-o6dT4VmKDzmA,2758
56
+ adam/commands/cat.py,sha256=YaefSfLKYJqd8j1oWjU8QWwAtcyl2I93e2NeMeMKud0,1590
56
57
  adam/commands/cd.py,sha256=GyNyJnbxX7afrk7xwvXDhEtSdWnAgnz0dpDJXO2dO7w,4728
57
58
  adam/commands/check.py,sha256=853FPfgTMGxQXI_5UaPAtzaSWB_BvEVm48EkJhsHe4w,2181
58
59
  adam/commands/cli_commands.py,sha256=PEEyrG9yz7RAEZwHbbuFpyE3fVi8vrIWbr0d1H0Gp9o,3620
@@ -67,7 +68,7 @@ adam/commands/issues.py,sha256=VS-PC7e-2lywsa-lbmoUX8IY77OPGzFudwbw1g8XmQc,2599
67
68
  adam/commands/login.py,sha256=bj95WWIF7mJDJhnyS9T8xvaZUGL37dj7GlH8TgmODbk,1877
68
69
  adam/commands/logs.py,sha256=T-O9DYXmWEm4G1I5SM6MwyeRwq2aT-WMqNW0XA2MWmo,1165
69
70
  adam/commands/ls.py,sha256=aNBIoUUCFxWMJ9O6IV6qbw5XRHmaQqOD6dgjMf9EWkU,5766
70
- adam/commands/nodetool.py,sha256=HV9yDzMhRjS4lw6UfV7Hc1pcmeSx5a1jU6cAEKSZ1Bg,2334
71
+ adam/commands/nodetool.py,sha256=g_ADdVOM0VlYEsD5oa0nAylffkRz6jwkrShA9uKPU1s,2994
71
72
  adam/commands/nodetool_commands.py,sha256=5IgWC3rmeDD1cgwqQjiiWzi-wJpJ3n_8pAzz_9phXuk,2635
72
73
  adam/commands/param_get.py,sha256=kPAAppK2T0tEFRnSIVFLDPIIGHhgLA7drJhn8TRyvvE,1305
73
74
  adam/commands/param_set.py,sha256=QDIuqfU80aWCB16OK49yf7XRaRTWwiLkwMsJuVikq9I,1271
@@ -84,7 +85,7 @@ adam/commands/audit/audit_repair_tables.py,sha256=5Glsy29md3KH_4_smuVBeu6c4zygIC
84
85
  adam/commands/cql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
85
86
  adam/commands/cql/cql_completions.py,sha256=dXe51NTWEJis76587IWSn9Av-cjC0J6KMaxlBKfF4wM,411
86
87
  adam/commands/cql/cql_table_completer.py,sha256=Tth6lmZ1eCEbJeAVZojTx594ttQeeVf-OjhhkSLyRnI,312
87
- adam/commands/cql/cql_utils.py,sha256=q5hzAUVh7h8iVVH2s0M4E76zWqaMUDXULMn412mfHII,3893
88
+ adam/commands/cql/cql_utils.py,sha256=yEH5QTB-PvPxO7Y5Ky800mAvLVjAcIHM7mOsAY7Hkqo,4005
88
89
  adam/commands/cql/cqlsh.py,sha256=qEQufaDVi9FXkvruum6OHQDfLX01DVWVDnWsAjyCZYQ,2661
89
90
  adam/commands/deploy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
90
91
  adam/commands/deploy/code_start.py,sha256=-iH8HThTNM83IfBxT_LqTByuHVatV9d-Il4OYOfrwLI,1370
@@ -155,16 +156,16 @@ adam/commands/show/show_processes.py,sha256=jAesWDD_l0T6ql6LawnGpev-Glz21tFkegtC
155
156
  adam/commands/show/show_repairs.py,sha256=qpbyeRyLPyBWmn_4yxFu8KIjfd58HGry5pvqNyMwn5I,1477
156
157
  adam/commands/show/show_storage.py,sha256=LUTkH_qnc1d9s4jKsps8jhB4rkUuN7ifMlHSwFqd8_c,1837
157
158
  adam/k8s_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
158
- adam/k8s_utils/cassandra_clusters.py,sha256=CBn2GgN2N9voY04gSnZxgXttDxexgvEnSE_cXnHD4fs,1430
159
- adam/k8s_utils/cassandra_nodes.py,sha256=Fr0PxjaVxkIhNMxzpNDD4bNeJ4xSE66pVHMbpBd8mzU,1119
159
+ adam/k8s_utils/cassandra_clusters.py,sha256=JAUTix4fxDn3AJ64Nayxs7QVTu4lZhJ5-7G8h-ufJvs,1400
160
+ adam/k8s_utils/cassandra_nodes.py,sha256=R1sBxetbA2zQlVBWgfRnvF8onQ1Ug3h3yrHl_K_pJR4,1176
160
161
  adam/k8s_utils/config_maps.py,sha256=vc9A-2D1-1mindCMFL1wuysDOXb0RCl4BdjC6B6usXI,1194
161
162
  adam/k8s_utils/custom_resources.py,sha256=cIeaZRQET2DelTGU2f5QsMckh7TddPpWZDFeNK3txeQ,7647
162
163
  adam/k8s_utils/deployment.py,sha256=3oZPfPgQfqtAQaxEFL4daUfRSieRAhysmuaWMzUYgXk,2921
163
164
  adam/k8s_utils/ingresses.py,sha256=ul3Z6fDGc_Cxcn-ExP0vXhZatoShCUZFtpwtCY4Qx7o,3460
164
165
  adam/k8s_utils/jobs.py,sha256=gJpBpjcZ_FlkWJJIlavbHC_bqdmvv-GMVo8UZVh0sOQ,2610
165
166
  adam/k8s_utils/kube_context.py,sha256=xJF_72vUJu-X9MpIYzOIfnj7KEWU7a_sLBR-H3994Y0,3311
166
- adam/k8s_utils/pods.py,sha256=ljn5tB-j8bdof6X_YWS9Hf5cjAzwmYw61I9_0bwIjCc,10540
167
- adam/k8s_utils/secrets.py,sha256=V8SAsGwIfJCrbARf6gtbsCNKeqobu_x8hdJ-ckNyr1M,2369
167
+ adam/k8s_utils/pods.py,sha256=w8KyYryRi7LHjRP1yCxYYawe4zkmwRffg6uJgtZTTEw,10993
168
+ adam/k8s_utils/secrets.py,sha256=tBSKLknHlwdwyTzqvtJ2YS-y9x4gvW57Ug9sOkK_U50,2413
168
169
  adam/k8s_utils/service_accounts.py,sha256=v2oQSqCrNvt2uRnKlNwR3fjtpUG7oF5nqgzEB7NnT-U,6349
169
170
  adam/k8s_utils/services.py,sha256=EOJJGACVbbRvu5T3rMKqIJqgYic1_MSJ17EA0TJ6UOk,3156
170
171
  adam/k8s_utils/statefulsets.py,sha256=5g7KxGRHgEewT8rnZneDTaJDylUf-dHH2edWJEoorr8,4667
@@ -183,8 +184,8 @@ adam/sso/idp.py,sha256=fvcwUw_URTgsO6ySaqTIw0zQT2qRO1IPSGhf6rPtybo,5804
183
184
  adam/sso/idp_login.py,sha256=QAtCUeDTVWliJy40RK_oac8Vgybr13xH8wzeBoxPaa8,1754
184
185
  adam/sso/idp_session.py,sha256=9BUHNRf70u4rVKrVY1HKPOEmOviXvkjam8WJxmXSKIM,1735
185
186
  adam/sso/sso_config.py,sha256=5N8WZgIJQBtHUy585XLRWKjpU87_v6QluyNK9E27D5s,2459
186
- kaqing-2.0.89.dist-info/METADATA,sha256=VB9GiTJychvJTxeTQsPrEVwZs3WFpFkfzbWrXa1qXuQ,132
187
- kaqing-2.0.89.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
188
- kaqing-2.0.89.dist-info/entry_points.txt,sha256=SkzhuQJUWsXOzHeZ5TgQ2c3_g53UGK23zzJU_JTZOZI,39
189
- kaqing-2.0.89.dist-info/top_level.txt,sha256=8_2PZkwBb-xDcnc8a2rAbQeJhXKXskc7zTP7pSPa1fw,5
190
- kaqing-2.0.89.dist-info/RECORD,,
187
+ kaqing-2.0.91.dist-info/METADATA,sha256=yagJcxO7gKMvac3lZBLG4NkmHwH5tlhragoKQfrm7xk,132
188
+ kaqing-2.0.91.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
189
+ kaqing-2.0.91.dist-info/entry_points.txt,sha256=SkzhuQJUWsXOzHeZ5TgQ2c3_g53UGK23zzJU_JTZOZI,39
190
+ kaqing-2.0.91.dist-info/top_level.txt,sha256=8_2PZkwBb-xDcnc8a2rAbQeJhXKXskc7zTP7pSPa1fw,5
191
+ kaqing-2.0.91.dist-info/RECORD,,