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
juju add-model modela
juju add-model modelb
juju deploy -m modela <app-name>
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
Bug Description
Assuming current model is
shard, then runningjhack fire --model testing config-server/0 update-statusfails.The command that is crafted is:
The wrong model name is picked.
The reason is twofold:
The two patches should be:
_build_commandtobuild_event_envbuild_event_envuse 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_modelinbuild_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
juju add-model modelajuju add-model modelbjuju deploy -m modela <app-name>jhack fire -m modela <app-name>/0 update-statusEnvironment
Relevant log output
Additional context
No response