Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary files are not getting deleted #1221

Closed
isavitsky opened this issue May 10, 2024 · 4 comments
Closed

Temporary files are not getting deleted #1221

isavitsky opened this issue May 10, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@isavitsky
Copy link

Bug description

Temporary files networks*.csv.gz are not getting cleaned from the temporary directory, causing disk space to fill up with gigabytes of unused files.

Akvorado version:

akvorado v1.10.2-73-gcf6726c1-dirty
  Built with: go1.21.9 X:loopvar

Steps to reproduce the problem

docker compose up -d

Expected outcome

Temporary files are getting deleted from corresponding docker volumes when not in use.

Current outcome

In a few days' time after starting up docker containers:

sudo find /var/lib/docker -name "networks*.csv.gz" | wc -l
908

The possible cause could be the Akvorado container(s) restarting.

Preliminary patch to solve the problem:

diff --git a/orchestrator/clickhouse/networks.go b/orchestrator/clickhouse/networks.go
index 0fec4892..675a6a6d 100644
--- a/orchestrator/clickhouse/networks.go
+++ b/orchestrator/clickhouse/networks.go
@@ -126,6 +126,7 @@ func (c *Component) networksCSVRefresher() {
                        c.r.Err(err).Msg("cannot create temporary file for networks.csv")
                        return
                }
+               defer os.Remove(tmpfile.Name())

                // Write a gzip dump to the disk
                gzipWriter := gzip.NewWriter(tmpfile)

@isavitsky isavitsky added the bug Something isn't working label May 10, 2024
@vincentbernat
Copy link
Member

The file should not be removed as it is the one that is used at the end. It should be automatically removed when rotated and also on shutdown. I don't have the issue on my own installation.

@vincentbernat
Copy link
Member

On another install, I have leftover files. I don't know exactly what may trigger that, maybe a slow shutdown. I'll think of a better way to cleanup.

@isavitsky
Copy link
Author

I've conducted a few tests on two akvorado VMs (patched and unpatched) and can now confirm that my patch is ineffective against OOM events when containers get killed due to lack of memory.
I think there ought to be another way of dealing with this problem…

@vincentbernat
Copy link
Member

I'll add some cleanup on start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants