canonical / canonical/pycloudlib

cloud-init fails when launching images:ubuntu/16.04/cloud VM instances

Open
#121 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
22
Forks
42
PR merge metrics
No merged PRs in 30d

Description

Steps to reproduce:
```
import pycloudlib
lxdvm = pycloudlib.LXDVirtualMachine(tag="bar")
image = "images:ubuntu/16.04/cloud"
i = lxdvm.launch(image)
```
The VM starts fine and can be accessed via `lxc exec bash` (thus via lxd-agent), but cloud-init is in a bad state:
```
root@patient-stud:~# cloud-init status
status: error
```
The reason is:
```
2021-02-22 11:01:47,963 - helpers.py[DEBUG]: Running config-scripts-per-once using lock ()
2021-02-22 11:01:47,964 - subp.py[DEBUG]: Running command ['/var/lib/cloud/scripts/per-once/setup-lxc.sh'] with allowed return codes [0] (shell=False, capture=False)
2021-02-22 11:01:48,165 - subp.py[DEBUG]: Unexpected error while running command.
Command: ['/var/lib/cloud/scripts/per-once/setup-lxc.sh']
Exit code: 5
Reason: -
Stdout: -
Stderr: -
2021-02-22 11:01:48,166 - cc_scripts_per_once.py[WARNING]: Failed to run module scripts-per-once (per-once in /var/lib/cloud/scripts/per-once)
2021-02-22 11:01:48,166 - handlers.py[DEBUG]: finish: modules-final/config-scripts-per-once: FAIL: running config-scripts-per-once with frequency once
2021-02-22 11:01:48,167 - util.py[WARNING]: Running module scripts-per-once () failed
2021-02-22 11:01:48,167 - util.py[DEBUG]: Running module scripts-per-once () failed
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 849, in _run_modules
freq=freq)
File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 54, in run
return self._runners.run(name, functor, args, freq, clear_on_fail)
File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 186, in run
return (True, results)
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 74, in lock
yield self._acquire(name, freq)
File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 185, in run
results = functor(*args)
File "/usr/lib/python3/dist-packages/cloudinit/config/cc_scripts_per_once.py", line 42, in handle
subp.runparts(runparts_path)
File "/usr/lib/python3/dist-packages/cloudinit/subp.py", line 386, in runparts
(len(failed), ",".join(failed), len(attempted)))
RuntimeError: Runparts: 1 failures (setup-lxc.sh) in 1 attempted commands
```
This doesn't happen when manually launching an instance using the same image, e.g.
```
lxc launch images:ubuntu/16.04/cloud test-x-vm --vm
```
in this case:
```
root@test-x-vm:~# cloud-init status
status: done
```
This was done on the same host machine and the problem is can be reproduced consistently.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.