Skip to content

AUT-686 - Adding tmpreaper for optional temp file cleanup - #1275

Merged
alexcottner merged 3 commits into
mainfrom
aut-686
Nov 5, 2026
Merged

alexcottner merged 3 commits into
mainfrom
aut-686

Conversation

@alexcottner

@alexcottner alexcottner commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

AUT-686

Adding an optional scheduled job to cleanup temp files. Using tmpreaper to keep things simple.

This is due to go not consistently cleaning up temp files that are involved in http responses. Only an issue for long running instances.

@alexcottner
alexcottner requested review from a team as code owners November 4, 2026 16:11
Comment thread tmpreaper.go
// Remove temp files that have not been accessed in the last 15 minutes
cmd := exec.Command("tmpreaper", "-a", "15m", os.TempDir())
err := cmd.Run()
if err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add debug log to see what files and their file size were.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the file paths, that's easy.

But for the file sizes, we don't have an easy way to do that using tmpreaper. I'd need to replace tmpreaper with some go code that would go over the temp files ourselves.

For now I'll add output from the tmpreaper command to list the paths it's removing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example output:

rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk2800557433.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk1689011704.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk861932279.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk533984321.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk3505681865.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk2094103173.idsig
rmdir /tmp/hsperfdata_app
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk3653607433.idsig
rm remotesettingsdev/remote-settings.content-signature.mozilla.org-2026-12-04-05-00-03.chain
rm remotesettingsdev/remote-settings.content-signature.mozilla.org-2026-12-04-04-49-32.chain
rm normandydev/normandy.content-signature.mozilla.org-2026-12-04-05-00-03.chain
rm normandydev/normandy.content-signature.mozilla.org-2026-12-04-04-49-32.chain
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk502597530.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk3875899127.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk528328939.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk2955558364.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk3510606547.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk1432556671.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk1634675701.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk644545883.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk1215753861.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk1368309012.idsig
rm /tmp/apk2_input_83d0006ea9e05d9344252bcae3f93a41d2d50d3065e1593d11c7215d983d9746.apk1212336375.idsig

Comment thread autograph-service.yaml Resolved
Comment thread tmpreaper.go Resolved

@say-yawn say-yawn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions to add debug line and up the temp storage time due to historical higher response time.

Comment thread tmpreaper.go
select {
case <-r.ticker.C:
r.cleanTmp()
case <-r.exit:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when the service exits? It seems like the files will just stick around?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That depends heavily on infra. Potential examples below:

  • If the temp path is an ephemeral volume, then everything gets dropped regardless
  • When autograph starts back up, then it will start the temp cleaning task again
  • If autograph is running on a machine (VM or dev system) that's restarting, then the temp drive is getting wiped at shutdown anyway

@alexcottner
alexcottner requested a review from say-yawn November 5, 2026 15:23

@say-yawn say-yawn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit on trying to get the file size. Thanks for explaining how the tmpreaper works.

@alexcottner
alexcottner merged commit 5c50860 into main Nov 5, 2026
15 checks passed
@alexcottner
alexcottner deleted the aut-686 branch November 5, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants