Skip to content

jhack fire -m <other-model fails #248

Description

@Gu1nness

Bug Description

Assuming current model is shard, then running jhack fire --model testing config-server/0 update-status fails.

The command that is crafted is:

juju ssh -m testing config-server/0 /usr/bin/juju-exec -u config-server/0 JUJU_DISPATCH_PATH=hooks/update-status JUJU_MODEL_NAME=shard JUJU_UNIT_NAME=config-server/0 /var/lib/juju/agents/unit-config-server-0/charm/dispatch

The wrong model name is picked.
The reason is twofold:

  • The caller does not provide the model name while it has it: here
  • The callee does not respect the model provided: here

The two patches should be:

  • Pass the model in _build_command to build_event_env
  • In build_event_env use the model to create the env dictionary.

Since the model is always known, no need for it to be optional, we could even remove the call to get_current_model in build_event_env.
However, for the sake of consistency and reusability, I would do model = model or get_current_model.

I can provide a PR if you want.

To Reproduce

  1. juju add-model modela
  2. juju add-model modelb
  3. juju deploy -m modela <app-name>
  4. jhack fire -m modela <app-name>/0 update-status

Environment

┌──────────────┬──────────────────────────────────────┐
│ jhack        │ 0.4.4.0.29                           │
│ python       │ 3.12.3 (/snap/jhack/632/bin/python3) │
│ juju-* snaps │                                      │
│ microk8s     │ Not Installed.                       │
│ lxd          │ Not Installed.                       │
│ multipass    │ Not Installed.                       │
│ multipassd   │ Not Installed.                       │
│ os           │ Ubuntu Core 24                       │
│ kernel       │ Linux 7.0.0-28-generic x86_64        │
└──────────────┴──────────────────────────────────────┘

Relevant log output

juju ssh -m testing config-server/0 /usr/bin/juju-exec -u config-server/0 JUJU_DISPATCH_PATH=hooks/update-status JUJU_MODEL_NAME=shard JUJU_UNIT_NAME=config-server/0 /var/lib/juju/agents/unit-config-server-0/charm/dispatch
ERROR command terminated with exit code 1

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions