Snapcraft + snapped lxd = disk space waste


#1

When snapcraft injects the core snap and assertions into an lxc container running on lxd it seems to leave behind junk that in my opinion should be cleaned up, or not even saved in the first place…

$ du -sh ~/snap/lxd/common
9.2G	/home/dllewellyn/snap/lxd/common
$ ls -l ~/snap/lxd/common
total 284
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:57 snapcraft026x1_en
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:13 snapcraft1d76a408
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:19 snapcraft1ichwma8
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:54 snapcraft2_n1jfv9
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:57 snapcraft_50cwv5m
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:13 snapcraft5kixicip
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 15:55 snapcraft5tvje68_
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:07 snapcraft60hnusq0
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:17 snapcraft64a3bngh
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:56 snapcraft6qgctapj
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 15:05 snapcraft89wumq69
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 22:47 snapcraft8__b4wyo
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:43 snapcraft8e0gg7al
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 14:35 snapcraft8lbwu7qj
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:14 snapcraft9s1cvrbp
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:15 snapcraftbwkkvran
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 21:22 snapcraftcjf79ia2
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 17:23 snapcraftcmplqpna
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 14:50 snapcraftco_jn2cn
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 21:04 snapcraftcp_rzinc
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:35 snapcraftcqj2fct2
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 21:15 snapcraftdgmk33hw
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:33 snapcrafte72ghcd1
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 17:22 snapcraftg87_4mff
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 21:16 snapcraftgjv6kn2r
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 17:02 snapcraft_glztdu4
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 15:21 snapcraftgmgqkolc
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 14:58 snapcrafthdni3imk
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 21:10 snapcraftheobvdd_
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 17:05 snapcraftijeprwzb
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 14:56 snapcraftiof8y1__
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:17 snapcraftjr5n6lb_
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:41 snapcraft_k8_nwo8
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 15:47 snapcraftk8pw8f8n
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 21:20 snapcraftl_4cwovw
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:21 snapcraftngh_aijg
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 21:05 snapcraftngnhnm4d
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:22 snapcraftni6cub57
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:30 snapcraftnplnwi_k
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 14:53 snapcraftohxy6enz
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 17:08 snapcraftos2l_28y
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 21:07 snapcraftplan7eep
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:50 snapcraftppj_4gj3
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 22:51 snapcraftqqzkthyv
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:42 snapcraftr1uo64j2
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:25 snapcraftr47hai51
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 15:56 snapcraftr4zm1rvx
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:20 snapcraftri_jaatq
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:05 snapcraftruop8dvc
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 15:22 snapcrafts3rnicb8
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 21:06 snapcraftskgcjrqh
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:30 snapcrafttgkqj536
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 17:06 snapcraftuy1wf1rv
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:50 snapcraftv3ecbasc
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 15:25 snapcraftv4274dpf
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:07 snapcraftvgoi5tsp
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 22:44 snapcraftvmgw3zdc
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:12 snapcraftvx93f39y
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 14:55 snapcraftwwui525p
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 22:57 snapcraftwx2z5g2g
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:40 snapcraftwzeokbk0
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:08 snapcraftxj4m6rnx
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:38 snapcraftxomi2bvs
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:06 snapcraftxue0v4kb
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:32 snapcraftyqz2ok97
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 15:26 snapcraftysw6bewr
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 13:16 snapcraftytforfdo
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 14:48 snapcraftywzu7bjn
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:15 snapcraftyzndrxtd
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 14:49 snapcraftz3nisnm8
drwx------ 2 dllewellyn dllewellyn 4096 Nov 15 16:53 snapcraftzfi4wxz_

every one of those snapcraft directories contains the same four files:

$ ls -l ~/snap/lxd/common/snapcraftzfi4wxz_/
total 137952
-rw-r--r-- 1 dllewellyn dllewellyn     4517 Nov 15 16:53 core_3440.assert
-rw-r--r-- 1 dllewellyn dllewellyn 87793664 Nov 15 16:53 core_3440.snap
-rw-r--r-- 1 dllewellyn dllewellyn     4521 Nov 15 16:53 snapcraft_501.assert
-rw-r--r-- 1 dllewellyn dllewellyn 53448704 Nov 15 16:53 snapcraft_501.snap

#2

Yeah, I’ve noticed this as well and asked @kalikiana to work this out with python temporary file and context magic.
Should be solved soon.


#3

Did your last container build(s) fail? The code right now leaves the temporary folder around if for whatever reason it didn’t succeed in case you wanted to do some debugging - otherwise it gets deleted at the end of the run.


#4

To expand on my comment: I think what you’re seeing here is left-overs from failed builds. A temporary folder is used because you might be running multiple builds in parallel. There’s currently no code to sweep old folders next time you run snapcraft.
I also considered only leaving the temporary folder around if --debug was used, making this less relevant for most users.


#5

Yowzer.

alan@hal:~$ du -hs snap/lxd/common
19G	snap/lxd/common

#6

This is a flawed assumption; people in general wouldn’t want to debug this (unless it would be you); it is just a passthrough and should be eliminated as soon as the reason for it to be there is no longer required.


#7

Fair enough. I proposed a PR to always remove the folder.

Although unfortunately this won’t help with existing folders, or if snapcraft is killed - that will need additional logic.