From 03efedc6d1ffa8d8f76696875571b908cfe2fea1 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 15 Mar 2019 15:21:21 +0100 Subject: dashboard/app: add handler for config migration updateBugReporting adds missing reporting stages to bugs in a single namespace. Use with care. There is no undo. This can be used to migrate datastore to a new config with more reporting stages. This functionality is intentionally not connected to any handler. Before invoking it is recommented to stop all connected instances just in case. --- dashboard/app/api.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'dashboard/app/api.go') diff --git a/dashboard/app/api.go b/dashboard/app/api.go index 32cab3871..1f4fea5dd 100644 --- a/dashboard/app/api.go +++ b/dashboard/app/api.go @@ -988,12 +988,7 @@ func createBugForCrash(c context.Context, ns string, req *dashapi.Crash) (*Bug, FirstTime: now, LastTime: now, } - for _, rep := range config.Namespaces[ns].Reporting { - bug.Reporting = append(bug.Reporting, BugReporting{ - Name: rep.Name, - ID: bugReportingHash(bugHash, rep.Name), - }) - } + createBugReporting(bug, config.Namespaces[ns]) if bugKey, err = datastore.Put(c, bugKey, bug); err != nil { return fmt.Errorf("failed to put new bug: %v", err) } @@ -1018,6 +1013,16 @@ func createBugForCrash(c context.Context, ns string, req *dashapi.Crash) (*Bug, return bug, bugKey, nil } +func createBugReporting(bug *Bug, cfg *Config) { + for len(bug.Reporting) < len(cfg.Reporting) { + rep := &cfg.Reporting[len(bug.Reporting)] + bug.Reporting = append(bug.Reporting, BugReporting{ + Name: rep.Name, + ID: bugReportingHash(bug.keyHash(), rep.Name), + }) + } +} + func isActiveBug(c context.Context, bug *Bug) (bool, error) { if bug == nil { return false, nil -- cgit mrf-deployment