mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
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:
1 parent
ec34160a1a
commit
40a95a8ef5
7 files changed
+271
-18
No files matched your search
@@ -70,6 +70,47 @@ func filterActivitiesByLane(activities []plugin.JobActivity, laneFilter string)
|
||||
return filtered
|
||||
}
|
||||
|
||||
func parseVolumeIDFilter(raw string) (uint32, error) {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" {
|
||||
return 0, nil
|
||||
}
|
||||
value, err := strconv.ParseUint(raw, 10, 32)
|
||||
if err != nil || value == 0 {
|
||||
return 0, fmt.Errorf("invalid volume_id %q", raw)
|
||||
}
|
||||
return uint32(value), nil
|
||||
}
|
||||
|
||||
func filterTrackedJobsByVolume(jobs []plugin.TrackedJob, volumeID uint32) []plugin.TrackedJob {
|
||||
if volumeID == 0 {
|
||||
return jobs
|
||||
}
|
||||
|
||||
filtered := make([]plugin.TrackedJob, 0, len(jobs))
|
||||
for _, job := range jobs {
|
||||
if job.VolumeID == volumeID {
|
||||
filtered = append(filtered, job)
|
||||
}
|
||||
}
|
||||
return filtered
|
||||
}
|
||||
|
||||
func filterActivitiesByJobs(activities []plugin.JobActivity, jobs []plugin.TrackedJob) []plugin.JobActivity {
|
||||
jobIDs := make(map[string]struct{}, len(jobs))
|
||||
for _, job := range jobs {
|
||||
jobIDs[job.JobID] = struct{}{}
|
||||
}
|
||||
|
||||
filtered := make([]plugin.JobActivity, 0, len(activities))
|
||||
for _, activity := range activities {
|
||||
if _, ok := jobIDs[activity.JobID]; ok {
|
||||
filtered = append(filtered, activity)
|
||||
}
|
||||
}
|
||||
return filtered
|
||||
}
|
||||
|
||||
// GetPluginStatusAPI returns plugin status.
|
||||
func (s *AdminServer) GetPluginStatusAPI(w http.ResponseWriter, r *http.Request) {
|
||||
plugin := s.GetPlugin()
|
||||
@@ -153,10 +194,15 @@ func (s *AdminServer) GetPluginJobsAPI(w http.ResponseWriter, r *http.Request) {
|
||||
jobType := strings.TrimSpace(query.Get("job_type"))
|
||||
state := strings.TrimSpace(query.Get("state"))
|
||||
laneFilter := strings.TrimSpace(query.Get("lane"))
|
||||
volumeID, err := parseVolumeIDFilter(query.Get("volume_id"))
|
||||
if err != nil {
|
||||
writeJSONError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
limit := parsePositiveInt(query.Get("limit"), 200)
|
||||
// Apply the lane before the limit, or a busy lane's newest rows crowd out a quiet lane.
|
||||
// Apply the filters before the limit, or a busy lane's newest rows crowd out a quiet lane.
|
||||
listLimit := limit
|
||||
if laneFilter != "" {
|
||||
if laneFilter != "" || volumeID != 0 {
|
||||
listLimit = 0
|
||||
}
|
||||
jobs := s.ListPluginJobs(jobType, state, listLimit)
|
||||
@@ -165,6 +211,7 @@ func (s *AdminServer) GetPluginJobsAPI(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
jobs = filterTrackedJobsByLane(jobs, laneFilter)
|
||||
jobs = filterTrackedJobsByVolume(jobs, volumeID)
|
||||
if len(jobs) > limit {
|
||||
jobs = jobs[:limit]
|
||||
}
|
||||
@@ -261,9 +308,14 @@ func (s *AdminServer) GetPluginActivitiesAPI(w http.ResponseWriter, r *http.Requ
|
||||
query := r.URL.Query()
|
||||
jobType := strings.TrimSpace(query.Get("job_type"))
|
||||
laneFilter := strings.TrimSpace(query.Get("lane"))
|
||||
volumeID, err := parseVolumeIDFilter(query.Get("volume_id"))
|
||||
if err != nil {
|
||||
writeJSONError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
limit := parsePositiveInt(query.Get("limit"), 500)
|
||||
listLimit := limit
|
||||
if laneFilter != "" {
|
||||
if laneFilter != "" || volumeID != 0 {
|
||||
listLimit = 0
|
||||
}
|
||||
activities := s.ListPluginActivities(jobType, listLimit)
|
||||
@@ -272,6 +324,9 @@ func (s *AdminServer) GetPluginActivitiesAPI(w http.ResponseWriter, r *http.Requ
|
||||
return
|
||||
}
|
||||
activities = filterActivitiesByLane(activities, laneFilter)
|
||||
if volumeID != 0 {
|
||||
activities = filterActivitiesByJobs(activities, filterTrackedJobsByVolume(s.ListPluginJobs(jobType, "", 0), volumeID))
|
||||
}
|
||||
if len(activities) > limit {
|
||||
activities = activities[:limit]
|
||||
}
|
||||
|
||||
@@ -290,3 +290,75 @@ func TestPluginJobsAndActivitiesAPILimitAfterLaneFilter(t *testing.T) {
|
||||
t.Fatalf("default lane activities: got %d rows, want the limit of 2", len(rows))
|
||||
}
|
||||
}
|
||||
|
||||
func TestPluginJobsAndActivitiesAPIVolumeIDFilter(t *testing.T) {
|
||||
dataDir := t.TempDir()
|
||||
store, err := plugin.NewConfigStore(dataDir)
|
||||
if err != nil {
|
||||
t.Fatalf("NewConfigStore: %v", err)
|
||||
}
|
||||
now := time.Now()
|
||||
var jobs []plugin.TrackedJob
|
||||
var activities []plugin.JobActivity
|
||||
for i := 0; i < 6; i++ {
|
||||
jobType, jobID, volumeID := "erasure_coding", fmt.Sprintf("ec-%d", i), uint32(7)
|
||||
if i%2 == 1 {
|
||||
jobType, jobID, volumeID = "vacuum", fmt.Sprintf("vacuum-%d", i), uint32(8)
|
||||
}
|
||||
at := now.Add(-time.Duration(i) * time.Minute)
|
||||
jobs = append(jobs, plugin.TrackedJob{JobID: jobID, JobType: jobType, VolumeID: volumeID, State: plugin.StateSucceeded, UpdatedAt: &at})
|
||||
activities = append(activities, plugin.JobActivity{JobID: jobID, JobType: jobType, Message: "done", OccurredAt: &at})
|
||||
}
|
||||
if err := store.SaveTrackedJobs(jobs); err != nil {
|
||||
t.Fatalf("SaveTrackedJobs: %v", err)
|
||||
}
|
||||
if err := store.SaveActivities(activities); err != nil {
|
||||
t.Fatalf("SaveActivities: %v", err)
|
||||
}
|
||||
p, err := plugin.New(plugin.Options{DataDir: dataDir})
|
||||
if err != nil {
|
||||
t.Fatalf("plugin.New: %v", err)
|
||||
}
|
||||
defer p.Shutdown()
|
||||
s := &AdminServer{plugin: p}
|
||||
|
||||
get := func(handler http.HandlerFunc, url string, wantStatus int) []map[string]any {
|
||||
recorder := httptest.NewRecorder()
|
||||
handler(recorder, httptest.NewRequest(http.MethodGet, url, nil))
|
||||
if recorder.Code != wantStatus {
|
||||
t.Fatalf("%s: status %d, want %d", url, recorder.Code, wantStatus)
|
||||
}
|
||||
if wantStatus != http.StatusOK {
|
||||
return nil
|
||||
}
|
||||
var rows []map[string]any
|
||||
if err := json.Unmarshal(recorder.Body.Bytes(), &rows); err != nil {
|
||||
t.Fatalf("%s: %v", url, err)
|
||||
}
|
||||
return rows
|
||||
}
|
||||
idsOf := func(rows []map[string]any) []string {
|
||||
ids := make([]string, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
ids = append(ids, fmt.Sprint(row["job_id"]))
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
if ids := idsOf(get(s.GetPluginJobsAPI, "/api/plugin/jobs?limit=2&volume_id=8", http.StatusOK)); fmt.Sprint(ids) != "[vacuum-1 vacuum-3]" {
|
||||
t.Fatalf("volume 8 jobs: got %v", ids)
|
||||
}
|
||||
if ids := idsOf(get(s.GetPluginJobsAPI, "/api/plugin/jobs?volume_id=7&job_type=vacuum", http.StatusOK)); len(ids) != 0 {
|
||||
t.Fatalf("volume 7 vacuum jobs: got %v, want none", ids)
|
||||
}
|
||||
if ids := idsOf(get(s.GetPluginActivitiesAPI, "/api/plugin/activities?limit=2&volume_id=7", http.StatusOK)); fmt.Sprint(ids) != "[ec-0 ec-2]" {
|
||||
t.Fatalf("volume 7 activities: got %v", ids)
|
||||
}
|
||||
if ids := idsOf(get(s.GetPluginActivitiesAPI, "/api/plugin/activities?volume_id=9", http.StatusOK)); len(ids) != 0 {
|
||||
t.Fatalf("volume 9 activities: got %v, want none", ids)
|
||||
}
|
||||
for _, bad := range []string{"0", "-1", "abc", "4294967296"} {
|
||||
get(s.GetPluginJobsAPI, "/api/plugin/jobs?volume_id="+bad, http.StatusBadRequest)
|
||||
get(s.GetPluginActivitiesAPI, "/api/plugin/activities?volume_id="+bad, http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
@@ -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))
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -383,6 +383,7 @@ templ Plugin(page string, initialJob string, lane string) {
|
||||
<div class="card-header d-flex justify-content-between align-items-center flex-wrap gap-2">
|
||||
<h5 class="mb-0"><i class="bi bi-list me-2"></i>Job Queue</h5>
|
||||
<div class="d-flex gap-2 align-items-center flex-wrap">
|
||||
<input type="number" min="1" max="4294967295" step="1" autocomplete="off" class="form-control form-control-sm plugin-monitor-volume-filter" placeholder="Volume ID" title="Show only jobs of this volume" style="width: 130px;"/>
|
||||
<small class="text-muted">States: pending/assigned/running</small>
|
||||
</div>
|
||||
</div>
|
||||
@@ -451,6 +452,7 @@ templ Plugin(page string, initialJob string, lane string) {
|
||||
<div class="card-header d-flex justify-content-between align-items-center flex-wrap gap-2">
|
||||
<h5 class="mb-0"><i class="bi bi-list-check me-2"></i>Execution Jobs</h5>
|
||||
<div class="d-flex gap-2 align-items-center flex-wrap">
|
||||
<input type="number" min="1" max="4294967295" step="1" autocomplete="off" class="form-control form-control-sm plugin-monitor-volume-filter" placeholder="Volume ID" title="Show only jobs and activities of this volume" style="width: 130px;"/>
|
||||
<select class="form-select form-select-sm" id="plugin-monitor-job-state-filter" style="min-width: 180px;">
|
||||
<option value="">All States</option>
|
||||
<option value="assigned">Assigned</option>
|
||||
@@ -612,6 +614,7 @@ templ Plugin(page string, initialJob string, lane string) {
|
||||
activeSubTab: 'configuration',
|
||||
initialNavigationApplied: false,
|
||||
monitorExecutionJobState: '',
|
||||
monitorVolumeID: '',
|
||||
workers: [],
|
||||
jobs: [],
|
||||
activities: [],
|
||||
@@ -622,6 +625,10 @@ templ Plugin(page string, initialJob string, lane string) {
|
||||
allJobs: [],
|
||||
allActivities: [],
|
||||
monitorRowsScope: null,
|
||||
detectionActivities: [],
|
||||
detectionRowsScope: null,
|
||||
monitorRefreshSeq: 0,
|
||||
monitorCommittedRefreshID: 0,
|
||||
refreshError: '',
|
||||
loadedJobType: '',
|
||||
descriptor: null,
|
||||
@@ -643,6 +650,24 @@ templ Plugin(page string, initialJob string, lane string) {
|
||||
return url + sep + 'job_type=' + encodeURIComponent(jobType);
|
||||
}
|
||||
|
||||
function appendVolumeParam(url) {
|
||||
if (!state.monitorVolumeID) return url;
|
||||
var sep = url.indexOf('?') === -1 ? '?' : '&';
|
||||
return url + sep + 'volume_id=' + encodeURIComponent(state.monitorVolumeID);
|
||||
}
|
||||
|
||||
function readMonitorVolumeFilter(input) {
|
||||
if (input.validity && input.validity.badInput) {
|
||||
return null;
|
||||
}
|
||||
var value = String(input.value || '').trim();
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
var volumeID = /^[0-9]+$/.test(value) ? Number(value) : 0;
|
||||
return volumeID >= 1 && volumeID <= 4294967295 ? String(volumeID) : null;
|
||||
}
|
||||
|
||||
function getCSRFToken() {
|
||||
var meta = document.querySelector('meta[name="csrf-token"]');
|
||||
if (!meta) {
|
||||
@@ -1877,7 +1902,7 @@ templ Plugin(page string, initialJob string, lane string) {
|
||||
}
|
||||
|
||||
var filteredActivities = [];
|
||||
var activities = Array.isArray(state.activities) ? state.activities : [];
|
||||
var activities = Array.isArray(state.detectionActivities) ? state.detectionActivities : [];
|
||||
for (var i = 0; i < activities.length; i++) {
|
||||
var activity = activities[i] || {};
|
||||
var jobType = String(activity.job_type || '').trim();
|
||||
@@ -3102,28 +3127,42 @@ templ Plugin(page string, initialJob string, lane string) {
|
||||
// The newest 500 rows cluster-wide may hold none of the selected job type on a busy
|
||||
// cluster, so the job-type sub-tabs fetch their own server-side filtered window.
|
||||
var scopedJobType = monitorJobTypeScope();
|
||||
var sameScope = state.monitorRowsScope === scopedJobType;
|
||||
var scopedVolume = state.monitorVolumeID;
|
||||
var rowsScope = scopedJobType + '|' + scopedVolume;
|
||||
var scopedRows = scopedJobType || scopedVolume;
|
||||
var refreshID = ++state.monitorRefreshSeq;
|
||||
|
||||
// A failed request keeps its last rows; the rest still land and the failure is rethrown.
|
||||
// A failed request keeps the rows committed when this refresh lands; the rest still
|
||||
// land and the failure is rethrown.
|
||||
var failure = null;
|
||||
function keepOnFailure(promise, previous) {
|
||||
var failed = {};
|
||||
function keepOnFailure(promise) {
|
||||
return promise.catch(function(e) {
|
||||
failure = failure || e;
|
||||
return previous;
|
||||
return failed;
|
||||
});
|
||||
}
|
||||
function kept(value, previous) {
|
||||
return value === failed ? previous : value;
|
||||
}
|
||||
|
||||
var allJobsPromise = keepOnFailure(pluginRequest('GET', appendLaneParam('/api/plugin/jobs?limit=500')), state.allJobs);
|
||||
var allActivitiesPromise = keepOnFailure(pluginRequest('GET', appendLaneParam('/api/plugin/activities?limit=500')), state.allActivities);
|
||||
var jobsPromise = scopedJobType ? keepOnFailure(pluginRequest('GET', appendJobTypeParam(appendLaneParam('/api/plugin/jobs?limit=500'), scopedJobType)), sameScope ? state.jobs : null) : allJobsPromise;
|
||||
var activitiesPromise = scopedJobType ? keepOnFailure(pluginRequest('GET', appendJobTypeParam(appendLaneParam('/api/plugin/activities?limit=500'), scopedJobType)), sameScope ? state.activities : null) : allActivitiesPromise;
|
||||
var schedulerPromise = keepOnFailure(pluginRequest('GET', appendLaneParam('/api/plugin/scheduler-states')), state.schedulerStates);
|
||||
var allJobsPromise = keepOnFailure(pluginRequest('GET', appendLaneParam('/api/plugin/jobs?limit=500')));
|
||||
var allActivitiesPromise = keepOnFailure(pluginRequest('GET', appendLaneParam('/api/plugin/activities?limit=500')));
|
||||
var jobsPromise = scopedRows ? keepOnFailure(pluginRequest('GET', appendVolumeParam(appendJobTypeParam(appendLaneParam('/api/plugin/jobs?limit=500'), scopedJobType)))) : allJobsPromise;
|
||||
var activitiesPromise = scopedRows ? keepOnFailure(pluginRequest('GET', appendVolumeParam(appendJobTypeParam(appendLaneParam('/api/plugin/activities?limit=500'), scopedJobType)))) : allActivitiesPromise;
|
||||
// Detection scans belong to no job, so the volume filter would hide every one of them.
|
||||
var detectionActivitiesPromise = activitiesPromise;
|
||||
if (scopedVolume) {
|
||||
detectionActivitiesPromise = scopedJobType ? keepOnFailure(pluginRequest('GET', appendJobTypeParam(appendLaneParam('/api/plugin/activities?limit=500'), scopedJobType))) : allActivitiesPromise;
|
||||
}
|
||||
var schedulerPromise = keepOnFailure(pluginRequest('GET', appendLaneParam('/api/plugin/scheduler-states')));
|
||||
var schedulerStatusPromise = pluginRequest('GET', appendLaneParam('/api/plugin/scheduler-status'));
|
||||
|
||||
var allJobs = await allJobsPromise;
|
||||
var allActivities = await allActivitiesPromise;
|
||||
var jobs = await jobsPromise;
|
||||
var activities = await activitiesPromise;
|
||||
var detectionActivities = await detectionActivitiesPromise;
|
||||
var schedulerStates = await schedulerPromise;
|
||||
var schedulerStatus = null;
|
||||
try {
|
||||
@@ -3131,15 +3170,26 @@ templ Plugin(page string, initialJob string, lane string) {
|
||||
} catch (e) {
|
||||
schedulerStatus = null;
|
||||
}
|
||||
if (monitorJobTypeScope() !== scopedJobType) {
|
||||
if (monitorJobTypeScope() !== scopedJobType || state.monitorVolumeID !== scopedVolume || refreshID < state.monitorCommittedRefreshID) {
|
||||
return;
|
||||
}
|
||||
state.monitorCommittedRefreshID = refreshID;
|
||||
|
||||
var sameScope = state.monitorRowsScope === rowsScope;
|
||||
allJobs = kept(allJobs, state.allJobs);
|
||||
allActivities = kept(allActivities, state.allActivities);
|
||||
jobs = kept(jobs, sameScope ? state.jobs : null);
|
||||
activities = kept(activities, sameScope ? state.activities : null);
|
||||
detectionActivities = kept(detectionActivities, state.detectionRowsScope === scopedJobType ? state.detectionActivities : null);
|
||||
schedulerStates = kept(schedulerStates, state.schedulerStates);
|
||||
|
||||
state.allJobs = Array.isArray(allJobs) ? allJobs : [];
|
||||
state.allActivities = Array.isArray(allActivities) ? allActivities : [];
|
||||
state.jobs = Array.isArray(jobs) ? jobs : state.allJobs;
|
||||
state.activities = Array.isArray(activities) ? activities : state.allActivities;
|
||||
state.monitorRowsScope = scopedJobType;
|
||||
state.jobs = Array.isArray(jobs) ? jobs : (scopedVolume ? [] : state.allJobs);
|
||||
state.activities = Array.isArray(activities) ? activities : (scopedVolume ? [] : state.allActivities);
|
||||
state.monitorRowsScope = rowsScope;
|
||||
state.detectionActivities = Array.isArray(detectionActivities) ? detectionActivities : state.allActivities;
|
||||
state.detectionRowsScope = scopedJobType;
|
||||
state.schedulerStates = Array.isArray(schedulerStates) ? schedulerStates : [];
|
||||
state.schedulerStatus = schedulerStatus && schedulerStatus.scheduler ? schedulerStatus.scheduler : null;
|
||||
state.schedulerLock = schedulerStatus && schedulerStatus.lock ? schedulerStatus.lock : null;
|
||||
@@ -3202,6 +3252,28 @@ templ Plugin(page string, initialJob string, lane string) {
|
||||
});
|
||||
}
|
||||
|
||||
var monitorVolumeFilters = document.querySelectorAll('.plugin-monitor-volume-filter');
|
||||
for (var v = 0; v < monitorVolumeFilters.length; v++) {
|
||||
monitorVolumeFilters[v].addEventListener('change', async function(event) {
|
||||
var volumeID = readMonitorVolumeFilter(event.target);
|
||||
if (volumeID !== null) {
|
||||
state.monitorVolumeID = volumeID;
|
||||
}
|
||||
for (var k = 0; k < monitorVolumeFilters.length; k++) {
|
||||
monitorVolumeFilters[k].value = state.monitorVolumeID;
|
||||
}
|
||||
if (volumeID === null) {
|
||||
notify('Volume ID must be a whole number from 1 to 4294967295', 'warning');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await refreshJobsAndActivities();
|
||||
} catch (refreshErr) {
|
||||
notify('Monitoring refresh failed: ' + refreshErr.message, 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var expireBtn = document.getElementById('plugin-expire-job-btn');
|
||||
if (expireBtn) {
|
||||
expireBtn.addEventListener('click', function() {
|
||||
|
||||
@@ -109,7 +109,7 @@ func Plugin(page string, initialJob string, lane string) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<div class=\"plugin-section plugin-section-overview\"><div class=\"row mb-4\"><div class=\"col-md-3 mb-3\"><div class=\"card border-info h-100\"><div class=\"card-body text-center\"><div class=\"text-uppercase text-muted small mb-1\">Workers</div><h4 class=\"mb-0\" id=\"plugin-status-workers\">0</h4></div></div></div><div class=\"col-md-3 mb-3\"><div class=\"card border-warning h-100\"><div class=\"card-body text-center\"><div class=\"text-uppercase text-muted small mb-1\">Active Jobs</div><h4 class=\"mb-0\" id=\"plugin-status-active-jobs\">0</h4></div></div></div><div class=\"col-md-3 mb-3\"><div class=\"card border-success h-100\"><div class=\"card-body text-center\"><div class=\"text-uppercase text-muted small mb-1\">Activities (recent)</div><h4 class=\"mb-0\" id=\"plugin-status-activities\">0</h4></div></div></div><div class=\"col-md-3 mb-3\"><div class=\"card border-secondary h-100\"><div class=\"card-body text-center\"><div class=\"text-uppercase text-muted small mb-1\">Next scheduled check</div><h4 class=\"mb-0 plugin-scheduler-next-run\">-</h4><div class=\"text-muted small plugin-scheduler-next-run-meta\"></div></div></div></div></div><div class=\"row mb-4\"><div class=\"col-12\"><div class=\"card shadow-sm\"><div class=\"card-header\"><h5 class=\"mb-0\"><i class=\"bi bi-bar-chart me-2\"></i>Per Job Type Summary</h5></div><div class=\"card-body p-0\"><div class=\"table-responsive\"><table class=\"table table-sm table-hover mb-0\"><thead class=\"table-light\"><tr><th>Job Type</th><th>Active Jobs</th><th>Recent Activities</th></tr></thead> <tbody id=\"plugin-jobtype-summary-body\"><tr><td colspan=\"3\" class=\"text-muted text-center py-3\">Loading...</td></tr></tbody></table></div></div></div></div></div><div class=\"row mb-4\"><div class=\"col-12\"><div class=\"card shadow-sm\"><div class=\"card-header d-flex justify-content-between align-items-center flex-wrap gap-2\"><h5 class=\"mb-0\"><i class=\"bi bi-clock me-2\"></i>Scheduler State</h5><small class=\"text-muted\">Sequential scheduler with per-job runtime limits</small></div><div class=\"card-body p-0\"><div class=\"table-responsive\"><table class=\"table table-sm table-hover mb-0\"><thead class=\"table-light\"><tr><th>Job Type</th><th>Enabled</th><th>Detector</th><th>In Flight</th><th>Max Runtime</th><th>Exec Global</th><th>Exec/Worker</th><th>Executor Workers</th><th>Effective Exec</th><th>Last Run</th></tr></thead> <tbody id=\"plugin-scheduler-table-body\"><tr><td colspan=\"10\" class=\"text-muted text-center py-3\">Loading...</td></tr></tbody></table></div></div></div></div></div><div class=\"row mb-4\"><div class=\"col-12\"><div class=\"card shadow-sm\"><div class=\"card-header\"><h5 class=\"mb-0\"><i class=\"bi bi-people me-2\"></i>Workers</h5></div><div class=\"card-body p-0\"><div class=\"table-responsive\" style=\"max-height: 560px; overflow-y: auto;\"><table class=\"table table-sm table-hover mb-0\"><thead class=\"table-light sticky-top\"><tr><th>Worker</th><th>Address</th><th>Capabilities</th><th>Load</th></tr></thead> <tbody id=\"plugin-workers-table-body\"><tr><td colspan=\"4\" class=\"text-muted text-center py-3\">Loading...</td></tr></tbody></table></div></div></div></div></div></div><div class=\"plugin-section plugin-section-configuration\"><div class=\"row mb-4\"><div class=\"col-lg-8 mb-3\"><div class=\"card shadow-sm h-100\"><div class=\"card-header d-flex justify-content-between align-items-center\"><h5 class=\"mb-0\"><i class=\"bi bi-sliders me-2\"></i>Job Type Configuration</h5><small class=\"text-muted\" id=\"plugin-config-updated-at\">Not loaded</small></div><div class=\"card-body\"><div class=\"mb-3\"><div class=\"small text-muted\">Selected Job Type</div><div class=\"fw-semibold\" id=\"plugin-selected-job-type\">-</div></div><div class=\"mb-3\"><div class=\"d-flex justify-content-between align-items-center mb-2\"><h6 class=\"mb-0\">Descriptor</h6><button type=\"button\" class=\"btn btn-sm btn-outline-secondary\" id=\"plugin-refresh-schema-btn\"><i class=\"bi bi-cloud-download me-1\"></i>Refresh Schema</button></div><div class=\"alert alert-light border\" id=\"plugin-descriptor-summary\">Select a job type to load schema and config.</div></div><div class=\"mb-3\"><h6>Admin Config Form</h6><div id=\"plugin-admin-config-form\" class=\"plugin-form-root\"><div class=\"text-muted\">No admin form loaded.</div></div></div><div class=\"mb-3\"><h6>Worker Config Form</h6><div id=\"plugin-worker-config-form\" class=\"plugin-form-root\"><div class=\"text-muted\">No worker form loaded.</div></div></div><div class=\"d-flex flex-wrap gap-2\"><button type=\"button\" class=\"btn btn-primary\" id=\"plugin-save-config-btn\"><i class=\"bi bi-floppy me-1\"></i>Save Config</button> <button type=\"button\" class=\"btn btn-outline-primary\" id=\"plugin-trigger-detection-btn\"><i class=\"bi bi-search me-1\"></i>Run Detection</button> <button type=\"button\" class=\"btn btnLine truncated
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<div class=\"plugin-section plugin-section-overview\"><div class=\"row mb-4\"><div class=\"col-md-3 mb-3\"><div class=\"card border-info h-100\"><div class=\"card-body text-center\"><div class=\"text-uppercase text-muted small mb-1\">Workers</div><h4 class=\"mb-0\" id=\"plugin-status-workers\">0</h4></div></div></div><div class=\"col-md-3 mb-3\"><div class=\"card border-warning h-100\"><div class=\"card-body text-center\"><div class=\"text-uppercase text-muted small mb-1\">Active Jobs</div><h4 class=\"mb-0\" id=\"plugin-status-active-jobs\">0</h4></div></div></div><div class=\"col-md-3 mb-3\"><div class=\"card border-success h-100\"><div class=\"card-body text-center\"><div class=\"text-uppercase text-muted small mb-1\">Activities (recent)</div><h4 class=\"mb-0\" id=\"plugin-status-activities\">0</h4></div></div></div><div class=\"col-md-3 mb-3\"><div class=\"card border-secondary h-100\"><div class=\"card-body text-center\"><div class=\"text-uppercase text-muted small mb-1\">Next scheduled check</div><h4 class=\"mb-0 plugin-scheduler-next-run\">-</h4><div class=\"text-muted small plugin-scheduler-next-run-meta\"></div></div></div></div></div><div class=\"row mb-4\"><div class=\"col-12\"><div class=\"card shadow-sm\"><div class=\"card-header\"><h5 class=\"mb-0\"><i class=\"bi bi-bar-chart me-2\"></i>Per Job Type Summary</h5></div><div class=\"card-body p-0\"><div class=\"table-responsive\"><table class=\"table table-sm table-hover mb-0\"><thead class=\"table-light\"><tr><th>Job Type</th><th>Active Jobs</th><th>Recent Activities</th></tr></thead> <tbody id=\"plugin-jobtype-summary-body\"><tr><td colspan=\"3\" class=\"text-muted text-center py-3\">Loading...</td></tr></tbody></table></div></div></div></div></div><div class=\"row mb-4\"><div class=\"col-12\"><div class=\"card shadow-sm\"><div class=\"card-header d-flex justify-content-between align-items-center flex-wrap gap-2\"><h5 class=\"mb-0\"><i class=\"bi bi-clock me-2\"></i>Scheduler State</h5><small class=\"text-muted\">Sequential scheduler with per-job runtime limits</small></div><div class=\"card-body p-0\"><div class=\"table-responsive\"><table class=\"table table-sm table-hover mb-0\"><thead class=\"table-light\"><tr><th>Job Type</th><th>Enabled</th><th>Detector</th><th>In Flight</th><th>Max Runtime</th><th>Exec Global</th><th>Exec/Worker</th><th>Executor Workers</th><th>Effective Exec</th><th>Last Run</th></tr></thead> <tbody id=\"plugin-scheduler-table-body\"><tr><td colspan=\"10\" class=\"text-muted text-center py-3\">Loading...</td></tr></tbody></table></div></div></div></div></div><div class=\"row mb-4\"><div class=\"col-12\"><div class=\"card shadow-sm\"><div class=\"card-header\"><h5 class=\"mb-0\"><i class=\"bi bi-people me-2\"></i>Workers</h5></div><div class=\"card-body p-0\"><div class=\"table-responsive\" style=\"max-height: 560px; overflow-y: auto;\"><table class=\"table table-sm table-hover mb-0\"><thead class=\"table-light sticky-top\"><tr><th>Worker</th><th>Address</th><th>Capabilities</th><th>Load</th></tr></thead> <tbody id=\"plugin-workers-table-body\"><tr><td colspan=\"4\" class=\"text-muted text-center py-3\">Loading...</td></tr></tbody></table></div></div></div></div></div></div><div class=\"plugin-section plugin-section-configuration\"><div class=\"row mb-4\"><div class=\"col-lg-8 mb-3\"><div class=\"card shadow-sm h-100\"><div class=\"card-header d-flex justify-content-between align-items-center\"><h5 class=\"mb-0\"><i class=\"bi bi-sliders me-2\"></i>Job Type Configuration</h5><small class=\"text-muted\" id=\"plugin-config-updated-at\">Not loaded</small></div><div class=\"card-body\"><div class=\"mb-3\"><div class=\"small text-muted\">Selected Job Type</div><div class=\"fw-semibold\" id=\"plugin-selected-job-type\">-</div></div><div class=\"mb-3\"><div class=\"d-flex justify-content-between align-items-center mb-2\"><h6 class=\"mb-0\">Descriptor</h6><button type=\"button\" class=\"btn btn-sm btn-outline-secondary\" id=\"plugin-refresh-schema-btn\"><i class=\"bi bi-cloud-download me-1\"></i>Refresh Schema</button></div><div class=\"alert alert-light border\" id=\"plugin-descriptor-summary\">Select a job type to load schema and config.</div></div><div class=\"mb-3\"><h6>Admin Config Form</h6><div id=\"plugin-admin-config-form\" class=\"plugin-form-root\"><div class=\"text-muted\">No admin form loaded.</div></div></div><div class=\"mb-3\"><h6>Worker Config Form</h6><div id=\"plugin-worker-config-form\" class=\"plugin-form-root\"><div class=\"text-muted\">No worker form loaded.</div></div></div><div class=\"d-flex flex-wrap gap-2\"><button type=\"button\" class=\"btn btn-primary\" id=\"plugin-save-config-btn\"><i class=\"bi bi-floppy me-1\"></i>Save Config</button> <button type=\"button\" class=\"btn btn-outline-primary\" id=\"plugin-trigger-detection-btn\"><i class=\"bi bi-search me-1\"></i>Run Detection</button> <button type=\"button\" class=\"btn btnLine truncated
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user