Remove persisted IPAM ring data on peerName change
This commit is contained in:
1 parent
f396c60402
commit
06f3793f05
1 file changed
+16
@@ -768,15 +768,31 @@ func (alloc *Allocator) reportFreeSpace() {
|
|||||||
// Persisting the Ring
|
// Persisting the Ring
|
||||||
const (
|
const (
|
||||||
ringIdent = "ring"
|
ringIdent = "ring"
|
||||||
|
nameIdent = "peername"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (alloc *Allocator) persistRing() {
|
func (alloc *Allocator) persistRing() {
|
||||||
|
// It would be better if these two Save operations happened in the same transaction
|
||||||
|
if err := alloc.db.Save(nameIdent, alloc.ourName); err != nil {
|
||||||
|
common.Log.Errorf("Error persisting ring data: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
if err := alloc.db.Save(ringIdent, alloc.ring); err != nil {
|
if err := alloc.db.Save(ringIdent, alloc.ring); err != nil {
|
||||||
common.Log.Errorf("Error persisting ring data: %s", err)
|
common.Log.Errorf("Error persisting ring data: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (alloc *Allocator) loadPersistedRing() {
|
func (alloc *Allocator) loadPersistedRing() {
|
||||||
|
var checkPeerName mesh.PeerName
|
||||||
|
if err := alloc.db.Load(nameIdent, &checkPeerName); err != nil {
|
||||||
|
common.Log.Errorf("Error loading persisted peer name: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if checkPeerName != alloc.ourName {
|
||||||
|
alloc.infof("Deleting persisted data for peername %s", checkPeerName)
|
||||||
|
alloc.persistRing()
|
||||||
|
return
|
||||||
|
}
|
||||||
if err := alloc.db.Load(ringIdent, &alloc.ring); err != nil {
|
if err := alloc.db.Load(ringIdent, &alloc.ring); err != nil {
|
||||||
common.Log.Errorf("Error loading persisted ring data: %s", err)
|
common.Log.Errorf("Error loading persisted ring data: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user