Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bitmap): use enhanced bitmap from go-common-libs (backport #625) #674

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/longhorn/longhorn-instance-manager
go 1.22.2

require (
github.com/RoaringBitmap/roaring v1.9.4
github.com/google/uuid v1.6.0
github.com/longhorn/backupstore v0.0.0-20240823072635-7afd6aa10d3e
github.com/longhorn/go-common-libs v0.0.0-20240821134112-907f57efd48f
Expand All @@ -27,6 +26,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.4.0 // indirect
github.com/RoaringBitmap/roaring v1.9.4 // indirect
github.com/aws/aws-sdk-go v1.55.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.12.0 // indirect
Expand Down
10 changes: 8 additions & 2 deletions pkg/process/process_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"google.golang.org/protobuf/types/known/emptypb"
"k8s.io/mount-utils"

lhBitmap "github.com/longhorn/go-common-libs/bitmap"
lhKubernetes "github.com/longhorn/go-common-libs/kubernetes"
lhLonghorn "github.com/longhorn/go-common-libs/longhorn"

Expand Down Expand Up @@ -52,7 +53,7 @@ type Manager struct {
processes map[string]*Process
processUpdateCh chan *Process

availablePorts *util.Bitmap
availablePorts *lhBitmap.Bitmap

logsDir string

Expand All @@ -65,6 +66,11 @@ func NewManager(ctx context.Context, portRange string, logsDir string) (*Manager
if err != nil {
return nil, err
}
bitmap, err := lhBitmap.NewBitmap(start, end)
if err != nil {
return nil, err
}

pm := &Manager{
ctx: ctx,
portRangeMin: start,
Expand All @@ -76,7 +82,7 @@ func NewManager(ctx context.Context, portRange string, logsDir string) (*Manager
lock: &sync.RWMutex{},
processes: map[string]*Process{},
processUpdateCh: make(chan *Process),
availablePorts: util.NewBitmap(start, end),
availablePorts: bitmap,

logsDir: logsDir,

Expand Down
86 changes: 0 additions & 86 deletions pkg/util/bitmap.go

This file was deleted.

54 changes: 0 additions & 54 deletions pkg/util/bitmap_test.go

This file was deleted.