mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-19 23:11:29 +02:00
Handle job error responses on mgm side
This commit is contained in:
@@ -6,11 +6,12 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/netbirdio/netbird/management/server/store"
|
||||
"github.com/netbirdio/netbird/management/server/telemetry"
|
||||
"github.com/netbirdio/netbird/management/server/types"
|
||||
"github.com/netbirdio/netbird/shared/management/proto"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const jobChannelBuffer = 100
|
||||
@@ -97,6 +98,7 @@ func (jm *JobManager) HandleResponse(ctx context.Context, resp *proto.JobRespons
|
||||
jm.mu.Lock()
|
||||
defer jm.mu.Unlock()
|
||||
|
||||
// todo: validate job ID and would be nice to use uuid text marshal instead of string
|
||||
jobID := string(resp.ID)
|
||||
|
||||
event, ok := jm.pending[jobID]
|
||||
|
||||
@@ -170,12 +170,12 @@ func (j *Job) ApplyResponse(resp *proto.JobResponse) error {
|
||||
j.Status = JobStatusSucceeded
|
||||
case proto.JobStatus_failed:
|
||||
j.Status = JobStatusFailed
|
||||
if len(resp.Reason) > 0 {
|
||||
j.FailedReason = fmt.Sprintf("Client error: '%v'", resp.Reason)
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
j.Status = JobStatusPending
|
||||
}
|
||||
|
||||
if len(resp.Reason) > 0 {
|
||||
j.FailedReason = string(resp.Reason)
|
||||
return fmt.Errorf("unexpected job status: %v", resp.Status)
|
||||
}
|
||||
|
||||
// Handle workload results (oneof)
|
||||
|
||||
Reference in New Issue
Block a user