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/manager | |
| parent | 668455c34bb42e5068264dae8ba909be95260c81 (diff) | |
pkg/manager: support multiple pools in Web UI
Diffstat (limited to 'pkg/manager')
| -rw-r--r-- | pkg/manager/http.go | 19 |
1 files changed, 12 insertions, 7 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")) |
