Handle job error responses on mgm side

This commit is contained in:
Zoltán Papp
2025-11-17 11:49:46 +01:00
parent 9cdfb0d78c
commit a1457f541b
2 changed files with 8 additions and 6 deletions

View File

@@ -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]

View File

@@ -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)