Public bug reported:

% tox -e citest -- run --verbose --os-name centos70 --preserve-data --data-dir 
ctestout --test bugs/lp1885952-chrony
...

Command: ['lxc', 'image', 'export', 
'b73b65fa3d3ce2b5aad9c22ac1c83575c15262e157db5651219318aad13cb94f', 
'/tmp/cloud_test_util_9kido331']
Exit code: 1
Reason: -
Stdout:
Stderr: Error: open /var/lib/snapd/hostfs/tmp/cloud_test_util_9kido331: is a 
directory
2020-07-02 17:16:24,585 - 
/home/rharper/work/git/cloud-init/tests/cloud_tests/stage.py:run_stage:104 
[ERROR]: traceback:
  File "/home/rharper/work/git/cloud-init/tests/cloud_tests/stage.py", line 97, 
in run_stage
    (call_res, call_failed) = call()
  File "/home/rharper/work/git/cloud-init/tests/cloud_tests/collect.py", line 
169, in collect_image
    with component as image:
  File "/home/rharper/work/git/cloud-init/tests/cloud_tests/stage.py", line 27, 
in __enter__
    self.instance = self.get_func()
  File 
"/home/rharper/work/git/cloud-init/tests/cloud_tests/platforms/__init__.py", 
line 22, in get_image
    return platform.get_image(config)
  File 
"/home/rharper/work/git/cloud-init/tests/cloud_tests/platforms/lxd/platform.py",
 line 38, in get_image
    image.update_templates(self.config.get('template_overrides', {}),
  File 
"/home/rharper/work/git/cloud-init/tests/cloud_tests/platforms/lxd/image.py", 
line 127, in update_templates
    (metadata, rootfs) = self.export_image(export_dir)
  File 
"/home/rharper/work/git/cloud-init/tests/cloud_tests/platforms/lxd/image.py", 
line 85, in export_image
    subp.subp(['lxc', 'image', 'export', self.pylxd_image.fingerprint,
  File "/home/rharper/work/git/cloud-init/cloudinit/subp.py", line 290, in subp
    raise ProcessExecutionError(stdout=out, stderr=err,


1) lxc image export <hash> <filename>  is the new format; if <filename>
is a directly like platforms/lxd/image.py provides, it fails.

The export format now writes two file

% lxc image export <hash> myimage
myimage
myimage.root

Where myimage is a tar.xz of the metadata folder and myimage.root is the
squashfs root

(crispyboi) lxd % lxc image export --verbose 
e37c4d8078f197d3eabd85a9bb5a87462db54b5d6729cff63d86bdd5c312ad40 myimage.tar.xz
Image exported successfully!
(crispyboi) lxd % ls -al
total 85272
drwxrwxr-x  2 rharper rharper        4 Jul  2 12:20 .
drwxrwxrwt 49 root    root          59 Jul  2 12:19 ..
-rw-rw-r--  1 rharper rharper      844 Jul  2 12:20 myimage.tar.xz
-rw-rw-r--  1 rharper rharper 87203840 Jul  2 12:20 myimage.tar.xz.root
(crispyboi) lxd % tar tJvf myimage.tar.xz
-rw-r--r-- root/root       686 2020-07-01 02:31 metadata.yaml
drwxr-xr-x root/root         0 2020-07-01 02:31 templates/
-rw-r--r-- root/root       189 2020-07-01 02:31 templates/hosts.tpl
-rw-r--r-- root/root       139 2020-07-01 02:31 templates/ifcfg-eth0.lxd.tpl
-rw-r--r-- root/root        45 2020-07-01 02:31 templates/network.lxd.tpl
(crispyboi) lxd % file myimage.tar.xz.root
myimage.tar.xz.root: Squashfs filesystem, little endian, version 1024.0, 
compressed, 1701289756295430144 bytes, -1455882240 inodes, blocksize: 4096 
bytes, created: Thu Feb  7 01:07:42 2104


The following seems to make it work:

diff --git a/tests/cloud_tests/platforms/lxd/image.py 
b/tests/cloud_tests/platforms/lxd/image.py
index 8934fb74..172f83ab 100644
--- a/tests/cloud_tests/platforms/lxd/image.py
+++ b/tests/cloud_tests/platforms/lxd/image.py
@@ -82,13 +82,11 @@ class LXDImage(Image):
         @return_value: tuple of path to metadata tarball and rootfs tarball
         """
         # pylxd's image export feature doesn't do split exports, so use cmdline
+        outfile = output_dir + 'myimage.tar.xz'
         subp.subp(['lxc', 'image', 'export', self.pylxd_image.fingerprint,
-                  output_dir], capture=True)
-        tarballs = [p for p in os.listdir(output_dir) if p.endswith('tar.xz')]
-        metadata = os.path.join(
-            output_dir, next(p for p in tarballs if p.startswith('meta-')))
-        rootfs = os.path.join(
-            output_dir, next(p for p in tarballs if not p.startswith('meta-')))
+                  outfile], capture=True)
+        metadata = outfile
+        rootfs = outfile + '.root'
         return (metadata, rootfs)

** Affects: cloud-init (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1886080

Title:
  lxd cloud_tests fail to export images on latest/stable

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1886080/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to