mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-19 15:19:55 +00:00
fix MarkPendingJobsAsFailed
This commit is contained in:
@@ -142,11 +142,11 @@ func (s *SqlStore) SaveJob(ctx context.Context, job *types.Job) error {
|
||||
|
||||
// job was pending for too long and has been cancelled
|
||||
// todo call it when we first start the jobChannel to make sure no stuck jobs
|
||||
func (s *SqlStore) MarkPendingJobsAsFailed(ctx context.Context) error {
|
||||
func (s *SqlStore) MarkPendingJobsAsFailed(ctx context.Context, peerID string) error {
|
||||
now := time.Now().UTC()
|
||||
return s.db.WithContext(ctx).
|
||||
Model(&types.Job{}).
|
||||
Where("status = ?", types.JobStatusPending).
|
||||
Where("peer_id = ? AND status = ?", types.JobStatusPending, peerID).
|
||||
Updates(map[string]any{
|
||||
"status": types.JobStatusFailed,
|
||||
"failed_reason": "Pending job cleanup: marked as failed automatically due to being stuck too long",
|
||||
|
||||
@@ -209,7 +209,7 @@ type Store interface {
|
||||
GetJobByID(ctx context.Context, accountID, jobID string) (*types.Job, error)
|
||||
GetJobs(ctx context.Context, accountID, peerID string) ([]*types.Job, error)
|
||||
CompleteJob(ctx context.Context, accountID, jobID, result string, failedReason string) error
|
||||
MarkPendingJobsAsFailed(ctx context.Context) error
|
||||
MarkPendingJobsAsFailed(ctx context.Context, peerID string) error
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user