Fix Run file capability negotiation

This commit is contained in:
npc0-hue
2026-08-25 23:16:02 +08:00
parent a90474f896
commit 3f493bb78c
2 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -611,7 +611,7 @@ func firstEligibleSupportedJob(jobs []domain.Job, capabilities []string, stamp t
if !eligible || !job.CancelRequestedAt.IsZero() { if !eligible || !job.CancelRequestedAt.IsZero() {
continue continue
} }
if len(capabilitySet) > 0 && !isServerFileCapability(job.Capability) { if len(capabilitySet) > 0 {
if _, supported := capabilitySet[job.Capability]; !supported { if _, supported := capabilitySet[job.Capability]; !supported {
continue continue
} }
+7 -3
View File
@@ -98,7 +98,7 @@ func TestCoreServiceRunJobClaimNoJob(t *testing.T) {
} }
} }
func TestCoreServiceRunJobClaimAllowsServerFileCapabilityWithoutDeclaration(t *testing.T) { func TestCoreServiceRunJobClaimSkipsServerFileCapabilityWithoutDeclaration(t *testing.T) {
svc := newTestCoreService() svc := newTestCoreService()
plugin, endpoint := createPluginAndRunEndpoint(t, svc) plugin, endpoint := createPluginAndRunEndpoint(t, svc)
instance, err := svc.CreateServerInstance(domain.ServerInstance{ instance, err := svc.CreateServerInstance(domain.ServerInstance{
@@ -139,8 +139,12 @@ func TestCoreServiceRunJobClaimAllowsServerFileCapabilityWithoutDeclaration(t *t
if err != nil { if err != nil {
t.Fatalf("claim file list job: %v", err) t.Fatalf("claim file list job: %v", err)
} }
if !claim.Accepted || !claim.HasJob || claim.Job.JobID != "job-file-list" || claim.Job.Capability != domain.JobCapabilityFilesList { if !claim.Accepted || claim.HasJob || claim.Job != nil || claim.NextPollSeconds <= 0 {
t.Fatalf("expected file job claim without files.list declaration, got %+v", claim) t.Fatalf("expected unsupported file job to remain queued, got %+v", claim)
}
jobs, err := svc.store.Jobs().List(domain.JobFilter{RunEndpointID: endpoint.ID})
if err != nil || len(jobs) != 1 || jobs[0].State != domain.JobStateQueued {
t.Fatalf("expected unsupported file job to remain queued in storage, jobs=%+v err=%v", jobs, err)
} }
} }