From 00dc68fb94791fb479cdd1932b9dd6793f14fefd Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Thu, 31 Jul 2025 16:05:38 +0200 Subject: pkg/coveragedb: update file to subsystem info periodically #6070 explains the problem of data propagation. 1. Add weekly /cron/update_coverdb_subsystems. 2. Stop updating subsystems from coverage receiver API. --- dashboard/app/api.go | 7 +------ dashboard/app/coverage.go | 21 +++++++++++++++++++++ dashboard/app/cron.yaml | 3 +++ dashboard/app/main.go | 1 + 4 files changed, 26 insertions(+), 6 deletions(-) (limited to 'dashboard/app') diff --git a/dashboard/app/api.go b/dashboard/app/api.go index c1d77881c..49c524c14 100644 --- a/dashboard/app/api.go +++ b/dashboard/app/api.go @@ -1963,12 +1963,7 @@ func apiSaveCoverage(c context.Context, payload io.Reader) (interface{}, error) if err := jsonDec.Decode(descr); err != nil { return 0, fmt.Errorf("json.NewDecoder(coveragedb.HistoryRecord).Decode: %w", err) } - var sss []*subsystem.Subsystem - if service := getNsConfig(c, descr.Namespace).Subsystems.Service; service != nil { - sss = service.List() - log.Infof(c, "found %d subsystems for %s namespace", len(sss), descr.Namespace) - } - rowsCreated, err := coveragedb.SaveMergeResult(c, getCoverageDBClient(c), descr, jsonDec, sss) + rowsCreated, err := coveragedb.SaveMergeResult(c, getCoverageDBClient(c), descr, jsonDec) if err != nil { log.Errorf(c, "error storing coverage for ns %s, date %s: %v", descr.Namespace, descr.DateTo.String(), err) diff --git a/dashboard/app/coverage.go b/dashboard/app/coverage.go index 4611a7977..67a4494e0 100644 --- a/dashboard/app/coverage.go +++ b/dashboard/app/coverage.go @@ -21,6 +21,7 @@ import ( "github.com/google/syzkaller/pkg/html/urlutil" "github.com/google/syzkaller/pkg/validator" "google.golang.org/appengine/v2" + "google.golang.org/appengine/v2/log" ) var coverageDBClient spannerclient.SpannerClient @@ -393,3 +394,23 @@ func handleCoverageGraph(c context.Context, w http.ResponseWriter, r *http.Reque } return serveTemplate(w, "graph_histogram.html", data) } + +func handleUpdateCoverDBSubsystems(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + for ns, nsConfig := range getConfig(ctx).Namespaces { + service := nsConfig.Subsystems.Service + if service == nil { + continue + } + sss := service.List() + updatedRecords, err := coveragedb.RegenerateSubsystems(ctx, ns, sss, coverageDBClient) + if err != nil { + httpErr := fmt.Errorf("ns %s: %w", ns, err) + log.Errorf(ctx, "%s", httpErr.Error()) + http.Error(w, httpErr.Error(), http.StatusInternalServerError) + return + } + log.Infof(ctx, "%s: %v records updated\n", ns, updatedRecords) + fmt.Fprintf(w, "%s: %v records updated\n", ns, updatedRecords) + } +} diff --git a/dashboard/app/cron.yaml b/dashboard/app/cron.yaml index 2e293797a..1a9400e65 100644 --- a/dashboard/app/cron.yaml +++ b/dashboard/app/cron.yaml @@ -36,3 +36,6 @@ cron: # We use 15 for convenience here. - url: /cron/email_coverage_reports schedule: 15 of month 00:00 +# Weekly update the kernel-file -> subsystems relationship +- url: /cron/update_coverdb_subsystems + schedule: every monday diff --git a/dashboard/app/main.go b/dashboard/app/main.go index eeba85c9e..0d2e588b1 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -88,6 +88,7 @@ func initHTTPHandlers() { http.HandleFunc("/cron/deprecate_assets", handleDeprecateAssets) http.HandleFunc("/cron/refresh_subsystems", handleRefreshSubsystems) http.HandleFunc("/cron/subsystem_reports", handleSubsystemReports) + http.HandleFunc("/cron/update_coverdb_subsystems", handleUpdateCoverDBSubsystems) } func handleMovedPermanently(dest string) http.HandlerFunc { -- cgit mrf-deployment