From c782043c6449d2c9f4612abbaa253f026e86cb88 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Mon, 26 Jan 2026 08:38:53 +0100 Subject: [PATCH] Upgrade cclib and remove usage of obsolete util.Float --- go.mod | 4 ++-- go.sum | 4 ++-- pkg/metricstore/level.go | 3 ++- pkg/metricstore/metricstore.go | 5 ++--- pkg/metricstore/stats.go | 21 +++++++++++---------- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index 479f1644..9e1a5453 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ tool ( require ( github.com/99designs/gqlgen v0.17.85 - github.com/ClusterCockpit/cc-lib/v2 v2.1.0 + github.com/ClusterCockpit/cc-lib/v2 v2.2.0 github.com/Masterminds/squirrel v1.5.4 github.com/aws/aws-sdk-go-v2 v1.41.1 github.com/aws/aws-sdk-go-v2/config v1.32.6 @@ -32,7 +32,6 @@ require ( github.com/joho/godotenv v1.5.1 github.com/linkedin/goavro/v2 v2.14.1 github.com/mattn/go-sqlite3 v1.14.33 - github.com/nats-io/nats.go v1.47.0 github.com/qustavo/sqlhooks/v2 v2.1.0 github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 github.com/stretchr/testify v1.11.1 @@ -95,6 +94,7 @@ require ( github.com/kr/pretty v0.3.1 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect + github.com/nats-io/nats.go v1.47.0 // indirect github.com/nats-io/nkeys v0.4.12 // indirect github.com/nats-io/nuid v1.0.1 // indirect github.com/oapi-codegen/runtime v1.1.1 // indirect diff --git a/go.sum b/go.sum index ef89e2d2..0cb7e925 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/99designs/gqlgen v0.17.85 h1:EkGx3U2FDcxQm8YDLQSpXIAVmpDyZ3IcBMOJi2nH github.com/99designs/gqlgen v0.17.85/go.mod h1:yvs8s0bkQlRfqg03YXr3eR4OQUowVhODT/tHzCXnbOU= github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8= github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= -github.com/ClusterCockpit/cc-lib/v2 v2.1.0 h1:B6l6h0IjfEuY9DU6aVM3fSsj24lQ1eudXK9QTKmJjqg= -github.com/ClusterCockpit/cc-lib/v2 v2.1.0/go.mod h1:JuxMAuEOaLLNEnnL9U3ejha8kMvsSatLdKPZEgJw6iw= +github.com/ClusterCockpit/cc-lib/v2 v2.2.0 h1:gqMsh7zsJMUhaXviXzaZ3gqXcLVgerjRJHzIcwX4FmQ= +github.com/ClusterCockpit/cc-lib/v2 v2.2.0/go.mod h1:JuxMAuEOaLLNEnnL9U3ejha8kMvsSatLdKPZEgJw6iw= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM= diff --git a/pkg/metricstore/level.go b/pkg/metricstore/level.go index b35137ef..bfa0ddf0 100644 --- a/pkg/metricstore/level.go +++ b/pkg/metricstore/level.go @@ -44,6 +44,7 @@ import ( "sync" "unsafe" + "github.com/ClusterCockpit/cc-lib/v2/schema" "github.com/ClusterCockpit/cc-lib/v2/util" ) @@ -272,7 +273,7 @@ func (l *Level) sizeInBytes() int64 { for _, b := range l.metrics { if b != nil { - size += b.count() * int64(unsafe.Sizeof(util.Float(0))) + size += b.count() * int64(unsafe.Sizeof(schema.Float(0))) } } diff --git a/pkg/metricstore/metricstore.go b/pkg/metricstore/metricstore.go index a50f4ab5..0d1f19c9 100644 --- a/pkg/metricstore/metricstore.go +++ b/pkg/metricstore/metricstore.go @@ -37,7 +37,7 @@ import ( "github.com/ClusterCockpit/cc-lib/v2/util" ) -// Define a struct to hold your globals and the mutex +// GlobalState holds the global state for the metric store with thread-safe access. type GlobalState struct { mu sync.RWMutex lastRetentionTime int64 @@ -740,8 +740,7 @@ func (m *MemoryStore) Free(selector []string, t int64) (int, error) { return m.GetLevel(selector).free(t) } -// Free releases all buffers for the selected level and all its children that -// contain only values older than `t`. +// ForceFree unconditionally removes the oldest buffer from each metric chain. func (m *MemoryStore) ForceFree() (int, error) { return m.GetLevel(nil).forceFree() } diff --git a/pkg/metricstore/stats.go b/pkg/metricstore/stats.go index 51ffafc1..8f7886a3 100644 --- a/pkg/metricstore/stats.go +++ b/pkg/metricstore/stats.go @@ -9,14 +9,15 @@ import ( "errors" "math" + "github.com/ClusterCockpit/cc-lib/v2/schema" "github.com/ClusterCockpit/cc-lib/v2/util" ) type Stats struct { Samples int - Avg util.Float - Min util.Float - Max util.Float + Avg schema.Float + Min schema.Float + Max schema.Float } func (b *buffer) stats(from, to int64) (Stats, int64, int64, error) { @@ -61,9 +62,9 @@ func (b *buffer) stats(from, to int64) (Stats, int64, int64, error) { return Stats{ Samples: samples, - Avg: util.Float(sum) / util.Float(samples), - Min: util.Float(min), - Max: util.Float(max), + Avg: schema.Float(sum) / schema.Float(samples), + Min: schema.Float(min), + Max: schema.Float(max), }, from, t, nil } @@ -81,7 +82,7 @@ func (m *MemoryStore) Stats(selector util.Selector, metric string, from, to int6 } n, samples := 0, 0 - avg, min, max := util.Float(0), math.MaxFloat32, -math.MaxFloat32 + avg, min, max := schema.Float(0), math.MaxFloat32, -math.MaxFloat32 err := m.root.findBuffers(selector, minfo.offset, func(b *buffer) error { stats, cfrom, cto, err := b.stats(from, to) if err != nil { @@ -110,7 +111,7 @@ func (m *MemoryStore) Stats(selector util.Selector, metric string, from, to int6 } if minfo.Aggregation == AvgAggregation { - avg /= util.Float(n) + avg /= schema.Float(n) } else if n > 1 && minfo.Aggregation != SumAggregation { return nil, 0, 0, errors.New("invalid aggregation") } @@ -118,7 +119,7 @@ func (m *MemoryStore) Stats(selector util.Selector, metric string, from, to int6 return &Stats{ Samples: samples, Avg: avg, - Min: util.Float(min), - Max: util.Float(max), + Min: schema.Float(min), + Max: schema.Float(max), }, from, to, nil }