diff options
| author | Space Meyer <spm@google.com> | 2023-05-06 12:18:30 +0200 |
|---|---|---|
| committer | Space Meyer <git@the-space.agency> | 2023-06-12 17:16:51 +0200 |
| commit | 2d0582f691044a9bcc8199bc4bec0aa6979340a2 (patch) | |
| tree | 77a445fdb1a2ec0fad1bd234a9936228dc6299de /dashboard/app/admin.go | |
| parent | aaed018397bf51a5aaff9a072ba223d81cd3c107 (diff) | |
dashboard: allow admins to retry individual bisections
Changes to our rootfs, compilers or bisection logic regularly cause
regressions in our bisection accuracy. Retrying them currently entails
fiddling with the GCP datastore directly or mass deleting all failed
bisections.
This change will allow us to retry specific bisections with a single
click.
Diffstat (limited to 'dashboard/app/admin.go')
| -rw-r--r-- | dashboard/app/admin.go | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/dashboard/app/admin.go b/dashboard/app/admin.go index e487f9b9e..0b6eef0c6 100644 --- a/dashboard/app/admin.go +++ b/dashboard/app/admin.go @@ -15,6 +15,26 @@ import ( aemail "google.golang.org/appengine/v2/mail" ) +func handleInvalidateBisection(c context.Context, w http.ResponseWriter, r *http.Request) error { + encodedKey := r.FormValue("key") + if encodedKey == "" { + return fmt.Errorf("mandatory parameter key is missing") + } + jobKey, err := db.DecodeKey(encodedKey) + if err != nil { + return fmt.Errorf("failed to decode job key %v: %w", encodedKey, err) + } + + err = invalidateBisection(c, jobKey) + if err != nil { + return fmt.Errorf("failed to invalidate job %v: %w", jobKey, err) + } + + // Sending back to bug page after successful invalidation. + http.Redirect(w, r, r.Header.Get("Referer"), http.StatusFound) + return nil +} + // dropNamespace drops all entities related to a single namespace. // Use with care. There is no undo. // This functionality is intentionally not connected to any handler. @@ -162,40 +182,9 @@ func restartFailedBisections(c context.Context, w http.ResponseWriter, r *http.R return nil } for idx, jobKey := range toReset { - tx := func(c context.Context) error { - // Reset the job. - job := new(Job) - if err := db.Get(c, jobKey, job); err != nil { - return fmt.Errorf("job %v: failed to get in tx: %v", idx, err) - } - job.LastStarted = time.Time{} - job.Finished = time.Time{} - job.Log = 0 - job.Error = 0 - job.CrashLog = 0 - job.Flags = 0 - if _, err := db.Put(c, jobKey, job); err != nil { - return fmt.Errorf("job %v: failed to put: %v", idx, err) - } - // Update the bug. - bug := new(Bug) - bugKey := jobKey.Parent() - if err := db.Get(c, bugKey, bug); err != nil { - return fmt.Errorf("job %v: failed to get bug: %v", idx, err) - } - if job.Type == JobBisectCause { - bug.BisectCause = BisectNot - } else if job.Type == JobBisectFix { - bug.BisectFix = BisectNot - } - if _, err := db.Put(c, bugKey, bug); err != nil { - return fmt.Errorf("job %v: failed to put the bug: %v", idx, err) - } - return nil - } - if err := db.RunInTransaction(c, tx, &db.TransactionOptions{XG: true, Attempts: 10}); err != nil { - fmt.Fprintf(w, "update failed: %s", err) - return nil + err = invalidateBisection(c, jobKey) + if err != nil { + fmt.Fprintf(w, "job %v update failed: %s", idx, err) } } |
