Skip to content

Commit 9b162bf

Browse files
authored
feat(dashboard-api): flag sandboxes past data retention (#3102)
1 parent 711aa33 commit 9b162bf

6 files changed

Lines changed: 209 additions & 107 deletions

File tree

packages/dashboard-api/internal/api/api.gen.go

Lines changed: 92 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dashboard-api/internal/handlers/sandbox_record.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ func (s *APIStore) GetSandboxesSandboxIDRecord(c *gin.Context, sandboxID api.San
3131
telemetry.SetAttributes(ctx, telemetry.WithTeamID(teamID.String()), telemetry.WithSandboxID(sandboxID))
3232

3333
row, err := s.db.GetSandboxRecordByTeamAndSandboxID(ctx, queries.GetSandboxRecordByTeamAndSandboxIDParams{
34-
TeamID: teamID,
35-
SandboxID: sandboxID,
36-
CreatedAfter: time.Now().UTC().Add(-sandboxRecordRetention),
34+
TeamID: teamID,
35+
SandboxID: sandboxID,
3736
})
3837
if err != nil {
3938
if dberrors.IsNotFoundError(err) || isUndefinedTableError(err) {
@@ -53,16 +52,21 @@ func (s *APIStore) GetSandboxesSandboxIDRecord(c *gin.Context, sandboxID api.San
5352
alias = &row.Alias
5453
}
5554

55+
// The sandbox's monitoring, events, and logs data is purged once the
56+
// sandbox ended more than the retention window ago.
57+
retentionExpired := row.StoppedAt != nil && time.Since(*row.StoppedAt) > sandboxRecordRetention
58+
5659
c.JSON(http.StatusOK, api.SandboxRecord{
57-
TemplateID: row.TemplateID,
58-
Alias: alias,
59-
SandboxID: row.SandboxID,
60-
StartedAt: row.StartedAt,
61-
StoppedAt: row.StoppedAt,
62-
Domain: row.Domain,
63-
CpuCount: row.Vcpu,
64-
MemoryMB: row.RamMb,
65-
DiskSizeMB: row.TotalDiskSizeMb,
60+
TemplateID: row.TemplateID,
61+
Alias: alias,
62+
SandboxID: row.SandboxID,
63+
StartedAt: row.StartedAt,
64+
StoppedAt: row.StoppedAt,
65+
Domain: row.Domain,
66+
CpuCount: row.Vcpu,
67+
MemoryMB: row.RamMb,
68+
DiskSizeMB: row.TotalDiskSizeMb,
69+
RetentionExpired: retentionExpired,
6670
})
6771
}
6872

0 commit comments

Comments
 (0)