clair icon indicating copy to clipboard operation
clair copied to clipboard

Cleanup downloaded assets in `/tmp` directory

Open rqc opened this issue 10 years ago • 9 comments

Hello,

We've been running Clair in our staging environment for a couple of months with an update frequency of 2 hours. Right now, our /tmp directory is over 20 gigabytes. As a workaround we will reduce the frequency of updates as well as create a cron job to clean it periodically.

However, I think Clair could do this cleanup after itself. There is no need to have those files in the /tmp after they are used to update the database.

I would like to know your thoughts about this. Thanks!

rqc avatar Jun 16 '16 12:06 rqc

+1

soninob avatar Jun 16 '16 13:06 soninob

Hi,

Which version of Clair are you running? Could you please describe which folders/files (and their sizes) do you have in the /tmp so we can identify which fetcher(s) are problematic? I believe that du -h --max-depth=1 /tmp will do the trick.

Quentin-M avatar Jun 16 '16 13:06 Quentin-M

Hello @Quentin-M

Thanks for the quick reply. We are using the following docker image tag quay.io/coreos/clair:v1.1.0.

Here is the list of the /tmp directory.

247M    /tmp/clair-data/ubuntu-cve-tracker095295273
251M    /tmp/clair-data/ubuntu-cve-tracker278321022
249M    /tmp/clair-data/ubuntu-cve-tracker906029387
248M    /tmp/clair-data/ubuntu-cve-tracker911549057
4.0K    /tmp/clair-data/nvd-data960633029
4.0K    /tmp/clair-data/nvd-data425983436
247M    /tmp/clair-data/ubuntu-cve-tracker307292641
4.0K    /tmp/clair-data/nvd-data531440884
4.0K    /tmp/clair-data/nvd-data113332939
4.0K    /tmp/clair-data/nvd-data030706397
102M    /tmp/clair-data/ubuntu-cve-tracker568601134
4.0K    /tmp/clair-data/nvd-data427166207
251M    /tmp/clair-data/ubuntu-cve-tracker760798198
248M    /tmp/clair-data/ubuntu-cve-tracker717889182
4.0K    /tmp/clair-data/nvd-data626804203
248M    /tmp/clair-data/ubuntu-cve-tracker558621762
4.0K    /tmp/clair-data/nvd-data054489614
248M    /tmp/clair-data/ubuntu-cve-tracker855017496
4.0K    /tmp/clair-data/nvd-data741321262
4.0K    /tmp/clair-data/nvd-data537980261
59M /tmp/clair-data/ubuntu-cve-tracker365880726
70M /tmp/clair-data/ubuntu-cve-tracker186765555
247M    /tmp/clair-data/ubuntu-cve-tracker955159447
4.0K    /tmp/clair-data/nvd-data300693889
4.0K    /tmp/clair-data/nvd-data380433015
4.0K    /tmp/clair-data/nvd-data610753185
4.0K    /tmp/clair-data/nvd-data060538052
250M    /tmp/clair-data/ubuntu-cve-tracker338733084
248M    /tmp/clair-data/ubuntu-cve-tracker420590265
4.0K    /tmp/clair-data/nvd-data185252906
248M    /tmp/clair-data/ubuntu-cve-tracker739594818
4.0K    /tmp/clair-data/nvd-data448498724
249M    /tmp/clair-data/ubuntu-cve-tracker991600682
245M    /tmp/clair-data/ubuntu-cve-tracker545365099
4.0K    /tmp/clair-data/nvd-data480519284
245M    /tmp/clair-data/ubuntu-cve-tracker435355512
4.0K    /tmp/clair-data/nvd-data842395799
4.0K    /tmp/clair-data/nvd-data012348601
4.0K    /tmp/clair-data/nvd-data901936892
249M    /tmp/clair-data/ubuntu-cve-tracker433383377
248M    /tmp/clair-data/ubuntu-cve-tracker118130381
247M    /tmp/clair-data/ubuntu-cve-tracker144033738
246M    /tmp/clair-data/ubuntu-cve-tracker171962027
248M    /tmp/clair-data/ubuntu-cve-tracker855145760
250M    /tmp/clair-data/ubuntu-cve-tracker048179767
4.0K    /tmp/clair-data/nvd-data331583673
4.0K    /tmp/clair-data/nvd-data568592394
4.0K    /tmp/clair-data/nvd-data177407298
4.0K    /tmp/clair-data/nvd-data826570446
251M    /tmp/clair-data/ubuntu-cve-tracker077834600
4.0K    /tmp/clair-data/nvd-data337019303
245M    /tmp/clair-data/ubuntu-cve-tracker918393775
4.0K    /tmp/clair-data/nvd-data060947948
4.0K    /tmp/clair-data/nvd-data133614534
247M    /tmp/clair-data/ubuntu-cve-tracker526533545
4.0K    /tmp/clair-data/nvd-data628093384
247M    /tmp/clair-data/ubuntu-cve-tracker725389635
245M    /tmp/clair-data/ubuntu-cve-tracker627439036
4.0K    /tmp/clair-data/nvd-data947315757
248M    /tmp/clair-data/ubuntu-cve-tracker041786777
245M    /tmp/clair-data/ubuntu-cve-tracker816003206
21G /tmp/clair-data/

Thanks!

rqc avatar Jun 16 '16 14:06 rqc

Hello! I'm having the same issue but with quay.io/coreos/clair:v2.0.0-pre.3. Our /tmp directory fills up very quickly. It'd be nice if clair cleaned up after itself

total 506M
-rw-r--r--.  1 root root 109M Feb 27 14:19 nvd-data2176703002011.xml
-rw-r--r--.  1 root root  45M Feb 27 14:20 nvd-data2176703002010.xml
-rw-r--r--.  1 root root  44M Feb 27 14:19 nvd-data2176703002013.xml
-rw-r--r--.  1 root root  42M Feb 27 14:19 nvd-data2176703002012.xml
-rw-r--r--.  1 root root  40M Feb 27 14:19 nvd-data2176703002014.xml
-rw-r--r--.  1 root root  32M Feb 27 14:20 nvd-data2176703002016.xml
-rw-r--r--.  1 root root  31M Feb 27 14:19 nvd-data2176703002009.xml
-rw-r--r--.  1 root root  31M Feb 27 14:19 nvd-data2176703002008.xml
-rw-r--r--.  1 root root  30M Feb 27 14:19 nvd-data2176703002015.xml
-rw-r--r--.  1 root root  27M Feb 27 14:20 nvd-data2176703002006.xml
-rw-r--r--.  1 root root  25M Feb 27 14:19 nvd-data2176703002007.xml
-rw-r--r--.  1 root root  19M Feb 27 14:19 nvd-data2176703002002.xml
-rw-r--r--.  1 root root  18M Feb 27 14:19 nvd-data2176703002005.xml
-rw-r--r--.  1 root root  12M Feb 27 14:19 nvd-data2176703002004.xml
-rw-r--r--.  1 root root 5.5M Feb 27 14:19 nvd-data2176703002003.xml
-rw-r--r--.  1 root root 2.1M Feb 27 14:20 nvd-data2176703002017.xml
drwxrwxrwx. 10 root root 4.0K Feb 27 14:24 .
dr-xr-xr-x. 21 root root 4.0K Feb 27 11:13 ..
drwx------.  6 root root   84 Feb 27 14:08 alpine-secdb628505646
drwxrwxrwt.  2 root root    6 Sep 23 10:18 .font-unix
drwxrwxrwt.  2 root root    6 Sep 23 10:18 .ICE-unix
drwx------.  2 root root    6 Feb 27 14:04 nvd-data217670300
drwxrwxrwt.  2 root root    6 Sep 23 10:18 .Test-unix
drwx------.  2 root root    6 Feb 27 14:24 ubuntu-cve-tracker124427664
drwxrwxrwt.  2 root root    6 Sep 23 10:18 .X11-unix
drwxrwxrwt.  2 root root    6 Sep 23 10:18 .XIM-unix

mytunguyen avatar Feb 27 '17 19:02 mytunguyen

@mytunguyen We've improved a lot the cleaning. The NVD data present in this folder, as well as the Alpine and Ubuntu data are expected to be there until Clair stops (https://github.com/coreos/clair/blob/master/updater.go#L153).

This speeds up consecutive updates tremendously.

Quentin-M avatar Mar 02 '17 02:03 Quentin-M

We also have the same issue. We are running Harbor which uses a Clair container. The /tmp dir inside the Clair container continuously grows and has reached 100 GB. We don't regularly stop Clair unless we're upgrading Harbor so some method where Clair can clean itself up while running would be really helpful.

troy256 avatar Aug 20 '19 17:08 troy256

Would you consider some kind of disk space policy so this cache does not grow without bound?

AstraLuma avatar Sep 10 '20 18:09 AstraLuma

Would you consider some kind of disk space policy so this cache does not grow without bound?

+1

soninob avatar Sep 13 '20 07:09 soninob

Hello,

We've been running Clair in our staging environment for a couple of months with an update frequency of 2 hours. Right now, our /tmp directory is over 20 gigabytes. As a workaround we will reduce the frequency of updates as well as create a cron job to clean it periodically.

However, I think Clair could do this cleanup after itself. There is no need to have those files in the /tmp after they are used to update the database.

I would like to know your thoughts about this. Thanks!

https://github.com/goharbor/harbor/issues/8474#issuecomment-1091659082

leofang94 avatar Apr 07 '22 12:04 leofang94