canonical / jhack

Chock-full of Juju hackery.
Apache License 2.0
48 stars 23 forks source link

jhack fire failed on MAAS in non-destructive mode (the same error for `version`) #162

Closed taurus-forever closed 1 month ago

taurus-forever commented 1 month ago

Hi,

jhack version :

tracking:     latest/edge
refresh-date: today at 12:28 CEST
channels:
  latest/stable:    0.4.0.8 2024-05-15 (306) 114MB -
  latest/candidate: 0.4.1.3 2024-05-15 (343) 114MB -
  latest/beta:      0.4.1.3 2024-05-15 (343) 114MB -
  latest/edge:      0.4.1.7 2024-05-30 (353) 114MB -
installed:          0.4.1.7            (353) 114MB -

After deploying PostgreSQL on MAAS, I cannot fire update-status:

ubuntu@maas-test:~$ jhack fire postgresql/0 update-status
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /snap/jhack/353/lib/python3.8/site-packages/jhack/utils/simulate_event.py:503 in simulate_event  │
│                                                                                                  │
│   500 │                                                                                          │
│   501 │   Especially useful in combination with jhack charm sync and/or debug-code/debug-hooks   │
│   502 │   """                                                                                    │
│ ❱ 503 │   return _simulate_event(                                                                │
│   504 │   │   target,                                                                            │
│   505 │   │   event,                                                                             │
│   506 │   │   relation_remote=relation_remote,                                                   │
│                                                                                                  │
│ ╭───────────── locals ──────────────╮                                                            │
│ │         dry_run = None            │                                                            │
│ │    env_override = []              │                                                            │
│ │           event = 'update-status' │                                                            │
│ │           model = None            │                                                            │
│ │       notice_id = None            │                                                            │
│ │        parallel = None            │                                                            │
│ │     relation_id = None            │                                                            │
│ │ relation_remote = None            │                                                            │
│ │          secret = None            │                                                            │
│ │     show_output = True            │                                                            │
│ │          target = 'postgresql/0'  │                                                            │
│ ╰───────────────────────────────────╯                                                            │
│                                                                                                  │
│ /snap/jhack/353/lib/python3.8/site-packages/jhack/utils/simulate_event.py:390 in _simulate_event │
│                                                                                                  │
│   387 │   │   print(f"would run: \n\t {cmdlist}")                                                │
│   388 │   │   return                                                                             │
│   389 │                                                                                          │
│ ❱ 390 │   check_destructive_commands_allowed("fire", cmdlist)                                    │
│   391 │                                                                                          │
│   392 │   _fire = partial(                                                                       │
│   393 │   │   _juju_exec_cmd,                                                                    │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │               cmdlist = 'juju ssh postgresql/0 sudo /usr/bin/juju-exec -u postgresql/0       │ │
│ │                         JUJU_DISPATCH_PATH'+86                                               │ │
│ │                  cmds = (                                                                    │ │
│ │                         │   'juju ssh postgresql/0 sudo /usr/bin/juju-exec -u postgresql/0   │ │
│ │                         JUJU_DISPATCH_PATH'+86,                                              │ │
│ │                         )                                                                    │ │
│ │               dry_run = None                                                                 │ │
│ │         emit_juju_log = True                                                                 │ │
│ │          env_override = []                                                                   │ │
│ │                 event = 'update-status'                                                      │ │
│ │                 model = None                                                                 │ │
│ │             notice_id = None                                                                 │ │
│ │     operator_dispatch = False                                                                │ │
│ │              parallel = None                                                                 │ │
│ │ print_captured_stderr = True                                                                 │ │
│ │ print_captured_stdout = True                                                                 │ │
│ │           relation_id = None                                                                 │ │
│ │       relation_remote = None                                                                 │ │
│ │    secret_id_or_label = None                                                                 │ │
│ │                target = 'postgresql/0'                                                       │ │
│ │               targets = ['postgresql/0']                                                     │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /snap/jhack/353/lib/python3.8/site-packages/jhack/conf/conf.py:138 in                            │
│ check_destructive_commands_allowed                                                               │
│                                                                                                  │
│   135 │   │   │   "This is *for your own good*. "                                                │
│   136 │   │   )                                                                                  │
│   137 │   │   closure = (                                                                        │
│ ❱ 138 │   │   │   "Or, if you want to allow destructive mode just this once, run "               │
│   139 │   │   │   f"`JHACK_PROFILE=devmode {' '.join(sys.orig_argv)}`"                           │
│   140 │   │   )                                                                                  │
│   141                                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ _check_only = False                                                                          │ │
│ │ dry_run_cmd = 'juju ssh postgresql/0 sudo /usr/bin/juju-exec -u postgresql/0                 │ │
│ │               JUJU_DISPATCH_PATH'+86                                                         │ │
│ │         msg = 'fire'                                                                         │ │
│ │    preamble = 'in order to run this command without confirmation prompt, you must enable     │ │
│ │               destru'+130                                                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: module 'sys' has no attribute 'orig_argv'

BTW:

ubuntu@maas-test:~$ jhack version
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /snap/jhack/353/lib/python3.8/site-packages/jhack/utils/print_env.py:93 in jhack_version         │
│                                                                                                  │
│    90                                                                                            │
│    91 def jhack_version():                                                                       │
│    92 │   """Print the currently installed jhack version and exit."""                            │
│ ❱  93 │   is_devmode = check_destructive_commands_allowed("", _check_only=True)                  │
│    94 │   print(f"jhack {get_jhack_version()}{' --DEVMODE--' if is_devmode else ''}")            │
│    95                                                                                            │
│    96                                                                                            │
│                                                                                                  │
│ /snap/jhack/353/lib/python3.8/site-packages/jhack/conf/conf.py:138 in                            │
│ check_destructive_commands_allowed                                                               │
│                                                                                                  │
│   135 │   │   │   "This is *for your own good*. "                                                │
│   136 │   │   )                                                                                  │
│   137 │   │   closure = (                                                                        │
│ ❱ 138 │   │   │   "Or, if you want to allow destructive mode just this once, run "               │
│   139 │   │   │   f"`JHACK_PROFILE=devmode {' '.join(sys.orig_argv)}`"                           │
│   140 │   │   )                                                                                  │
│   141                                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ _check_only = True                                                                           │ │
│ │ dry_run_cmd = ''                                                                             │ │
│ │         msg = ''                                                                             │ │
│ │    preamble = 'in order to run this command without confirmation prompt, you must enable     │ │
│ │               destru'+130                                                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: module 'sys' has no attribute 'orig_argv'

Note: it is old test seput with auto-updated jhack by snap. No (non-)destructive mode configs created.

PietroPasotti commented 1 month ago

Thanks for the report!

should be fixed by https://github.com/canonical/jhack/commit/ab6369a44575e92a2ec8dbf46b197652d5cb4a98 just now.

taurus-forever commented 1 month ago

Confirmed the fix. Resolved. Tnx!