mirror of
https://github.com/moby/moby.git
synced 2026-08-10 17:15:06 +00:00
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:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user