From 93ae7e0a1ca84fd2df902b7c8d94cdedb671bed6 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Mon, 13 Feb 2023 16:05:01 +0100 Subject: dashboard: move all cron endpoints to cron/ This lets us keep only one access rule and reliefs from the need to keep handlers and app.yaml in sync for cron jobs that'll be added in the future. --- dashboard/app/app.yaml | 2 +- dashboard/app/asset_storage_test.go | 12 ++++++------ dashboard/app/cron.yaml | 8 ++++---- dashboard/app/kcidb.go | 2 +- dashboard/app/main.go | 6 +++--- dashboard/app/util_test.go | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dashboard/app/app.yaml b/dashboard/app/app.yaml index a4b947a96..3990f9d97 100644 --- a/dashboard/app/app.yaml +++ b/dashboard/app/app.yaml @@ -25,7 +25,7 @@ handlers: - url: /static static_dir: static secure: always -- url: /(admin|email_poll|cache_update|kcidb_poll|deprecate_assets) +- url: /(admin|cron/.*) script: auto login: admin secure: always diff --git a/dashboard/app/asset_storage_test.go b/dashboard/app/asset_storage_test.go index ad972cf8b..1bcf5574e 100644 --- a/dashboard/app/asset_storage_test.go +++ b/dashboard/app/asset_storage_test.go @@ -117,7 +117,7 @@ https://goo.gl/tpsmEJ#status for how to communicate with syzbot.`, // Invalidate the bug. c.client.updateBug(extBugID, dashapi.BugStatusInvalid, "") - _, err = c.GET("/deprecate_assets") + _, err = c.GET("/cron/deprecate_assets") c.expectOK(err) // Query the needed assets once more, so far there should be no change. @@ -128,7 +128,7 @@ https://goo.gl/tpsmEJ#status for how to communicate with syzbot.`, // Skip one month and deprecate assets. c.advanceTime(time.Hour * 24 * 31) - _, err = c.GET("/deprecate_assets") + _, err = c.GET("/cron/deprecate_assets") c.expectOK(err) // Only the html asset should have persisted. @@ -194,7 +194,7 @@ func TestCoverReportDeprecation(t *testing.T) { defer c.Close() ensureNeeded := func(needed []string) { - _, err := c.GET("/deprecate_assets") + _, err := c.GET("/cron/deprecate_assets") c.expectOK(err) neededResp, err := c.client.NeededAssetsList() c.expectOK(err) @@ -270,7 +270,7 @@ func TestFreshBuildAssets(t *testing.T) { defer c.Close() ensureNeeded := func(needed []string) { - _, err := c.GET("/deprecate_assets") + _, err := c.GET("/cron/deprecate_assets") c.expectOK(err) neededResp, err := c.client.NeededAssetsList() c.expectOK(err) @@ -395,7 +395,7 @@ https://goo.gl/tpsmEJ#status for how to communicate with syzbot.`, // Invalidate the bug. c.client.updateBug(extBugID, dashapi.BugStatusInvalid, "") - _, err = c.GET("/deprecate_assets") + _, err = c.GET("/cron/deprecate_assets") c.expectOK(err) // Query the needed assets once more, so far there should be no change. @@ -406,7 +406,7 @@ https://goo.gl/tpsmEJ#status for how to communicate with syzbot.`, // Skip one month and deprecate assets. c.advanceTime(time.Hour * 24 * 31) - _, err = c.GET("/deprecate_assets") + _, err = c.GET("/cron/deprecate_assets") c.expectOK(err) // Nothing should have been persisted. diff --git a/dashboard/app/cron.yaml b/dashboard/app/cron.yaml index fca974bb5..5defc3d31 100644 --- a/dashboard/app/cron.yaml +++ b/dashboard/app/cron.yaml @@ -4,13 +4,13 @@ cron: - url: /email_poll schedule: every 1 minutes -- url: /cache_update +- url: /cron/cache_update schedule: every 1 hours -- url: /deprecate_assets +- url: /cron/deprecate_assets schedule: every 1 hours -- url: /kcidb_poll +- url: /cron/kcidb_poll schedule: every 5 minutes -- url: /retest_repros +- url: /cron/retest_repros schedule: every 1 hours - url: /_ah/datastore_admin/backup.create?name=backup&filesystem=gs&gs_bucket_name=syzkaller-backups&kind=Bug&kind=Build&kind=Crash&kind=CrashLog&kind=CrashReport&kind=Error&kind=Job&kind=KernelConfig&kind=Manager&kind=ManagerStats&kind=Patch&kind=ReportingState&kind=ReproC&kind=ReproSyz schedule: every monday 00:00 diff --git a/dashboard/app/kcidb.go b/dashboard/app/kcidb.go index 4b1a4a991..489c89c3b 100644 --- a/dashboard/app/kcidb.go +++ b/dashboard/app/kcidb.go @@ -16,7 +16,7 @@ import ( ) func initKcidb() { - http.HandleFunc("/kcidb_poll", handleKcidbPoll) + http.HandleFunc("/cron/kcidb_poll", handleKcidbPoll) } func handleKcidbPoll(w http.ResponseWriter, r *http.Request) { diff --git a/dashboard/app/main.go b/dashboard/app/main.go index f8f7c1ccd..d95e79a62 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -61,9 +61,9 @@ func initHTTPHandlers() { http.Handle("/"+ns+"/repos", handlerWrapper(handleRepos)) http.Handle("/"+ns+"/bug-stats", handlerWrapper(handleBugStats)) } - http.HandleFunc("/cache_update", cacheUpdate) - http.HandleFunc("/deprecate_assets", handleDeprecateAssets) - http.HandleFunc("/retest_repros", handleRetestRepros) + http.HandleFunc("/cron/cache_update", cacheUpdate) + http.HandleFunc("/cron/deprecate_assets", handleDeprecateAssets) + http.HandleFunc("/cron/retest_repros", handleRetestRepros) } type uiMainPage struct { diff --git a/dashboard/app/util_test.go b/dashboard/app/util_test.go index a0fce8d16..e82d549cb 100644 --- a/dashboard/app/util_test.go +++ b/dashboard/app/util_test.go @@ -364,7 +364,7 @@ func (c *Ctx) expectNoEmail() { } func (c *Ctx) updRetestReproJobs() { - _, err := c.GET("/retest_repros") + _, err := c.GET("/cron/retest_repros") c.expectOK(err) } -- cgit mrf-deployment