@@ -54,8 +54,8 @@ def stop_monitoring(self, force=False):
5454 ssh_client .close ()
5555
5656 def _monitoring_loop (self ):
57- # ToDo: not needed and not safe - doesn't survive XAPI restarts
5857 vmuuid = self .get_uuid ()
58+ log .info ("monitor_loop handles VM %s" % (vmuuid ))
5959 start_time = time .time ()
6060 error_message = None
6161 docker .wipe_docker_other_config (self )
@@ -73,6 +73,8 @@ def _monitoring_loop(self):
7373 # if we got past the above, it's about time to delete the
7474 # error message, as all appears to be working again
7575 try :
76+ log .info ("monitor_loop destroys message for VM %s: %s"
77+ % (vmuuid , error_message ))
7678 api_helper .destroy_message (self .get_session (),
7779 error_message )
7880 except XenAPI .Failure :
@@ -87,37 +89,40 @@ def _monitoring_loop(self):
8789 try :
8890 session = self .get_session ()
8991 cause = docker .determine_error_cause (session , vmuuid )
92+ log .info ("monitor_loop creates message for VM %s: %s"
93+ % (vmuuid , cause ))
9094 error_message = api_helper .send_message (
9195 session ,
9296 self .get_uuid (),
93- "Cannot monitor containers on VM" ,
97+ "Container Management cannot monitor VM" ,
9498 cause )
9599 except (XenAPI .Failure ):
96100 # this can happen when XAPI is not running
97101 pass
98- log .info ("Could not connect to VM %s, retry" % (vmuuid ))
102+ log .info ("Could not connect to VM %s, will retry" % (vmuuid ))
99103 error_in_this_iteration = True
100104 if not error_in_this_iteration :
101105 try :
102106 self .__monitor_vm_events ()
103107 except (XenAPI .Failure , util .XSContainerException ):
104- log .exception ("monitor_vm_events threw an exception, retry" )
108+ log .exception ("__monitor_vm_events threw an exception, "
109+ "will retry" )
105110 if wipe_other_config_required :
106111 docker .wipe_docker_other_config (self )
107112 if not self ._stop_monitoring_request :
108113 time .sleep (MONITORRETRYSLEEPINS )
109- log .info ("monitor_vm returns from handling vm %s" % (vmuuid ))
114+ log .info ("monitor_loop returns from handling vm %s" % (vmuuid ))
110115
111116 def __monitor_vm_events (self ):
112117 session = self .get_session ()
113118 vmuuid = self .get_uuid ()
114119 ssh_client = ssh_helper .prepare_ssh_client (session , vmuuid )
115120 try :
116- cmd = "ncat -U /var/run/docker.sock"
121+ cmd = "ncat -U %s" % (docker .DOCKER_SOCKET_PATH )
122+ log .info ("__monitor_vm_events is running '%s' on VM '%s'"
123+ % (cmd , vmuuid ))
117124 stdin , stdout , _ = ssh_client .exec_command (cmd )
118125 stdin .write ("GET /events HTTP/1.0\r \n \r \n " )
119- log .debug ("__monitor_vm_events at %r is running: %r"
120- % (ssh_client .get_transport ().getpeername (), cmd ))
121126 self ._ssh_client = ssh_client
122127 data = ""
123128 # set unblocking io for select.select
@@ -165,7 +170,7 @@ def __monitor_vm_events(self):
165170 except Exception :
166171 util .log .exception ("Error when closing ssh_client for %r"
167172 % ssh_client )
168- log .debug ('__monitor_vm_events (%s) exited' % cmd )
173+ log .info ('__monitor_vm_events (%s) exited' % cmd )
169174
170175 def handle_docker_event (self , event ):
171176 if 'status' in event :
@@ -333,6 +338,7 @@ def monitor_host():
333338 DOCKER_MONITOR = DockerMonitor (host )
334339 else :
335340 DOCKER_MONITOR .set_host (host )
341+ log .info ("Monitoring host %s" % (host .get_id ()))
336342 try :
337343 # Avoid race conditions - get a current event token
338344 event_from = session .xenapi .event_from (["vm" ], '' , 0.0 )
@@ -359,8 +365,8 @@ def monitor_host():
359365 log .exception ("Failed when trying to logout" )
360366 except (socket .error , XenAPI .Failure , xmlrpclib .ProtocolError ):
361367 if session is not None :
362- log .info ("Could not connect to XAPI - Is XAPI running? " +
363- "Will retry in %d" % (XAPIRETRYSLEEPINS ))
368+ log .error ("Could not connect to XAPI - Is XAPI running? " +
369+ "Will retry in %d" % (XAPIRETRYSLEEPINS ))
364370 else :
365371 log .exception ("Recovering from XAPI failure - Is XAPI " +
366372 "restarting? Will retry in %d."
0 commit comments