[PATCH 1/2] the agent will now retry to connect incase the http.request fails This ensures that the agent doesn't just die if networking configuration isn't completed by the time the agent is launched.

Dan Radez dradez at redhat.com
Fri Dec 9 15:07:10 UTC 2011


---
 agent/aeolus-audrey-agent.spec.in |    2 +-
 agent/audrey_agent.in.py          |   25 ++++++++++++++++++++++---
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/agent/aeolus-audrey-agent.spec.in b/agent/aeolus-audrey-agent.spec.in
index 39a106c..6e09af8 100644
--- a/agent/aeolus-audrey-agent.spec.in
+++ b/agent/aeolus-audrey-agent.spec.in
@@ -15,7 +15,7 @@
 #
 Name:       aeolus-audrey-agent
 Version:    @VERSION@
-Release:    14%{?dist}
+Release:    15%{?dist}
 Summary:    The Aeolus Audrey Startup Agent
 
 Group:      Applications/System
diff --git a/agent/audrey_agent.in.py b/agent/audrey_agent.in.py
index 9ef7826..fb554d2 100755
--- a/agent/audrey_agent.in.py
+++ b/agent/audrey_agent.in.py
@@ -862,15 +862,21 @@ class CSClient(object):
         Description:
             Issue the http get to the the Config Server.
         '''
-        return self.http.request(url, method='GET', headers=headers)
+        try:
+            return self.http.request(url, method='GET', headers=headers)
+        except Exception, e:
+            return (e, None)
 
     def _put(self, url, body=None, headers=None):
         '''
         Description:
             Issue the http put to the the Config Server.
         '''
-        return self.http.request(url, method='PUT',
-                            body=body, headers=headers)
+        try:
+            return self.http.request(url, method='PUT',
+                                body=body, headers=headers)
+        except Exception, e:
+            return (e, None)
 
     def _validate_http_status(self, status):
         '''
@@ -1297,6 +1303,19 @@ def audrey_script_main(client_http=None):
     cs_client = CSClient(**conf)
     if client_http:
         cs_client.http = client_http
+    # test connectivity, try and wait for it if it's not there
+    url = cs_client._cs_url('version')
+    while isinstance(cs_client._get(url)[0], Exception):
+        if max_retry:
+            max_retry-=1
+            LOGGER.info('Failed attempt to contact config server')
+            sleep(10)
+        else:
+            LOGGER.error('Failed to connect to the Configserver')
+            exit(1)
+
+    max_retry = 5
+
     LOGGER.info(str(cs_client))
 
     LOGGER.debug('Get optional tooling from the Config Server')
-- 
1.7.7.3




More information about the aeolus-devel mailing list