bug(host): Fix sync job failure blocking other set syncs (#1841)

During the plugin_host_set_sync job, a single set failing to  sync
can cause all following syncs to fail.
This commit is contained in:
Louis Ruch authored and GitHub committed 2022-02-04 12:02:37 -08:00
1 parent 2f7b4e5451
commit aaaf0241ff
4 files changed
+43 -59

No files matched your search

@@ -200,7 +200,6 @@ func getSetChanges(
currentHostMap map[string]*Host,
newHostMap map[string]*hostInfo) (
setMembershipsToAdd, setMembershipsToRemove map[string][]string,
allSetIds map[string]struct{},
) {
// First, find sets that hosts should be added to: hosts that are new or
// have new set IDs returned.
@@ -224,11 +223,7 @@ func getSetChanges(
if setMembershipsToAdd == nil {
setMembershipsToAdd = make(map[string][]string)
}
if allSetIds == nil {
allSetIds = make(map[string]struct{})
}
setMembershipsToAdd[setToAdd] = append(setMembershipsToAdd[setToAdd], newHostId)
allSetIds[setToAdd] = struct{}{}
}
}
@@ -254,11 +249,7 @@ func getSetChanges(
if setMembershipsToRemove == nil {
setMembershipsToRemove = make(map[string][]string)
}
if allSetIds == nil {
allSetIds = make(map[string]struct{})
}
setMembershipsToRemove[setToRemove] = append(setMembershipsToRemove[setToRemove], currentHostId)
allSetIds[setToRemove] = struct{}{}
}
}