summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2012-10-23 09:40:56 -0500
committerTim Laszlo <tim.laszlo@gmail.com>2012-10-23 09:43:58 -0500
commit2ec42ab01bb7d120dff8a985a3c73b9c4caa53ce (patch)
treea28cace0d4583874d7abc99a17ca6c5f6d3e30d3
parent1df0518c9cdae1fd555c5871b3f33bb5c2768d82 (diff)
downloadbcfg2-2ec42ab01bb7d120dff8a985a3c73b9c4caa53ce.tar.gz
bcfg2-2ec42ab01bb7d120dff8a985a3c73b9c4caa53ce.tar.bz2
bcfg2-2ec42ab01bb7d120dff8a985a3c73b9c4caa53ce.zip
Update internal probe data at once.
When a large number of clients upload probe data at once, the data is occasionally written out before the data is fully populated. This causes writes to fail with KeyErrors on the server and clients to stop running.
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Probes.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py
index 45d3c2763..bb1cbf81c 100644
--- a/src/lib/Bcfg2/Server/Plugins/Probes.py
+++ b/src/lib/Bcfg2/Server/Plugins/Probes.py
@@ -298,10 +298,12 @@ class Probes(Bcfg2.Server.Plugin.Probing,
else:
olddata = []
- self.cgroups[client.hostname] = []
- self.probedata[client.hostname] = ClientProbeDataSet()
+ cgroups = []
+ cprobedata = ClientProbeDataSet()
for data in datalist:
- self.ReceiveDataItem(client, data)
+ self.ReceiveDataItem(client, data, cgroups, cprobedata)
+ self.cgroups[client.hostname] = cgroups
+ self.probedata[client.hostname] = cprobedata
if (self.core.metadata_cache_mode in ['cautious', 'aggressive'] and
olddata != self.cgroups[client.hostname]):
@@ -309,17 +311,12 @@ class Probes(Bcfg2.Server.Plugin.Probing,
self.write_data(client)
ReceiveData.__doc__ = Bcfg2.Server.Plugin.Probing.ReceiveData.__doc__
- def ReceiveDataItem(self, client, data):
+ def ReceiveDataItem(self, client, data, cgroups, cprobedata):
"""Receive probe results pertaining to client."""
- if client.hostname not in self.cgroups:
- self.cgroups[client.hostname] = []
- if client.hostname not in self.probedata:
- self.probedata[client.hostname] = ClientProbeDataSet()
if data.text == None:
self.logger.info("Got null response to probe %s from %s" %
(data.get('name'), client.hostname))
- self.probedata[client.hostname][data.get('name')] = \
- ProbeData('')
+ cprobedata[data.get('name')] = ProbeData('')
return
dlines = data.text.split('\n')
self.logger.debug("%s:probe:%s:%s" %
@@ -328,11 +325,11 @@ class Probes(Bcfg2.Server.Plugin.Probing,
for line in dlines[:]:
if line.split(':')[0] == 'group':
newgroup = line.split(':')[1].strip()
- if newgroup not in self.cgroups[client.hostname]:
- self.cgroups[client.hostname].append(newgroup)
+ if newgroup not in cgroups:
+ cgroups.append(newgroup)
dlines.remove(line)
dobj = ProbeData("\n".join(dlines))
- self.probedata[client.hostname][data.get('name')] = dobj
+ cprobedata[data.get('name')] = dobj
def get_additional_groups(self, meta):
return self.cgroups.get(meta.hostname, list())