mirror of https://github.com/status-im/consul.git
Cleans up state management for remote deletes from local state.
Fixes #2125.
This commit is contained in:
parent
6f0a3b9bf5
commit
c8ce41f459
|
@ -26,8 +26,7 @@ const (
|
|||
// syncStatus is used to represent the difference between
|
||||
// the local and remote state, and if action needs to be taken
|
||||
type syncStatus struct {
|
||||
remoteDelete bool // Should this be deleted from the server
|
||||
inSync bool // Is this in sync with the server
|
||||
inSync bool // Is this in sync with the server
|
||||
}
|
||||
|
||||
// localState is used to represent the node's services,
|
||||
|
@ -177,7 +176,7 @@ func (l *localState) RemoveService(serviceID string) {
|
|||
|
||||
delete(l.services, serviceID)
|
||||
delete(l.serviceTokens, serviceID)
|
||||
l.serviceStatus[serviceID] = syncStatus{remoteDelete: true}
|
||||
l.serviceStatus[serviceID] = syncStatus{inSync: false}
|
||||
l.changeMade()
|
||||
}
|
||||
|
||||
|
@ -237,7 +236,7 @@ func (l *localState) RemoveCheck(checkID types.CheckID) {
|
|||
delete(l.checks, checkID)
|
||||
delete(l.checkTokens, checkID)
|
||||
delete(l.checkCriticalTime, checkID)
|
||||
l.checkStatus[checkID] = syncStatus{remoteDelete: true}
|
||||
l.checkStatus[checkID] = syncStatus{inSync: false}
|
||||
l.changeMade()
|
||||
}
|
||||
|
||||
|
@ -434,7 +433,7 @@ func (l *localState) setSyncState() error {
|
|||
// If we don't have the service locally, deregister it
|
||||
existing, ok := l.services[id]
|
||||
if !ok {
|
||||
l.serviceStatus[id] = syncStatus{remoteDelete: true}
|
||||
l.serviceStatus[id] = syncStatus{inSync: false}
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -472,7 +471,7 @@ func (l *localState) setSyncState() error {
|
|||
if id == consul.SerfCheckID {
|
||||
continue
|
||||
}
|
||||
l.checkStatus[id] = syncStatus{remoteDelete: true}
|
||||
l.checkStatus[id] = syncStatus{inSync: false}
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -521,7 +520,7 @@ func (l *localState) syncChanges() error {
|
|||
|
||||
// Sync the services
|
||||
for id, status := range l.serviceStatus {
|
||||
if status.remoteDelete {
|
||||
if _, ok := l.services[id]; !ok {
|
||||
if err := l.deleteService(id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -536,7 +535,7 @@ func (l *localState) syncChanges() error {
|
|||
|
||||
// Sync the checks
|
||||
for id, status := range l.checkStatus {
|
||||
if status.remoteDelete {
|
||||
if _, ok := l.checks[id]; !ok {
|
||||
if err := l.deleteCheck(id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue