Commit 7b4abcb7 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Titouan Soulard

slapos: Watchdog use jio api for software instance bang

parent 36d8797c
...@@ -187,12 +187,32 @@ class Watchdog(object): ...@@ -187,12 +187,32 @@ class Watchdog(object):
def handle_process_state_change_event(self, headers, payload_dict): def handle_process_state_change_event(self, headers, payload_dict):
partition_id = payload_dict['groupname'] partition_id = payload_dict['groupname']
self.initialize_connection(partition_id) self.initialize_connection(partition_id)
partition = slapos.slap.ComputerPartition( if self.slap.jio_api_connector:
computer_id=self.computer_id, instance_list = self.slap.jio_api_connector.allDocs({
connection_helper=self.slap._connection_helper, "portal_type": "Software Instance",
partition_id=partition_id) "compute_node_id": self.computer_id,
partition.bang("%s process in partition %s encountered a problem" "compute_partition_id": partition_id,
% (payload_dict['processname'], partition_id)) }).get("result_list", [])
if len(instance_list) != 1:
raise ValueError("No instance found for %s %s %s" % (
self.computer_id,
partition_id,
instance_list,
))
self.slap.jio_api_connector.put({
"portal_type": "Software Instance",
"reported_state": "bang",
"status_message": "%s process in partition %s encountered a problem"
% (payload_dict['processname'], partition_id),
"reference": instance_list[0]["reference"]
})
else:
partition = slapos.slap.ComputerPartition(
computer_id=self.computer_id,
connection_helper=self.slap._connection_helper,
partition_id=partition_id)
partition.bang("%s process in partition %s encountered a problem"
% (payload_dict['processname'], partition_id))
self.create_partition_bang_timestamp_file(payload_dict['groupname']) self.create_partition_bang_timestamp_file(payload_dict['groupname'])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment