From 953d1c45a16b7284725e337b47369a8ab111bab4 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 17 Jan 2025 10:23:56 +0100 Subject: [PATCH] pkg/manager: show bug first time This allows to understand if a bug is new (found in the current run) or old. --- pkg/manager/crash.go | 2 ++ pkg/manager/html/main.html | 2 ++ pkg/manager/http.go | 6 +++++- pkg/osutil/osutil.go | 6 ++++++ pkg/osutil/osutil_bsd.go | 5 +++++ pkg/osutil/osutil_darwin.go | 5 +++++ pkg/osutil/osutil_fuchsia.go | 5 +++++ pkg/osutil/osutil_linux.go | 5 +++++ pkg/osutil/osutil_windows.go | 5 +++++ 9 files changed, 40 insertions(+), 1 deletion(-) diff --git a/pkg/manager/crash.go b/pkg/manager/crash.go index d995b5633244..44df6e63e017 100644 --- a/pkg/manager/crash.go +++ b/pkg/manager/crash.go @@ -211,6 +211,7 @@ type CrashInfo struct { type BugInfo struct { ID string Title string + FirstTime time.Time LastTime time.Time HasRepro bool HasCRepro bool @@ -232,6 +233,7 @@ func (cs *CrashStore) BugInfo(id string, full bool) (*BugInfo, error) { return nil, err } ret.Title = strings.TrimSpace(string(desc)) + ret.FirstTime = osutil.CreationTime(stat) ret.LastTime = stat.ModTime() files, err := osutil.ListDir(dir) if err != nil { diff --git a/pkg/manager/html/main.html b/pkg/manager/html/main.html index 1b4ea0f755a4..2b0cb225074b 100644 --- a/pkg/manager/html/main.html +++ b/pkg/manager/html/main.html @@ -24,6 +24,7 @@ Description Count + First Time Last Time Report @@ -31,6 +32,7 @@ {{$c.Description}} {{$c.Count}} + {{formatTime $c.FirstTime}} {{formatTime $c.LastTime}} {{if $c.Triaged}} diff --git a/pkg/manager/http.go b/pkg/manager/http.go index 65f0a5714be6..d78d5dc0e4e1 100644 --- a/pkg/manager/http.go +++ b/pkg/manager/http.go @@ -343,7 +343,9 @@ func makeUICrashType(info *BugInfo, startTime time.Time, repros map[string]bool) info.ReproAttempts >= MaxReproAttempts) return UICrashType{ Description: info.Title, + FirstTime: info.FirstTime, LastTime: info.LastTime, + New: info.FirstTime.After(startTime), Active: info.LastTime.After(startTime), ID: info.ID, Count: len(info.Crashes), @@ -992,8 +994,10 @@ type UICrashPage struct { type UICrashType struct { Description string + FirstTime time.Time LastTime time.Time - Active bool + New bool // was first found in the current run + Active bool // was found in the current run ID string Count int Triaged string diff --git a/pkg/osutil/osutil.go b/pkg/osutil/osutil.go index f4a3cac180f2..c9ee98412860 100644 --- a/pkg/osutil/osutil.go +++ b/pkg/osutil/osutil.go @@ -351,6 +351,12 @@ func Abs(path string) string { return filepath.Clean(path) } +// CreationTime returns file creation time. +// May return zero time, if not known. +func CreationTime(fi os.FileInfo) time.Time { + return creationTime(fi) +} + // MonotonicNano returns monotonic time in nanoseconds from some unspecified point in time. // Useful mostly to measure time intervals. // This function should be used inside of tested VMs b/c time.Now may reject to use monotonic time diff --git a/pkg/osutil/osutil_bsd.go b/pkg/osutil/osutil_bsd.go index b54c9126f172..b26c91ff7d03 100644 --- a/pkg/osutil/osutil_bsd.go +++ b/pkg/osutil/osutil_bsd.go @@ -8,8 +8,13 @@ package osutil import ( "os" "os/exec" + "time" ) +func creationTime(fi os.FileInfo) time.Time { + return time.Time{} +} + func RemoveAll(dir string) error { return os.RemoveAll(dir) } diff --git a/pkg/osutil/osutil_darwin.go b/pkg/osutil/osutil_darwin.go index 22c667ed729a..0b1f30711251 100644 --- a/pkg/osutil/osutil_darwin.go +++ b/pkg/osutil/osutil_darwin.go @@ -6,8 +6,13 @@ package osutil import ( "os" "os/exec" + "time" ) +func creationTime(fi os.FileInfo) time.Time { + return time.Time{} +} + func RemoveAll(dir string) error { return os.RemoveAll(dir) } diff --git a/pkg/osutil/osutil_fuchsia.go b/pkg/osutil/osutil_fuchsia.go index 4103e7f520a4..1ebd64eb4c25 100644 --- a/pkg/osutil/osutil_fuchsia.go +++ b/pkg/osutil/osutil_fuchsia.go @@ -9,8 +9,13 @@ import ( "fmt" "os" "os/exec" + "time" ) +func creationTime(fi os.FileInfo) time.Time { + return time.Time{} +} + func HandleInterrupts(shutdown chan struct{}) { } diff --git a/pkg/osutil/osutil_linux.go b/pkg/osutil/osutil_linux.go index 6585713ac52b..63743a5f2a6b 100644 --- a/pkg/osutil/osutil_linux.go +++ b/pkg/osutil/osutil_linux.go @@ -17,6 +17,11 @@ import ( "golang.org/x/sys/unix" ) +func creationTime(fi os.FileInfo) time.Time { + st := fi.Sys().(*syscall.Stat_t) + return time.Unix(int64(st.Ctim.Sec), int64(st.Ctim.Nsec)) // nolint: unconvert +} + // RemoveAll is similar to os.RemoveAll, but can handle more cases. func RemoveAll(dir string) error { files, _ := os.ReadDir(dir) diff --git a/pkg/osutil/osutil_windows.go b/pkg/osutil/osutil_windows.go index 8a0e8b77a11f..c5763b6776a6 100644 --- a/pkg/osutil/osutil_windows.go +++ b/pkg/osutil/osutil_windows.go @@ -8,8 +8,13 @@ import ( "os" "os/exec" "syscall" + "time" ) +func creationTime(fi os.FileInfo) time.Time { + return time.Time{} +} + func HandleInterrupts(shutdown chan struct{}) { }