diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-10-18 14:10:33 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-10-25 12:08:02 +0000 |
| commit | c0aa87d6da9bb0a5b04e70e4d2bb3cd187c566b6 (patch) | |
| tree | 623be3ebff9fe881cfabe3f6214e7283429a3a22 /pkg | |
| parent | 668455c34bb42e5068264dae8ba909be95260c81 (diff) | |
pkg/manager: support multiple pools in Web UI
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/manager/http.go | 19 | ||||
| -rw-r--r-- | pkg/rpcserver/rpcserver.go | 26 |
2 files changed, 33 insertions, 12 deletions
diff --git a/pkg/manager/http.go b/pkg/manager/http.go index 96cd5a8bb..155765534 100644 --- a/pkg/manager/http.go +++ b/pkg/manager/http.go @@ -18,6 +18,7 @@ import ( "sort" "strconv" "strings" + "sync" "sync/atomic" "time" @@ -55,7 +56,7 @@ type HTTPServer struct { Fuzzer atomic.Pointer[fuzzer.Fuzzer] Cover atomic.Pointer[CoverageInfo] ReproLoop atomic.Pointer[ReproLoop] - Pool atomic.Pointer[dispatcher.Pool[*vm.Instance]] + Pools sync.Map // string => dispatcher.Pool[*vm.Instance] EnabledSyscalls atomic.Value // map[*prog.Syscall]bool // Internal state. @@ -198,12 +199,15 @@ func (serv *HTTPServer) httpStats(w http.ResponseWriter, r *http.Request) { executeTemplate(w, pages.StatsTemplate, stat.RenderGraphs()) } +const DefaultPool = "" + func (serv *HTTPServer) httpVMs(w http.ResponseWriter, r *http.Request) { - pool := serv.Pool.Load() - if pool == nil { - http.Error(w, "no VM pool is present (yet)", http.StatusInternalServerError) + poolObj, ok := serv.Pools.Load(r.FormValue("pool")) + if !ok { + http.Error(w, "no such VM pool is known (yet)", http.StatusInternalServerError) return } + pool := poolObj.(*dispatcher.Pool[*vm.Instance]) data := &UIVMData{ Name: serv.Cfg.Name, } @@ -241,11 +245,12 @@ func (serv *HTTPServer) httpVMs(w http.ResponseWriter, r *http.Request) { } func (serv *HTTPServer) httpVM(w http.ResponseWriter, r *http.Request) { - pool := serv.Pool.Load() - if pool == nil { - http.Error(w, "no VM pool is present (yet)", http.StatusInternalServerError) + poolObj, ok := serv.Pools.Load(r.FormValue("pool")) + if !ok { + http.Error(w, "no such VM pool is known (yet)", http.StatusInternalServerError) return } + pool := poolObj.(*dispatcher.Pool[*vm.Instance]) w.Header().Set("Content-Type", ctTextPlain) id, err := strconv.Atoi(r.FormValue("id")) diff --git a/pkg/rpcserver/rpcserver.go b/pkg/rpcserver/rpcserver.go index 76f1ddc68..10455cee7 100644 --- a/pkg/rpcserver/rpcserver.go +++ b/pkg/rpcserver/rpcserver.go @@ -8,6 +8,7 @@ import ( "context" "errors" "fmt" + "net/url" "slices" "sort" "strings" @@ -103,12 +104,27 @@ type Stats struct { } func NewStats() Stats { + return NewNamedStats("") +} + +func NewNamedStats(name string) Stats { + suffix := name + if suffix != "" { + suffix = " [" + suffix + "]" + } + vmsLink := "/vms" + if name != "" { + vmsLink += "?pool=" + url.QueryEscape(name) + } return Stats{ - StatExecs: stat.New("exec total", "Total test program executions", - stat.Console, stat.Rate{}, stat.Prometheus("syz_exec_total")), - StatNumFuzzing: stat.New("fuzzing VMs", - "Number of VMs that are currently fuzzing", stat.Graph("fuzzing VMs")), - StatVMRestarts: stat.New("vm restarts", "Total number of VM starts", + StatExecs: stat.New("exec total"+suffix, "Total test program executions", + stat.Console, stat.Rate{}, stat.Prometheus("syz_exec_total"+name), + ), + StatNumFuzzing: stat.New("fuzzing VMs"+suffix, + "Number of VMs that are currently fuzzing", stat.Graph("fuzzing VMs"), + stat.Link(vmsLink), + ), + StatVMRestarts: stat.New("vm restarts"+suffix, "Total number of VM starts", stat.Rate{}, stat.NoGraph), } } |
