libnetwork/bit{seq,map}: delete CheckConsistency()

That method was only referenced by ipam.Allocator, but as it no longer
stores any state persistently there is no possibility for it to load an
inconsistent bit-sequence from Docker 1.9.x.

Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Cory Snider
2023-01-24 18:54:05 -05:00
parent a08a254df3
commit 6f08fe20e9
4 changed files with 0 additions and 215 deletions

View File

@@ -11,7 +11,6 @@ import (
"github.com/docker/docker/libnetwork/bitmap"
"github.com/docker/docker/libnetwork/datastore"
"github.com/docker/docker/libnetwork/types"
"github.com/sirupsen/logrus"
)
var (
@@ -101,45 +100,6 @@ func (h *Handle) IsSet(ordinal uint64) bool {
return h.bm.IsSet(ordinal)
}
// CheckConsistency checks if the bit sequence is in an inconsistent state and attempts to fix it.
// It looks for a corruption signature that may happen in docker 1.9.0 and 1.9.1.
func (h *Handle) CheckConsistency() error {
for {
h.mu.Lock()
store := h.store
h.mu.Unlock()
if store != nil {
if err := store.GetObject(datastore.Key(h.Key()...), h); err != nil && err != datastore.ErrKeyNotFound {
return err
}
}
h.mu.Lock()
nh := h.getCopy()
h.mu.Unlock()
if !nh.bm.CheckConsistency() {
return nil
}
if err := nh.writeToStore(); err != nil {
if _, ok := err.(types.RetryError); !ok {
return fmt.Errorf("internal failure while fixing inconsistent bitsequence: %v", err)
}
continue
}
logrus.Infof("Fixed inconsistent bit sequence in datastore:\n%s\n%s", h, nh)
h.mu.Lock()
h.bm = nh.bm
h.mu.Unlock()
return nil
}
}
// set/reset the bit
func (h *Handle) apply(op func(*bitmap.Bitmap) (uint64, error)) (uint64, error) {
for {

View File

@@ -181,36 +181,6 @@ func TestRetrieveFromStore(t *testing.T) {
}
}
func TestIsCorrupted(t *testing.T) {
ds, err := randomLocalStore()
if err != nil {
t.Fatal(err)
}
// Negative test
hnd, err := NewHandle("bitseq-test/data/", ds, "test_corrupted", 1024)
if err != nil {
t.Fatal(err)
}
if err := hnd.CheckConsistency(); err != nil {
t.Fatal(err)
}
_ = hnd.Set(0)
if err := hnd.CheckConsistency(); err != nil {
t.Fatal(err)
}
_ = hnd.Set(1023)
if err := hnd.CheckConsistency(); err != nil {
t.Fatal(err)
}
if err := hnd.CheckConsistency(); err != nil {
t.Fatal(err)
}
}
func testSetRollover(t *testing.T, serial bool) {
ds, err := randomLocalStore()
if err != nil {