admin: filter plugin jobs and activities by volume id (#13077)

* admin: keep the volume id on tracked plugin jobs

Volume-scoped jobs carry their volume in the volume_id parameter, but
the in-memory job list drops parameters, so nothing could select a
volume's jobs without reading every job detail file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: filter plugin jobs and activities by volume id

/api/plugin/jobs and /api/plugin/activities accept volume_id, applied
before the limit like the lane filter. Activities follow the tracked
jobs of that volume.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: volume id filter on the plugin monitor

A Volume ID box next to the execution state filter narrows the queue,
execution jobs and activities to that volume's jobs, fetched with the
volume_id API filter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: keep detection scans visible under the volume filter

Detection activities belong to no job, so the volume-filtered activity
window had none of them and the Detection Jobs table went empty. That
table now reads its own job-type window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: accept zero-padded volume ids in the monitor filter

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: drop a monitor refresh that finishes after a newer one

Two refreshes of the same scope can finish out of order; the older one
then replaced the newer rows, with empty lists when its volume-filtered
fetch failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: keep rows committed for the scope when a plugin monitor refresh fails

A failed request fell back to the rows captured when the refresh started,
so a refresh overlapping one that had already committed the new scope's
rows cleared them. Resolve the fallback when the refresh commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: validate the monitor volume id before fetching

Out-of-range ids went to the APIs and came back 400. The filter is now
applied only from a valid change event, so the periodic refresh no longer
reads a value still being typed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: volume id filter on the job queue view

The queue renders the volume-scoped rows, but the only filter box sat on
the execution view, so an active filter was invisible and could not be
cleared there. Both views now carry a box kept in sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: reject unparsable volume id text instead of clearing the filter

A number input holding text like "1e" reports an empty value with
validity.badInput set; treat it as invalid rather than as a cleared box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 authored and GitHub committed 2026-11-27 18:42:11 -08:00
1 parent ec34160a1a
commit 40a95a8ef5
7 files changed
+271 -18

No files matched your search

+8
View File
@@ -10,6 +10,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/pb/plugin_pb"
pluginworker "github.com/seaweedfs/seaweedfs/weed/plugin/worker"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/timestamppb"
)
@@ -805,6 +806,9 @@ func mergeTrackedStatusIntoDetail(detail *TrackedJob, tracked *TrackedJob) {
if detail.DedupeKey == "" {
detail.DedupeKey = tracked.DedupeKey
}
if detail.VolumeID == 0 {
detail.VolumeID = tracked.VolumeID
}
if detail.Summary == "" {
detail.Summary = tracked.Summary
}
@@ -942,6 +946,7 @@ func (r *Plugin) trackExecutionStart(requestID, workerID string, job *plugin_pb.
tracked.RequestID = requestID
tracked.WorkerID = workerID
tracked.DedupeKey = job.DedupeKey
tracked.VolumeID = pluginworker.ReadUint32Config(job.Parameters, "volume_id", 0)
tracked.Summary = job.Summary
tracked.State = strings.ToLower(plugin_pb.JobState_JOB_STATE_ASSIGNED.String())
tracked.Progress = 0
@@ -962,6 +967,7 @@ func (r *Plugin) trackExecutionStart(requestID, workerID string, job *plugin_pb.
detail.RequestID = requestID
detail.WorkerID = workerID
detail.DedupeKey = job.DedupeKey
detail.VolumeID = trackedSnapshot.VolumeID
detail.Summary = job.Summary
detail.Detail = job.Detail
detail.Parameters = enrichTrackedJobParameters(job.JobType, configValueMapToPlain(job.Parameters))
@@ -1017,6 +1023,7 @@ func (r *Plugin) trackExecutionQueued(job *plugin_pb.JobSpec) {
tracked.JobType = job.JobType
tracked.DedupeKey = job.DedupeKey
tracked.VolumeID = pluginworker.ReadUint32Config(job.Parameters, "volume_id", 0)
tracked.Summary = job.Summary
tracked.State = strings.ToLower(plugin_pb.JobState_JOB_STATE_PENDING.String())
tracked.Progress = 0
@@ -1034,6 +1041,7 @@ func (r *Plugin) trackExecutionQueued(job *plugin_pb.JobSpec) {
detail.JobID = job.JobId
detail.JobType = job.JobType
detail.DedupeKey = job.DedupeKey
detail.VolumeID = trackedSnapshot.VolumeID
detail.Summary = job.Summary
detail.Detail = job.Detail
detail.Parameters = enrichTrackedJobParameters(job.JobType, configValueMapToPlain(job.Parameters))
+45
View File
@@ -170,6 +170,51 @@ func TestTrackExecutionQueuedMarksPendingState(t *testing.T) {
}
}
func TestTrackedJobsKeepVolumeID(t *testing.T) {
t.Parallel()
pluginSvc, err := New(Options{})
if err != nil {
t.Fatalf("New: %v", err)
}
defer pluginSvc.Shutdown()
pluginSvc.trackExecutionQueued(&plugin_pb.JobSpec{
JobId: "job-ec-17",
JobType: "erasure_coding",
Parameters: map[string]*plugin_pb.ConfigValue{
"volume_id": {Kind: &plugin_pb.ConfigValue_Int64Value{Int64Value: 17}},
},
})
pluginSvc.trackExecutionStart("req-1", "worker-a", &plugin_pb.JobSpec{
JobId: "job-vacuum-23",
JobType: "vacuum",
Parameters: map[string]*plugin_pb.ConfigValue{
"volume_id": {Kind: &plugin_pb.ConfigValue_StringValue{StringValue: "23"}},
},
}, 1)
pluginSvc.trackExecutionQueued(&plugin_pb.JobSpec{JobId: "job-no-volume", JobType: "iceberg"})
want := map[string]uint32{"job-ec-17": 17, "job-vacuum-23": 23, "job-no-volume": 0}
jobs := pluginSvc.ListTrackedJobs("", "", 0)
if len(jobs) != len(want) {
t.Fatalf("expected %d tracked jobs, got %d", len(want), len(jobs))
}
for _, job := range jobs {
if job.VolumeID != want[job.JobID] {
t.Fatalf("job %s: volume id %d, want %d", job.JobID, job.VolumeID, want[job.JobID])
}
}
detail, found, err := pluginSvc.BuildJobDetail("job-ec-17", 10, 0)
if err != nil || !found || detail.Job == nil {
t.Fatalf("BuildJobDetail: found=%v err=%v", found, err)
}
if detail.Job.VolumeID != 17 {
t.Fatalf("detail volume id %d, want 17", detail.Job.VolumeID)
}
}
func TestHandleJobProgressUpdateCarriesWorkerIDInActivities(t *testing.T) {
t.Parallel()
+1
View File
@@ -44,6 +44,7 @@ type TrackedJob struct {
RequestID string `json:"request_id"`
WorkerID string `json:"worker_id"`
DedupeKey string `json:"dedupe_key,omitempty"`
VolumeID uint32 `json:"volume_id,omitempty"`
Summary string `json:"summary,omitempty"`
Detail string `json:"detail,omitempty"`
Parameters map[string]interface{} `json:"parameters,omitempty"`