diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-05-19 19:25:38 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2023-05-25 11:11:21 +0200 |
| commit | ffc7db8b1950cae49c03f6f216189f9f8f2c4bb2 (patch) | |
| tree | 98ceb6aacd8fb1a8d2c9b6c1a84e44c8444d6cc3 | |
| parent | df6ffdd4e5bcf13ee4a3b27a9938bbe930483621 (diff) | |
dashboard: don't use a separate JobFlags type
Use the JobDoneFlags from dashapi.
Move the default string representation generation to JobDoneFlags.
| -rw-r--r-- | dashboard/app/admin.go | 2 | ||||
| -rw-r--r-- | dashboard/app/entities.go | 40 | ||||
| -rw-r--r-- | dashboard/app/jobs.go | 4 |
3 files changed, 8 insertions, 38 deletions
diff --git a/dashboard/app/admin.go b/dashboard/app/admin.go index c50548aad..e487f9b9e 100644 --- a/dashboard/app/admin.go +++ b/dashboard/app/admin.go @@ -173,7 +173,7 @@ func restartFailedBisections(c context.Context, w http.ResponseWriter, r *http.R job.Log = 0 job.Error = 0 job.CrashLog = 0 - job.Flags = JobFlags(0) + job.Flags = 0 if _, err := db.Put(c, jobKey, job); err != nil { return fmt.Errorf("job %v: failed to put: %v", idx, err) } diff --git a/dashboard/app/entities.go b/dashboard/app/entities.go index ed36fa4cd..5c6272f75 100644 --- a/dashboard/app/entities.go +++ b/dashboard/app/entities.go @@ -557,7 +557,7 @@ type Job struct { BuildID string Log int64 // reference to Log text entity Error int64 // reference to Error text entity, if set job failed - Flags JobFlags + Flags dashapi.JobDoneFlags Reported bool // have we reported result back to user? } @@ -587,46 +587,16 @@ func (typ JobType) toDashapiReportType() dashapi.ReportType { } } -type JobFlags int64 - -const ( - // Parallel to dashapi.JobDoneFlags, see comments there. - BisectResultMerge JobFlags = 1 << iota - BisectResultNoop - BisectResultRelease - BisectResultIgnore -) - -func (flags JobFlags) String() string { - res := "" - if flags&BisectResultMerge != 0 { - res += "merge " - } - if flags&BisectResultNoop != 0 { - res += "no-op " - } - if flags&BisectResultRelease != 0 { - res += "release " - } - if flags&BisectResultIgnore != 0 { - res += "ignored " - } - if res == "" { - return res - } - return "[" + res + "commit]" -} - func (job *Job) isUnreliableBisect() bool { if job.Type != JobBisectCause && job.Type != JobBisectFix { panic(fmt.Sprintf("bad job type %v", job.Type)) } // If a bisection points to a merge or a commit that does not affect the kernel binary, // it is considered an unreliable/wrong result and should not be reported in emails. - return job.Flags&BisectResultMerge != 0 || - job.Flags&BisectResultNoop != 0 || - job.Flags&BisectResultRelease != 0 || - job.Flags&BisectResultIgnore != 0 + return job.Flags&dashapi.BisectResultMerge != 0 || + job.Flags&dashapi.BisectResultNoop != 0 || + job.Flags&dashapi.BisectResultRelease != 0 || + job.Flags&dashapi.BisectResultIgnore != 0 } // Text holds text blobs (crash logs, reports, reproducers, etc). diff --git a/dashboard/app/jobs.go b/dashboard/app/jobs.go index c4912368a..d9834e413 100644 --- a/dashboard/app/jobs.go +++ b/dashboard/app/jobs.go @@ -961,7 +961,7 @@ func doneJob(c context.Context, req *dashapi.JobDoneReq) error { job.CrashTitle = req.CrashTitle job.Finished = now job.IsRunning = false - job.Flags = JobFlags(req.Flags) + job.Flags = req.Flags if job.Type == JobBisectCause || job.Type == JobBisectFix { // Update bug.BisectCause/Fix status and also remember current bug reporting to send results. var err error @@ -1408,7 +1408,7 @@ func makeJobInfo(c context.Context, job *Job, jobKey *db.Key, bug *Bug, build *B } info := &dashapi.JobInfo{ Type: dashapi.JobType(job.Type), - Flags: dashapi.JobDoneFlags(job.Flags), + Flags: job.Flags, Created: job.Created, BugLink: bugLink(jobKey.Parent().StringID()), ExternalLink: job.Link, |
