Skip to content

Conversation

@Sayan-
Copy link
Contributor

@Sayan- Sayan- commented Jul 28, 2025

Description

Allow folks to delete recordings. A concern for long running containers is the space used by recordings grows unbounded. We have ~some safeguards in place (e.g. total amount of space for a single recording, total amount of time for a single recording) but no way of actually marking recordings for clean up. I chose what felt like a simple path of "whoever is telling me to record can also tell me when to clean up". To be clear: this isn't meant to prevent all failure modes wrt storage but in typical workflows this should keep run times well within bounds

Testing

Units + end to end with our API


TL;DR

Added a new API endpoint and underlying functionality to allow users to delete recordings, addressing concerns about unbounded storage growth.

Why we made these changes

To provide a mechanism for cleaning up old recordings, preventing them from consuming excessive disk space, especially in long-running container environments.

What changed?

  • API Endpoint: Introduced a new /recordings/:id/delete endpoint to trigger recording deletion.
  • Recording Management:
    • Recorder interface now includes Delete and IsDeleted methods.
    • FFmpegRecorder implements deletion, removing associated files and marking recordings as deleted.
    • api.go prevents downloads of deleted recordings and handles deletion requests.
    • ListActiveRecorders now excludes deleted recordings.
  • OpenAPI: Updated openapi.yaml and regenerated oapi.go to reflect the new deletion endpoint.
  • Testing: api_test.go mock recorder updated to simulate deletion scenarios.

Validation

  • Unit tests for new and modified recording logic.
  • End-to-end API tests for the new deletion endpoint.

Copy link

@mesa-dot-dev mesa-dot-dev bot left a comment

Choose a reason for hiding this comment

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

What Changed

This PR introduces a new DELETE /recordings/{recorder_id} endpoint to allow for the deletion of recordings, addressing concerns about unbounded disk space usage. The implementation adds a Delete method to the Recorder interface and handles the file removal and status update asynchronously in a new goroutine within the DeleteRecording handler. The FFmpegRecorder is updated to track a deleted state to prevent further operations on deleted recordings.

Risks / Concerns

The primary concern is the use of the request's context within the asynchronous deletion goroutine in server/cmd/api/api/api.go. If the client cancels the request after the HTTP response is sent, the context will be cancelled, which could interrupt the file deletion process. It's recommended to use context.WithoutCancel(ctx) for this background task to ensure it runs to completion.

6 files reviewed | 1 comments | Review on Mesa | Edit Reviewer Settings

@Sayan- Sayan- requested a review from rgarcia July 28, 2025 17:08
@Sayan- Sayan- merged commit 52bfc43 into main Jul 28, 2025
2 checks passed
@Sayan- Sayan- deleted the sayan/deletion-endpoint branch July 28, 2025 21:08
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.

3 participants