fix(cron): log CreateLongerRecords errors (#1926)

chore(cron): comment cron tasks with pocketbase warning
This commit is contained in:
Lars Lehtonen
2026-08-14 10:40:28 -04:00
committed by GitHub
parent cf90249519
commit 6d0b83f6de
2 changed files with 6 additions and 2 deletions
+5 -2
View File
@@ -3,7 +3,7 @@ package records
import (
"encoding/json"
"log"
"log/slog"
"math"
"time"
@@ -68,15 +68,18 @@ func (rm *RecordManager) CreateLongerRecords() {
},
}
// wrap the operations in a transaction
// Pocketbase cron does not handle errors, log them here.
rm.app.RunInTransaction(func(txApp core.App) error {
var err error
collections := [2]*core.Collection{}
collections[0], err = txApp.FindCachedCollectionByNameOrId("system_stats")
if err != nil {
slog.Error("Error finding cached collection using system stats:", "err", err)
return err
}
collections[1], err = txApp.FindCachedCollectionByNameOrId("container_stats")
if err != nil {
slog.Error("Error finding cached collection using container stats:", "err", err)
return err
}
var systems RecordIds
@@ -142,7 +145,7 @@ func (rm *RecordManager) CreateLongerRecords() {
longerRecord.Set("stats", rm.AverageContainerStats(db, recordIds))
}
if err := txApp.SaveNoValidate(longerRecord); err != nil {
log.Println("failed to save longer record", "err", err)
slog.Error("failed to save longer record", "err", err)
}
}
}
+1
View File
@@ -12,6 +12,7 @@ import (
// Delete old records
func (rm *RecordManager) DeleteOldRecords() {
// Pocketbase cron does not handle errors, log them here.
rm.app.RunInTransaction(func(txApp core.App) error {
err := deleteOldSystemStats(txApp)
if err != nil {