summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins
diff options
context:
space:
mode:
authorMike McCallister <mike@mccllstr.com>2011-08-05 13:18:28 -0500
committerSol Jerome <sol.jerome@gmail.com>2011-08-09 15:14:04 -0500
commit7e61299d042c296ad1bbfd189b0457353ed84678 (patch)
treead87d5c541a1850c591b71bee01252c209638c19 /src/lib/Server/Plugins
parenta50d2a2c23415f5ce2f6941e9ae60532bf34b5be (diff)
downloadbcfg2-7e61299d042c296ad1bbfd189b0457353ed84678.tar.gz
bcfg2-7e61299d042c296ad1bbfd189b0457353ed84678.tar.bz2
bcfg2-7e61299d042c296ad1bbfd189b0457353ed84678.zip
Be more patient for notifications about generated SSHkeys.
Previously, we wanted one second for the FileMonitor to notify us about newly generated SSHkeys. Now, we wait up to ten seconds before logging a warning and giving up. (cherry picked from commit 204ddcddea55b1f8eed5f6dfe4dd2967bac5bad7)
Diffstat (limited to 'src/lib/Server/Plugins')
-rw-r--r--src/lib/Server/Plugins/SSHbase.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py
index 3ea2cb959..9e0580dbd 100644
--- a/src/lib/Server/Plugins/SSHbase.py
+++ b/src/lib/Server/Plugins/SSHbase.py
@@ -225,14 +225,19 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin,
self.GenerateHostKeys(client)
# Service the FAM events queued up by the key generation so
# the data structure entries will be available for binding.
- # NOTE: We're only waiting for one second. This seems ripe for
- # a potential race condition, because if the file monitor
- # doesn't get notified about the new key files in time, those
- # entries won't be available for binding.
- self.fam.handle_events_in_interval(1)
- if not filename in self.entries:
- self.logger.error("%s still not registered" % filename)
- raise Bcfg2.Server.Plugin.PluginExecutionError
+ #
+ # NOTE: We wait for up to ten seconds. There is some potential
+ # for race condition, because if the file monitor doesn't get
+ # notified about the new key files in time, those entries
+ # won't be available for binding. In practice, this seems
+ # "good enough".
+ tries = 0
+ while not filename in self.entries:
+ if tries >= 10:
+ self.logger.error("%s still not registered" % filename)
+ raise Bcfg2.Server.Plugin.PluginExecutionError
+ self.fam.handle_events_in_interval(1)
+ tries += 1
keydata = self.entries[filename].data
permdata = {'owner': 'root',
'group': 'root',