mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-20 03:13:53 +01:00
telemetry: keep the newest release in the versions chart (#12764)
The versions chart keeps the 8 versions with the most clusters on the last day and folds the rest into "other". A new release starts small, so 4.54 (282 clusters) was folded in while 4.53 shrank as clusters upgraded, which showed as a dip across the named versions. The newest plain release now always keeps its own band. Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e012fca9a2
commit
652133a28a
2 files changed
+48
-1
No files matched your search
@@ -74,9 +74,15 @@ func (s *PrometheusStorage) GetVersionSeries(days, limit int) VersionSeries {
|
||||
|
||||
if limit > 0 && len(series.Versions) > limit {
|
||||
// Old releases are a long tail of one-cluster bands; keep the versions
|
||||
// most of the fleet is on now and sum the rest into one band.
|
||||
// most of the fleet is on now and sum the rest into one band. The
|
||||
// newest release is kept too, while it is still too small to rank, or
|
||||
// clusters upgrading to it look like they left the named versions.
|
||||
newest := newestRelease(series.Versions, last)
|
||||
ranked := append([]VersionCounts(nil), series.Versions...)
|
||||
sort.Slice(ranked, func(i, j int) bool {
|
||||
if (ranked[i].Version == newest) != (ranked[j].Version == newest) {
|
||||
return ranked[i].Version == newest
|
||||
}
|
||||
if ranked[i].Clusters[last] != ranked[j].Clusters[last] {
|
||||
return ranked[i].Clusters[last] > ranked[j].Clusters[last]
|
||||
}
|
||||
@@ -104,6 +110,21 @@ func (s *PrometheusStorage) GetVersionSeries(days, limit int) VersionSeries {
|
||||
return series
|
||||
}
|
||||
|
||||
// newestRelease is the newest plain release, without a build suffix, that
|
||||
// clusters run on the last day.
|
||||
func newestRelease(versions []VersionCounts, last int) string {
|
||||
newest := ""
|
||||
for _, v := range versions {
|
||||
if _, suffix, ok := versionParts(v.Version); !ok || suffix != "" || v.Clusters[last] == 0 {
|
||||
continue
|
||||
}
|
||||
if newest == "" || versionLess(newest, v.Version) {
|
||||
newest = v.Version
|
||||
}
|
||||
}
|
||||
return newest
|
||||
}
|
||||
|
||||
// versionedHistories drops the samples recorded before the reported version was
|
||||
// kept in history, so the version series spans the days it actually knows a
|
||||
// version for instead of climbing out of a run of blank days.
|
||||
|
||||
@@ -93,6 +93,32 @@ func TestVersionSeriesHoldsForwardAndLimits(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionSeriesKeepsNewestRelease(t *testing.T) {
|
||||
s := newPrometheusStorage(prometheus.NewRegistry())
|
||||
|
||||
seedSamples(s, "a", HistorySample{Version: "4.40"}, -2, -1, 0)
|
||||
seedSamples(s, "b", HistorySample{Version: "4.40"}, -2, -1, 0)
|
||||
seedSamples(s, "c", HistorySample{Version: "4.41"}, -2, -1, 0)
|
||||
seedSamples(s, "d", HistorySample{Version: "4.41"}, -2, -1, 0)
|
||||
// Upgraded to the newest release, which is still the smallest band.
|
||||
seedSamples(s, "e", HistorySample{Version: "4.41"}, -2)
|
||||
seedSamples(s, "e", HistorySample{Version: "4.42"}, -1, 0)
|
||||
// A suffixed build newer than every release does not take its place.
|
||||
seedSamples(s, "f", HistorySample{Version: "4.43-dev"}, -2, -1, 0)
|
||||
|
||||
series := s.GetVersionSeries(3, 2)
|
||||
var kept []string
|
||||
for _, v := range series.Versions {
|
||||
kept = append(kept, v.Version)
|
||||
}
|
||||
if len(kept) != 2 || kept[0] != "4.41" || kept[1] != "4.42" {
|
||||
t.Fatalf("kept = %v, want 4.41 and the newest release 4.42", kept)
|
||||
}
|
||||
if series.Other == nil || series.Other.Count != 2 {
|
||||
t.Fatalf("other = %+v, want 4.40 and 4.43-dev", series.Other)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionLess(t *testing.T) {
|
||||
// Ordered oldest to newest; every pair must compare in this order.
|
||||
ordered := []string{"unknown", "3.97", "4.02", "4.30", "4.30-enterprise", "9.99", "10.02"}
|
||||
|
||||
Reference in new issue
Block a user