diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-04-24 13:58:56 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-04-24 13:58:56 +0200 |
| commit | 2e579571e0a2e1193ffcd9f3c082608c0a14ebe0 (patch) | |
| tree | d094e4a3f60aa32a02a0438f532103bb15889ec3 | |
| parent | 9366d03f001170479319878905031f63d4377c46 (diff) | |
dashboard/app: refactor manager info in config
In preparation for future changes.
| -rw-r--r-- | dashboard/app/api.go | 4 | ||||
| -rw-r--r-- | dashboard/app/config.go | 23 | ||||
| -rw-r--r-- | dashboard/app/entities.go | 2 | ||||
| -rw-r--r-- | dashboard/app/jobs.go | 7 |
4 files changed, 28 insertions, 8 deletions
diff --git a/dashboard/app/api.go b/dashboard/app/api.go index 5ccb3c18a..4fdf117d7 100644 --- a/dashboard/app/api.go +++ b/dashboard/app/api.go @@ -398,10 +398,10 @@ func managerList(c context.Context, ns string) ([]string, error) { if err != nil { return nil, fmt.Errorf("failed to query builds: %v", err) } - decommissioned := config.Namespaces[ns].DecommissionedManagers + configManagers := config.Namespaces[ns].Managers var managers []string for _, build := range builds { - if _, ok := decommissioned[build.Manager]; ok { + if configManagers[build.Manager].Decommissioned { continue } managers = append(managers, build.Manager) diff --git a/dashboard/app/config.go b/dashboard/app/config.go index 1d8a5ca15..5ef38f77b 100644 --- a/dashboard/app/config.go +++ b/dashboard/app/config.go @@ -55,13 +55,20 @@ type Config struct { ReportingDelay time.Duration // How long should we wait for a C repro before reporting a bug. WaitForRepro time.Duration - // Managers that were turned down and will not hold bug fixing due to missed commits. - // The value is delegated manager that will handle patch testing instead of the decommissioned one. - DecommissionedManagers map[string]string + // Managers contains some special additional info about syz-manager instances. + Managers map[string]ConfigManager // Reporting config. Reporting []Reporting } +// ConfigManager describes a single syz-manager instance. +// Dashboard does not generally need to know about all of them, +// but in some special cases it needs to know some additional information. +type ConfigManager struct { + Decommissioned bool // The instance is no longer active. + DelegatedTo string // If Decommissioned, test requests should go to this instance instead. +} + // One reporting stage. type Reporting struct { // See GlobalConfig.AccessLevel. @@ -151,6 +158,16 @@ func init() { cfg.DisplayTitle = ns } checkClients(clientNames, cfg.Clients) + for name, mgr := range cfg.Managers { + if mgr.Decommissioned && mgr.DelegatedTo == "" { + panic(fmt.Sprintf("decommissioned manager %v/%v does not have delegate", + ns, name)) + } + if !mgr.Decommissioned && mgr.DelegatedTo != "" { + panic(fmt.Sprintf("non-decommissioned manager %v/%v has delegate", + ns, name)) + } + } if !clientKeyRe.MatchString(cfg.Key) { panic(fmt.Sprintf("bad namespace %q key: %q", ns, cfg.Key)) } diff --git a/dashboard/app/entities.go b/dashboard/app/entities.go index 9e558e4e0..17b65286c 100644 --- a/dashboard/app/entities.go +++ b/dashboard/app/entities.go @@ -253,7 +253,7 @@ func loadAllManagers(c context.Context) ([]*Manager, []*datastore.Key, error) { var resultKeys []*datastore.Key for i, mgr := range managers { - if _, ok := config.Namespaces[mgr.Namespace].DecommissionedManagers[mgr.Name]; ok { + if config.Namespaces[mgr.Namespace].Managers[mgr.Name].Decommissioned { continue } result = append(result, mgr) diff --git a/dashboard/app/jobs.go b/dashboard/app/jobs.go index d085b1f5a..75f97a676 100644 --- a/dashboard/app/jobs.go +++ b/dashboard/app/jobs.go @@ -107,8 +107,11 @@ func addTestJob(c context.Context, bug *Bug, bugKey *datastore.Key, bugReporting manager := crash.Manager for _, ns := range config.Namespaces { - if delegated, ok := ns.DecommissionedManagers[manager]; ok { - manager = delegated + if mgr, ok := ns.Managers[manager]; ok { + if mgr.Decommissioned { + manager = mgr.DelegatedTo + break + } } } |
