Error in bundle causes juju to panic

Bug #1918742 reported by Camille Rodriguez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
High
Unassigned
2.8
Fix Released
High
Unassigned
2.9
Fix Released
High
Unassigned

Bug Description

Upon deployment of a bundle with a syntax error, juju panicked.

The error in the bundle was an empty charm. Look at the coredns line:
```
  kubernetes-master:
    bindings:
      ? ''
      : oam-space
      certificates: internal-space
      kube-api-endpoint: internal-space
      kube-control: internal-space
      loadbalancer: internal-space
      cni: k8s-pods-space
    charm: cs:~containers/kubernetes-master
    num_units: 3
    options:
      allow-privileged: 'true'
      authorization-mode: RBAC,Node
      # dns-provider: node
  coredns:

  kubernetes-worker:
    bindings:
      ? ''
      : oam-space
      certificates: internal-space
      kube-control: internal-space
      cni: k8s-pods-space
    charm: cs:~containers/kubernetes-worker
    expose: true
    num_units: 3
    options:
      allow-privileged: 'true'
```

traceback :
ubuntu@infra-01:~/$ fce build --layer lmacmr [78/78]
2021-03-11-22:32:33 root WARNING ["There must be at least three zones and there must be odd number of zones. Zones found: {'zone1'}"]
2021-03-11-22:32:33 fce.build INFO Started building layer: lmacmr
2021-03-11-22:32:33 fce.juju_workload INFO Starting step: lmacmr:create_model
2021-03-11-22:32:34 fce.juju_workload INFO Finished step: lmacmr:create_model. Time elapsed (hh:mm:ss.ms): 0:00:00.905820
2021-03-11-22:32:34 fce.juju_workload INFO Starting step: lmacmr:set_model_config
2021-03-11-22:32:34 fce.juju_workload INFO Finished step: lmacmr:set_model_config. Time elapsed (hh:mm:ss.ms): 0:00:00.214416
2021-03-11-22:32:34 fce.juju_workload INFO Starting step: lmacmr:ensure_storage_pools
2021-03-11-22:32:34 fce.juju_workload INFO Finished step: lmacmr:ensure_storage_pools. Time elapsed (hh:mm:ss.ms): 0:00:00.306996
2021-03-11-22:32:34 fce.juju_workload INFO Starting step: lmacmr:add_manual_machines
2021-03-11-22:32:34 fce.juju_workload INFO Finished step: lmacmr:add_manual_machines. Time elapsed (hh:mm:ss.ms): 0:00:00.000012
2021-03-11-22:32:34 fce.juju_workload INFO Starting step: lmacmr:deploy_bundle
2021-03-11 22:32:35.077297 22:32:35 INFO juju.cmd supercommand.go:54 running juju [2.8.9 0 a48bedf0ae2096d0cf750b7676da9b0a994cff09 gc go1.14.15]
2021-03-11 22:32:35.077398 22:32:35 DEBUG juju.cmd supercommand.go:55 args: []string{"/snap/juju/15523/bin/juju", "deploy", "-m", "foundations-maas:kubernetes", "--debug", "./config/../generated/kubernetes/bun
dle.yaml", "--overlay", "./config/overlay_kubernetes_options.yaml", "--overlay", "./config/overlay_kubernetes_placement.yaml", "--overlay", "./config/overlay_kubernetes_versioned.yaml", "--overlay", "./config/ov
erlay_kubernetes_saas.yaml"}
2021-03-11 22:32:35.078217 22:32:35 INFO juju.juju api.go:67 connecting to API addresses: [172.24.70.19:17070 172.24.70.20:17070 172.24.70.21:17070]
2021-03-11 22:32:35.100555 22:32:35 DEBUG juju.api apiclient.go:1107 successfully dialed "wss://172.24.70.19:17070/api"
2021-03-11 22:32:35.100596 22:32:35 INFO juju.api apiclient.go:639 connection established to "wss://172.24.70.19:17070/api"
2021-03-11 22:32:35.142810 22:32:35 INFO juju.juju api.go:67 connecting to API addresses: [172.24.70.19:17070 172.24.70.20:17070 172.24.70.21:17070]
2021-03-11 22:32:35.154207 22:32:35 DEBUG juju.api apiclient.go:1107 successfully dialed "wss://172.24.70.19:17070/model/a24e3392-b509-4b33-8cb3-3245d99b5f83/api"
2021-03-11 22:32:35.154304 22:32:35 INFO juju.api apiclient.go:639 connection established to "wss://172.24.70.19:17070/model/a24e3392-b509-4b33-8cb3-3245d99b5f83/api"
2021-03-11 22:32:35.196554 22:32:35 INFO juju.juju api.go:67 connecting to API addresses: [172.24.70.19:17070 172.24.70.20:17070 172.24.70.21:17070]
2021-03-11 22:32:35.215834 22:32:35 DEBUG juju.api apiclient.go:1107 successfully dialed "wss://172.24.70.21:17070/api"
2021-03-11 22:32:35.215906 22:32:35 INFO juju.api apiclient.go:639 connection established to "wss://172.24.70.21:17070/api"
2021-03-11 22:32:35.255197 22:32:35 INFO juju.juju api.go:302 API endpoints changed from [172.24.70.21:17070 172.24.70.20:17070 172.24.70.19:17070] to [172.24.70.21:17070 172.24.70.19:17070 172.24.70.20:17070]
2021-03-11 22:32:35.267203 22:32:35 DEBUG juju.api monitor.go:35 RPC connection died
2021-03-11 22:32:35.269840 panic: runtime error: invalid memory address or nil pointer dereference
2021-03-11 22:32:35.269906 [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x9ba3b5]
2021-03-11 22:32:35.269924
2021-03-11 22:32:35.269939 goroutine 1 [running]:
2021-03-11 22:32:35.269960 github.com/juju/charm/v7.ReadAndMergeBundleData(0xc000a89980, 0x5, 0x8, 0x4, 0x5, 0xc000a89980)
2021-03-11 22:32:35.269984 /build/snapcraft-juju-35d6cf/parts/juju/src/vendor/github.com/juju/charm/v7/overlay.go:443 +0x7a5
2021-03-11 22:32:35.270002 github.com/juju/juju/cmd/juju/application.composeAndVerifyBundle(0x4528180, 0xc000a9e7b0, 0xc0008a9040, 0x4, 0x4, 0x0, 0xc000f4f410, 0xffffffffffffffff)
2021-03-11 22:32:35.270020 /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/application/bundle.go:137 +0x17d
2021-03-11 22:32:35.270037 github.com/juju/juju/cmd/juju/application.(*DeployCommand).deployBundle(0xc00020fb80, 0xc00089b5e0, 0x0, 0x4528180, 0xc000a9e7b0, 0x0, 0x0, 0x0, 0xc0008a9040, 0x4, ...)
2021-03-11 22:32:35.270054 /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/application/deploy.go:898 +0x36f
2021-03-11 22:32:35.270070 github.com/juju/juju/cmd/juju/application.(*DeployCommand).maybeReadLocalBundle.func1(0xc00089b5e0, 0x45da6c0, 0xc000552500, 0x3e51548, 0xc000198e40, 0x0, 0x0)
2021-03-11 22:32:35.270087 /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/application/deploy.go:1373 +0x1c0
2021-03-11 22:32:35.270107 github.com/juju/juju/cmd/juju/application.(*DeployCommand).Run(0xc00020fb80, 0xc00089b5e0, 0x0, 0x0)
2021-03-11 22:32:35.270121 /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/application/deploy.go:1197 +0x4c2
2021-03-11 22:32:35.270134 github.com/juju/juju/cmd/modelcmd.(*modelCommandWrapper).Run(0xc00097b080, 0xc00089b5e0, 0x6552be0, 0x3326b80)
2021-03-11 22:32:35.270148 /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/modelcmd/modelcommand.go:623 +0x129
2021-03-11 22:32:35.270162 github.com/juju/juju/cmd/modelcmd.(*baseCommandWrapper).Run(0xc000891d80, 0xc00089b5e0, 0x0, 0x0)
2021-03-11 22:32:35.270175 /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/modelcmd/base.go:493 +0xa8
2021-03-11 22:32:35.270188 github.com/juju/cmd.(*SuperCommand).Run(0xc000658a00, 0xc00089b5e0, 0xc00089b5e0, 0x0)
2021-03-11 22:32:35.270206 /build/snapcraft-juju-35d6cf/parts/juju/src/vendor/github.com/juju/cmd/supercommand.go:523 +0x2ba
2021-03-11 22:32:35.270230 github.com/juju/cmd.Main(0x456a6a0, 0xc000658a00, 0xc00089b5e0, 0xc000b15930, 0xd, 0xd, 0xc000658a00)
2021-03-11 22:32:35.270246 /build/snapcraft-juju-35d6cf/parts/juju/src/vendor/github.com/juju/cmd/cmd.go:387 +0x2bf
2021-03-11 22:32:35.270262 github.com/juju/juju/cmd/juju/commands.main.Run(0x3e53fd8, 0xc00004c0e0, 0xe, 0xe, 0xc0007b0920)
2021-03-11 22:32:35.270278 /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/commands/main.go:169 +0x46e
2021-03-11 22:32:35.270294 github.com/juju/juju/cmd/juju/commands.Main(...)
2021-03-11 22:32:35.270310 /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/commands/main.go:90
2021-03-11 22:32:35.270325 main.main()
2021-03-11 22:32:35.270341 /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/main.go:37 +0xb9
2021-03-11-22:32:35 root ERROR [localhost] Command failed: juju deploy -m foundations-maas:kubernetes --debug ./config/../generated/kubernetes/bundle.yaml --overlay ./config/overlay_kubernetes_options.yaml --ove
rlay ./config/overlay_kubernetes_placement.yaml --overlay ./config/overlay_kubernetes_versioned.yaml --overlay ./config/overlay_kubernetes_saas.yaml
2021-03-11-22:32:35 root ERROR [localhost] STDOUT follows:
22:32:35 INFO juju.cmd supercommand.go:54 running juju [2.8.9 0 a48bedf0ae2096d0cf750b7676da9b0a994cff09 gc go1.14.15]
22:32:35 DEBUG juju.cmd supercommand.go:55 args: []string{"/snap/juju/15523/bin/juju", "deploy", "-m", "foundations-maas:kubernetes", "--debug", "./config/../generated/kubernetes/bundle.yaml", "--overlay", "./
config/overlay_kubernetes_options.yaml", "--overlay", "./config/overlay_kubernetes_placement.yaml", "--overlay", "./config/overlay_kubernetes_versioned.yaml", "--overlay", "./config/overlay_kubernetes_saas.yaml"
}
22:32:35 INFO juju.juju api.go:67 connecting to API addresses: [172.24.70.19:17070 172.24.70.20:17070 172.24.70.21:17070]
22:32:35 DEBUG juju.api apiclient.go:1107 successfully dialed "wss://172.24.70.19:17070/api"
22:32:35 INFO juju.api apiclient.go:639 connection established to "wss://172.24.70.19:17070/api"
22:32:35 INFO juju.juju api.go:67 connecting to API addresses: [172.24.70.19:17070 172.24.70.20:17070 172.24.70.21:17070]
22:32:35 DEBUG juju.api apiclient.go:1107 successfully dialed "wss://172.24.70.19:17070/model/a24e3392-b509-4b33-8cb3-3245d99b5f83/api"
22:32:35 INFO juju.api apiclient.go:639 connection established to "wss://172.24.70.19:17070/model/a24e3392-b509-4b33-8cb3-3245d99b5f83/api"
22:32:35 INFO juju.juju api.go:67 connecting to API addresses: [172.24.70.19:17070 172.24.70.20:17070 172.24.70.21:17070]
22:32:35 DEBUG juju.api apiclient.go:1107 successfully dialed "wss://172.24.70.21:17070/api"
22:32:35 INFO juju.api apiclient.go:639 connection established to "wss://172.24.70.21:17070/api"
22:32:35 INFO juju.juju api.go:302 API endpoints changed from [172.24.70.21:17070 172.24.70.20:17070 172.24.70.19:17070] to [172.24.70.21:17070 172.24.70.19:17070 172.24.70.20:17070]
22:32:35 DEBUG juju.api monitor.go:35 RPC connection died
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x9ba3b5]

goroutine 1 [running]:
github.com/juju/charm/v7.ReadAndMergeBundleData(0xc000a89980, 0x5, 0x8, 0x4, 0x5, 0xc000a89980)
        /build/snapcraft-juju-35d6cf/parts/juju/src/vendor/github.com/juju/charm/v7/overlay.go:443 +0x7a5
github.com/juju/juju/cmd/juju/application.composeAndVerifyBundle(0x4528180, 0xc000a9e7b0, 0xc0008a9040, 0x4, 0x4, 0x0, 0xc000f4f410, 0xffffffffffffffff)
        /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/application/bundle.go:137 +0x17d
github.com/juju/juju/cmd/juju/application.(*DeployCommand).deployBundle(0xc00020fb80, 0xc00089b5e0, 0x0, 0x4528180, 0xc000a9e7b0, 0x0, 0x0, 0x0, 0xc0008a9040, 0x4, ...)
        /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/application/deploy.go:898 +0x36f
github.com/juju/juju/cmd/juju/application.(*DeployCommand).maybeReadLocalBundle.func1(0xc00089b5e0, 0x45da6c0, 0xc000552500, 0x3e51548, 0xc000198e40, 0x0, 0x0)
        /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/application/deploy.go:1373 +0x1c0
github.com/juju/juju/cmd/juju/application.(*DeployCommand).Run(0xc00020fb80, 0xc00089b5e0, 0x0, 0x0)
        /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/application/deploy.go:1197 +0x4c2
github.com/juju/juju/cmd/modelcmd.(*modelCommandWrapper).Run(0xc00097b080, 0xc00089b5e0, 0x6552be0, 0x3326b80)
        /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/modelcmd/modelcommand.go:623 +0x129
github.com/juju/juju/cmd/modelcmd.(*baseCommandWrapper).Run(0xc000891d80, 0xc00089b5e0, 0x0, 0x0)
        /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/modelcmd/base.go:493 +0xa8
github.com/juju/cmd.(*SuperCommand).Run(0xc000658a00, 0xc00089b5e0, 0xc00089b5e0, 0x0)
        /build/snapcraft-juju-35d6cf/parts/juju/src/vendor/github.com/juju/cmd/supercommand.go:523 +0x2ba
github.com/juju/cmd.Main(0x456a6a0, 0xc000658a00, 0xc00089b5e0, 0xc000b15930, 0xd, 0xd, 0xc000658a00)
        /build/snapcraft-juju-35d6cf/parts/juju/src/vendor/github.com/juju/cmd/cmd.go:387 +0x2bf
github.com/juju/juju/cmd/juju/commands.main.Run(0x3e53fd8, 0xc00004c0e0, 0xe, 0xe, 0xc0007b0920)
        /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/commands/main.go:169 +0x46e
github.com/juju/juju/cmd/juju/commands.Main(...)
        /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/commands/main.go:90
main.main()
        /build/snapcraft-juju-35d6cf/parts/juju/src/cmd/juju/main.go:37 +0xb9
2021-03-11-22:32:35 root ERROR [localhost] STDERR follows:
None
Traceback (most recent call last):
  File "/usr/local/bin/fce", line 11, in <module>
    load_entry_point('foundationcloudengine', 'console_scripts', 'fce')()
  File "/home/ubuntu/cpe-foundation/foundationcloudengine/foundationcloudengine/main.py", line 170, in entry_point
    sys.exit(main(sys.argv[1:]))
  File "/home/ubuntu/cpe-foundation/foundationcloudengine/foundationcloudengine/main.py", line 161, in main
    opts.func(opts)
  File "/home/ubuntu/cpe-foundation/foundationcloudengine/foundationcloudengine/build.py", line 107, in build_main
    build_and_validate_if_needed(
  File "/home/ubuntu/cpe-foundation/foundationcloudengine/foundationcloudengine/build.py", line 75, in build_and_validate_if_needed
    layer.build_outer(only_steps)
  File "/home/ubuntu/cpe-foundation/foundationcloudengine/foundationcloudengine/layers/baselayer.py", line 122, in build_outer
    self.build(only_steps=only_steps)
  File "/home/ubuntu/cpe-foundation/foundationcloudengine/foundationcloudengine/layers/jujuworkloadlayer.py", line 901, in build
    self.run_steps(only_steps)
  File "/home/ubuntu/cpe-foundation/foundationcloudengine/foundationcloudengine/layers/steppedbaselayer.py", line 114, in run_steps
    step.build()
  File "/home/ubuntu/cpe-foundation/foundationcloudengine/foundationcloudengine/layers/jujuworkloadlayer.py", line 679, in build
    deploy(
  File "/home/ubuntu/cpe-foundation/foundationcloudengine/foundationcloudengine/juju_cli.py", line 201, in deploy
    local(command, stderr=subprocess.STDOUT, output_mode="live")
  File "/home/ubuntu/cpe-foundation/foundationcloudengine/foundationcloudengine/remotehelpers.py", line 209, in local
    return run_cmd(cmd, target_machine, **kwargs)
  File "/home/ubuntu/cpe-foundation/foundationcloudengine/foundationcloudengine/remotehelpers.py", line 147, in run_cmd
    raise subprocess.CalledProcessError(ps.returncode, cmd, output=out, stderr=err)
subprocess.CalledProcessError: Command '['juju', 'deploy', '-m', 'foundations-maas:kubernetes', '--debug', './config/../generated/kubernetes/bundle.yaml', '--overlay', './config/overlay_kubernetes_options.yaml',
 '--overlay', './config/overlay_kubernetes_placement.yaml', '--overlay', './config/overlay_kubernetes_versioned.yaml', '--overlay', './config/overlay_kubernetes_saas.yaml']' returned non-zero exit status 2.

Revision history for this message
John A Meinel (jameinel) wrote :

I think any bundle that has a nil application definition will cause a panic, if you use any overlay when it tries to run ReadAndMergeBundleOverlay.

applications:
  foo:

  bar:
   charm: bar

The charm code has:
                for app, appData := range base.Data.Applications {
                        resolvedCharm, err := resolveRelativeCharmPath(basePath, appData.Charm)

However, if you leave the app as a nil value, then 'appData' is nil, and 'appData.Charm' is a nil pointer dereference.
It should be easy to do:

if appData == nil {
  return nil, errors.Errorf("application %q has no body", app)
}

I'm not super happy with that error message, but something along those lines. It will point the user to what part of the bundle is incorrectly constructed.

Changed in juju:
importance: Undecided → High
status: New → Triaged
milestone: none → 3.0.0
Changed in juju:
assignee: nobody → Simon Richardson (simonrichardson)
Revision history for this message
Simon Richardson (simonrichardson) wrote :
Revision history for this message
Simon Richardson (simonrichardson) wrote :
Revision history for this message
John A Meinel (jameinel) wrote :

was released with 2.9rc7, the bug just didn't get updated before the release.

Changed in juju:
status: Triaged → Fix Committed
Changed in juju:
assignee: Simon Richardson (simonrichardson) → nobody
John A Meinel (jameinel)
Changed in juju:
milestone: 3.0.0 → 3.0-beta1
Ian Booth (wallyworld)
Changed in juju:
status: Fix Committed → Fix Released
Ian Booth (wallyworld)
Changed in juju:
status: Fix Released → Fix Committed
Changed in juju:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.