From 5a4f2f6ec3c3059e3134991720d5a9e9c0ccdde6 Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Mon, 9 Dec 2024 17:44:06 +0200 Subject: [PATCH] libmem: golangci-lint fixes. Signed-off-by: Krisztian Litkey --- pkg/resmgr/lib/memory/allocator.go | 10 ++++++++-- pkg/resmgr/lib/memory/allocator_test.go | 13 +------------ pkg/resmgr/lib/memory/request_test.go | 1 - pkg/resmgr/lib/memory/types.go | 4 ---- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/pkg/resmgr/lib/memory/allocator.go b/pkg/resmgr/lib/memory/allocator.go index 41c6a8673..18ed11e77 100644 --- a/pkg/resmgr/lib/memory/allocator.go +++ b/pkg/resmgr/lib/memory/allocator.go @@ -305,7 +305,10 @@ func (a *Allocator) allocate(req *Request) (retErr error) { defer func() { if retErr != nil { - a.revertJournal(req) + _, err := a.revertJournal(req) + if err != nil { + log.Warn("failed to revert journal on error: %v", err) + } } }() @@ -337,7 +340,10 @@ func (a *Allocator) realloc(req *Request, nodes NodeMask, types TypeMask) (zone defer func() { if retErr != nil { - a.revertJournal(nil) + _, err := a.revertJournal(nil) + if err != nil { + log.Warn("failed to revert journal on error: %v", err) + } } }() diff --git a/pkg/resmgr/lib/memory/allocator_test.go b/pkg/resmgr/lib/memory/allocator_test.go index 3cf438a87..f5c7f88dd 100644 --- a/pkg/resmgr/lib/memory/allocator_test.go +++ b/pkg/resmgr/lib/memory/allocator_test.go @@ -16,7 +16,6 @@ package libmem_test import ( "fmt" - "strconv" "testing" "github.com/stretchr/testify/require" @@ -1155,7 +1154,7 @@ func TestRealloc(t *testing.T) { require.Equal(t, tc.updates, updates, "updated nodes") } - nodes, updates, err = a.Realloc(tc.id, tc.newNodes, tc.newTypes) + nodes, _, err = a.Realloc(tc.id, tc.newNodes, tc.newTypes) if !tc.fail { require.Nil(t, err, "unexpected realloc failure") @@ -1451,13 +1450,3 @@ func (s *testSetup) nodes(t *testing.T) []*Node { return nodes } - -var ( - nextID = 1 -) - -func newID() string { - id := strconv.Itoa(nextID) - nextID++ - return id -} diff --git a/pkg/resmgr/lib/memory/request_test.go b/pkg/resmgr/lib/memory/request_test.go index e819e2c19..c4b9788cd 100644 --- a/pkg/resmgr/lib/memory/request_test.go +++ b/pkg/resmgr/lib/memory/request_test.go @@ -95,7 +95,6 @@ func TestHumanReadableSize(t *testing.T) { func TestRequestString(t *testing.T) { type testCase struct { name string - aff NodeMask req *Request result string } diff --git a/pkg/resmgr/lib/memory/types.go b/pkg/resmgr/lib/memory/types.go index 36bba29fc..aede65a4e 100644 --- a/pkg/resmgr/lib/memory/types.go +++ b/pkg/resmgr/lib/memory/types.go @@ -153,10 +153,6 @@ const ( TypeMaskAll TypeMask = (TypeMaskHBM << 1) - 1 // all types of memory ) -var ( - typeMaskToString map[TypeMask]string -) - // NewTypeMask returns a TypeMask containing the given memory types. func NewTypeMask(types ...Type) TypeMask { m := TypeMask(0)