From 6db8af716fb0995966f00e2d52d2f3baa43ea868 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 15 Jul 2022 09:29:43 +0000 Subject: dashboard: implement asset storage Asset is a file/attachment relevant for debugging a kernel crash or the syzbot itself. Dashboard keeps track of the uploaded assets and manages their lifetime. Some of the assets are attached to the bug reports sent by syzkaller, some (like html coverage report) are displayed on the web portal. Two new API requests: * add_build_assets -- let dashboard remember one more build-related asset. * needed_assets -- query the list of assets that are still needed by the dashboard. --- dashboard/dashapi/dashapi.go | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'dashboard/dashapi/dashapi.go') diff --git a/dashboard/dashapi/dashapi.go b/dashboard/dashapi/dashapi.go index 028448b33..cdefb8080 100644 --- a/dashboard/dashapi/dashapi.go +++ b/dashboard/dashapi/dashapi.go @@ -102,6 +102,7 @@ type Build struct { KernelConfig []byte Commits []string // see BuilderPoll FixCommits []Commit + Assets []NewAsset } type Commit struct { @@ -396,8 +397,27 @@ type BugReport struct { PatchLink string BisectCause *BisectResult BisectFix *BisectResult + Assets []Asset } +type Asset struct { + Title string + DownloadURL string + Type AssetType +} + +type AssetType string + +// Asset types used throughout the system. +// DO NOT change them, this will break compatibility with DB content. +const ( + BootableDisk AssetType = "bootable_disk" + NonBootableDisk AssetType = "non_bootable_disk" + KernelObject AssetType = "kernel_object" + KernelImage AssetType = "kernel_image" + HTMLCoverageReport AssetType = "html_coverage_report" +) + type BisectResult struct { Commit *Commit // for conclusive bisection Commits []*Commit // for inconclusive bisection @@ -537,6 +557,35 @@ func (dash *Dashboard) UploadManagerStats(req *ManagerStatsReq) error { return dash.Query("manager_stats", req, nil) } +// Asset lifetime: +// 1. syz-ci uploads it to GCS and reports to the dashboard via add_build_asset. +// 2. dashboard periodically checks if the asset is still needed. +// 3. syz-ci queries needed_assets to figure out which assets are still needed. +// 4. Once an asset is not needed, syz-ci removes the corresponding file. +type NewAsset struct { + DownloadURL string + Type AssetType +} + +type AddBuildAssetsReq struct { + BuildID string + Assets []NewAsset +} + +func (dash *Dashboard) AddBuildAssets(req *AddBuildAssetsReq) error { + return dash.Query("add_build_assets", req, nil) +} + +type NeededAssetsResp struct { + DownloadURLs []string +} + +func (dash *Dashboard) NeededAssetsList() (*NeededAssetsResp, error) { + resp := new(NeededAssetsResp) + err := dash.Query("needed_assets", nil, resp) + return resp, err +} + type BugListResp struct { List []string } -- cgit mrf-deployment