[2.7-rc6] Invalid exec format for a hook file does not result in a unit error
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Fix Released
|
Medium
|
John A Meinel | ||
2.7 |
Fix Released
|
Medium
|
John A Meinel |
Bug Description
A simple charm that has `exit 2` in hooks/install without a shebang (!) does not make Juju to error out on a hook execution and block further hook executions. Instead, Juju sets a unit status to "unknown" and other hooks are then executed.
Expectation: ENOEXEC ("exec format error") would be caught by the unit agent and a hook execution would be marked as failed.
➜ dummy-leaver tree
.
├── config.yaml
├── hooks
│ └── install
└── metadata.yaml
1 directory, 3 files
# NOTE: invalid without a shebang
➜ dummy-leaver cat hooks/install
exit 2
➜ dummy-leaver stat hooks/install
File: hooks/install
Size: 7 Blocks: 8 IO Block: 4096 regular file
Device: 1dh/29d Inode: 13251814 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 1000/ ubuntu) Gid: ( 1000/ ubuntu)
Access: 2019-11-28 13:00:15.267308455 +0300
Modify: 2019-11-28 12:59:56.195241078 +0300
Change: 2019-11-28 12:59:56.195241078 +0300
Birth: -
➜ dummy-leaver juju show-status-log leaver/1
Time Type Status Message
28 Nov 2019 13:02:43+03:00 workload waiting waiting for machine
28 Nov 2019 13:02:43+03:00 juju-unit allocating
28 Nov 2019 13:04:03+03:00 workload waiting installing agent
28 Nov 2019 13:04:06+03:00 workload waiting agent initializing
28 Nov 2019 13:04:07+03:00 workload maintenance installing charm software
28 Nov 2019 13:04:07+03:00 juju-unit executing running install hook
28 Nov 2019 13:04:07+03:00 juju-unit executing running leader-elected hook
28 Nov 2019 13:04:07+03:00 juju-unit executing running config-changed hook
28 Nov 2019 13:04:07+03:00 juju-unit executing running start hook
28 Nov 2019 13:04:07+03:00 workload unknown
28 Nov 2019 13:04:07+03:00 juju-unit idle
➜ dummy-leaver juju status leaver/1
Model Controller Cloud/Region Version SLA Timestamp
default localhost-localhost localhost/localhost 2.7-rc6 unsupported 13:07:34+03:00
App Version Status Scale Charm Store Rev OS Notes
leaver unknown 1 dummy-leaver local 2 ubuntu
Unit Workload Agent Machine Public address Ports Message
leaver/1* unknown idle 3 10.190.92.218
Machine State DNS Inst id Series AZ Message
3 started 10.190.92.218 juju-2a1341-3 bionic Running
A simple go program like this manages to catch it:
package main
import (
"log"
"os/exec"
)
func main() {
cmd := exec.Command(
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
}
./main
2019/11/28 13:15:05 fork/exec /tmp/dummy-
Changed in juju: | |
status: | New → Confirmed |
summary: |
- [2.7-rc6] Invalid exec format for a hook file does not result in unit + [2.7-rc6] Invalid exec format for a hook file does not result in a unit error |
Changed in juju: | |
status: | In Progress → Fix Committed |
Changed in juju: | |
status: | Fix Committed → Fix Released |
Attached a debug-log with
juju model-config logging- config= '<root> =WARNING; unit=TRACE; juju.state= TRACE;juju. worker. uniter. resolver= TRACE;juju. worker. uniter. runner= TRACE':