Skip to content
Snippets Groups Projects
Commit db380a83 authored by ale's avatar ale
Browse files

ignore duplicate deletes in config

parent caf6db76
No related branches found
No related tags found
No related merge requests found
...@@ -83,11 +83,16 @@ func (c *clusterConfig) setMountIfChanged(m *autoradio.Mount) bool { ...@@ -83,11 +83,16 @@ func (c *clusterConfig) setMountIfChanged(m *autoradio.Mount) bool {
return true return true
} }
// Delete a mount (in-memory only). // Delete a mount (in-memory only). Returns true if the mount existed
func (c *clusterConfig) delMount(name string) { // in our configuration and was deleted successfully.
func (c *clusterConfig) delMount(name string) bool {
c.lock.Lock() c.lock.Lock()
defer c.lock.Unlock() defer c.lock.Unlock()
delete(c.mounts, name) if _, ok := c.mounts[name]; ok {
delete(c.mounts, name)
return true
}
return false
} }
// Keeps the in-memory service configuration in sync with the etcd // Keeps the in-memory service configuration in sync with the etcd
...@@ -163,7 +168,11 @@ func (w *configWatcher) watcher(index uint64, stop chan bool) { ...@@ -163,7 +168,11 @@ func (w *configWatcher) watcher(index uint64, stop chan bool) {
case "delete": case "delete":
mountName := keyToMount(resp.Node.Key) mountName := keyToMount(resp.Node.Key)
log.Printf("deleted mount %s", mountName) log.Printf("deleted mount %s", mountName)
w.config.delMount(mountName) if !w.config.delMount(mountName) {
// Do not trigger an update if the
// operation had no effect.
continue
}
case "set", "create", "update": case "set", "create", "update":
if !w.updateMount(resp.Node.Key, resp.Node.Value, index) { if !w.updateMount(resp.Node.Key, resp.Node.Value, index) {
// Do not trigger an update if the // Do not trigger an update if the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment