Skip to content

Modern Docker Management, Designed for Everyone

fix: add missing job commands to edge tunnel

Kyle Mendell6af4589a1237
diff --git a/backend/internal/job/runtime_status.go b/backend/internal/job/runtime_status.go
index 45ae4cea4..6beb36ce2 100644
--- a/backend/internal/job/runtime_status.go
+++ b/backend/internal/job/runtime_status.go
@@ -140,6 +140,10 @@ func applyRunStatusInternal(status *jobschedule.JobStatus, runs []st.Run) {
}
}
}
+ if current := status.CurrentRun; current != nil && current.Status == st.NeedsAttention {
+ status.CurrentRun = nil
+ updateLatestRunInternal(status, *current)
+ }
for _, run := range runs {
updateLatestRunInternal(status, run)
updateLastSuccessInternal(status, run)
@@ -151,14 +155,14 @@ func applyRunStatusInternal(status *jobschedule.JobStatus, runs []st.Run) {
}
func updateLatestRunInternal(status *jobschedule.JobStatus, run st.Run) {
- if !run.Status.Terminal() {
+ if !run.Status.Terminal() && run.Status != st.NeedsAttention {
if status.CurrentRun == nil || preferCurrentRunInternal(run, *status.CurrentRun) {
status.CurrentRun = new(run)
}
return
}
current := status.CurrentRun
- if current != nil && current.ID == run.ID && run.UpdatedAt.After(current.UpdatedAt) && (!run.RemoteAccepted || run.RemoteSettled) {
+ if current != nil && current.ID == run.ID && !run.UpdatedAt.Before(current.UpdatedAt) && (run.Status == st.NeedsAttention || !run.RemoteAccepted || run.RemoteSettled) {
status.CurrentRun = nil
}
if status.LastRun == nil || run.UpdatedAt.After(status.LastRun.UpdatedAt) {
@@ -206,9 +210,9 @@ func currentRunPriorityInternal(status st.RunStatus) int {
switch status {
case st.Running:
return 0
- case st.NeedsAttention:
+ case st.Queued, st.Waiting, st.Retrying:
return 1
- case st.Queued, st.Waiting, st.Retrying, st.Succeeded, st.Partial, st.Skipped, st.Failed, st.Canceled:
+ case st.NeedsAttention, st.Succeeded, st.Partial, st.Skipped, st.Failed, st.Canceled:
return 2
default:
return 2
diff --git a/backend/pkg/libarcane/edge/commands.go b/backend/pkg/libarcane/edge/commands.go
index 079e1fae5..09772e562 100644
--- a/backend/pkg/libarcane/edge/commands.go
+++ b/backend/pkg/libarcane/edge/commands.go
@@ -160,6 +160,13 @@ var commandRoutes = []commandRoute{
{Method: http.MethodPut, PathPattern: "/api/environments/{id}/job-schedules", CommandName: "job_schedule.upsert"},
{Method: http.MethodGet, PathPattern: "/api/environments/{id}/jobs", CommandName: "job.list"},
{Method: http.MethodPost, PathPattern: "/api/environments/{id}/jobs/{jobId}/run", CommandName: "job.run"},
+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/jobs/{jobId}/runs", CommandName: "job.run.list"},
+ {Method: http.MethodGet, PathPattern: "/api/environments/{id}/jobs/{jobId}/runs/{runId}", CommandName: "job.run.inspect"},
+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/jobs/{jobId}/runs/{runId}/retry", CommandName: "job.run.retry"},
+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/jobs/{jobId}/runs/{runId}/cancel", CommandName: "job.run.cancel"},
+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/jobs/{jobId}/runs/{runId}/resolve", CommandName: "job.run.resolve"},
+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/jobs/{jobId}/runs/{runId}/ack", CommandName: "job.run.ack"},
+ {Method: http.MethodPost, PathPattern: "/api/environments/{id}/jobs/{jobId}/restart", CommandName: "job.worker.restart"},
{Method: http.MethodGet, PathPattern: "/api/environments/{id}/notifications/settings", CommandName: "notification.settings.list"},
{Method: http.MethodGet, PathPattern: "/api/environments/{id}/notifications/settings/{provider}", CommandName: "notification.settings.get"},
diff --git a/backend/pkg/scheduler/auto_update_job.go b/backend/pkg/scheduler/auto_update_job.go
index bbcd35460..8f724466c 100644
--- a/backend/pkg/scheduler/auto_update_job.go
+++ b/backend/pkg/scheduler/auto_update_job.go
@@ -125,7 +125,7 @@ func (j *AutoUpdateJob) Reschedule(ctx context.Context) error {
func (j *AutoUpdateJob) Reconcile(_ context.Context, previous schedulertypes.Run) (schedulertypes.Outcome, error) {
confirmed := confirmedAutoUpdateInternal(previous)
if confirmed.Status != schedulertypes.Succeeded {
- confirmed.Message = "Interrupted auto-update has no confirmed full-batch completion; review and resolve this run to resume the schedule"
+ confirmed.Message = "Interrupted auto-update has no confirmed full-batch completion; review this run's results"
if previous.Outcome.Message != "" {
confirmed.Message += ": " + previous.Outcome.Message
}
@@ -167,7 +167,7 @@ func autoUpdateRetryOptionsInternal(previous schedulertypes.Run) (updatertypes.O
return options, schedulertypes.Outcome{Status: schedulertypes.NeedsAttention, Message: "Target results do not confirm full-batch completion; review and resolve this run", ActivityID: previous.Outcome.ActivityID, Targets: previous.Outcome.Targets}, true
}
if !hasResourceTargets {
- return options, schedulertypes.Outcome{Status: schedulertypes.NeedsAttention, Message: "The previous update has no confirmed retry targets; review and resolve this run to resume the schedule", ActivityID: previous.Outcome.ActivityID, Targets: previous.Outcome.Targets}, true
+ return options, schedulertypes.Outcome{Status: schedulertypes.NeedsAttention, Message: "The previous update has no confirmed retry targets; review this run's results", ActivityID: previous.Outcome.ActivityID, Targets: previous.Outcome.Targets}, true
}
if len(options.ResourceIds) > 0 {
options.Type = "container"
@@ -215,7 +215,7 @@ func autoUpdateOutcomeInternal(ctx context.Context, result *updatertypes.Result,
}
if unresolvedTargets {
outcome.Status = schedulertypes.NeedsAttention
- outcome.Message = "Unconfirmed targets remain; review and resolve this run to resume the schedule"
+ outcome.Message = "Unconfirmed targets remain; review this run's results"
}
var outcomeErr *schedulertypes.OutcomeError
if errors.As(err, &outcomeErr) {
diff --git a/backend/pkg/scheduler/queue/queue.go b/backend/pkg/scheduler/queue/queue.go
index 95ce64742..290b4b49d 100644
--- a/backend/pkg/scheduler/queue/queue.go
+++ b/backend/pkg/scheduler/queue/queue.go
@@ -75,7 +75,7 @@ func (q *Queue) Submit(ctx context.Context, request st.Request) (st.Run, error)
result = existing
return nil
}
- if request.Trigger != "manual" && request.Trigger != "remote" && existing.Trigger != "manual" && existing.Trigger != "remote" && !existing.Status.Terminal() && existing.Status != st.Running {
+ if request.Trigger != "manual" && request.Trigger != "remote" && existing.Trigger != "manual" && existing.Trigger != "remote" && !existing.Status.Terminal() && existing.Status != st.Running && existing.Status != st.NeedsAttention {
result = existing
return nil
}
@@ -114,7 +114,7 @@ func (q *Queue) Checkpoint(ctx context.Context, jobID, schedule string, next tim
if first && record.Schedule == schedule && !record.NextRun.IsZero() && !record.NextRun.After(now) && record.LastEnqueuedAt.Before(record.NextRun) {
pending := false
for _, run := range record.Runs {
- if !run.Status.Terminal() {
+ if !run.Status.Terminal() && run.Status != st.NeedsAttention {
pending = true
break
}
@@ -439,7 +439,7 @@ func (q *Queue) nextRunInternal(runs []st.Run) (*st.Run, time.Time) {
blocked := false
for index := range runs {
run := &runs[index]
- if run.Status == st.NeedsAttention || (run.Status == st.Running && run.Owner == q.owner) {
+ if run.Status == st.Running && run.Owner == q.owner {
blocked = true
}
if run.Status == st.Running && run.Owner != q.owner && interrupted == nil {
@@ -453,7 +453,7 @@ func (q *Queue) nextRunInternal(runs []st.Run) (*st.Run, time.Time) {
now := time.Now()
for index := range runs {
run := &runs[index]
- if run.Status.Terminal() {
+ if run.Status.Terminal() || run.Status == st.NeedsAttention {
continue
}
if run.NextAttempt == nil || !run.NextAttempt.After(now) {
diff --git a/backend/pkg/scheduler/queue/resolution_test.go b/backend/pkg/scheduler/queue/resolution_test.go
index 43f9db08f..80a8ad015 100644
--- a/backend/pkg/scheduler/queue/resolution_test.go
+++ b/backend/pkg/scheduler/queue/resolution_test.go
@@ -24,7 +24,7 @@ func newResolutionQueueInternal(t *testing.T) *Queue {
return New(kv.NewKVService(&database.DB{DB: db}), nil, nil)
}
-func TestResolvePreservesEvidenceAndUnblocksSchedule(t *testing.T) {
+func TestResolvePreservesEvidenceWithoutBlockingSchedule(t *testing.T) {
q := newResolutionQueueInternal(t)
ctx := t.Context()
run, err := q.Submit(ctx, st.Request{JobID: "auto-update", Trigger: "manual"})
@@ -42,7 +42,8 @@ func TestResolvePreservesEvidenceAndUnblocksSchedule(t *testing.T) {
history, err := q.List(ctx, "0", "auto-update", 1, 20)
require.NoError(t, err)
selected, _ := q.nextRunInternal(history.Runs)
- require.Nil(t, selected)
+ require.NotNil(t, selected)
+ require.Equal(t, pending.ID, selected.ID)
for len(q.wake) > 0 {
<-q.wake
}