Commit d238b0e7 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: Dont check for stalled software releases on computers

   The verification is somehow duplicated with the ComputeNode_checkSoftwareInstallationState.

   The script to check Software Installations already expose problems whenever a
   new software is requested and not built properly, which is the focus of the
   verification removed by this commit.
parent b39fd3d6
...@@ -16,7 +16,6 @@ compute_node_title = context.getTitle() ...@@ -16,7 +16,6 @@ compute_node_title = context.getTitle()
node_ticket_title = "[MONITORING] Lost contact with compute_node %s" % reference node_ticket_title = "[MONITORING] Lost contact with compute_node %s" % reference
instance_ticket_title = "[MONITORING] Compute Node %s has a stalled instance process" % reference instance_ticket_title = "[MONITORING] Compute Node %s has a stalled instance process" % reference
software_ticket_title = "[MONITORING] Compute Node %s has a stalled software process" % reference
ticket_title = node_ticket_title ticket_title = node_ticket_title
description = "" description = ""
...@@ -62,7 +61,6 @@ if not should_notify: ...@@ -62,7 +61,6 @@ if not should_notify:
if instance_list: if instance_list:
should_notify = True should_notify = True
description = "The Compute Node %s (%s) didnt process its instances for more them 24 hours, last contact: %s"
for instance in instance_list: for instance in instance_list:
instance_access_status = instance.getAccessStatus() instance_access_status = instance.getAccessStatus()
...@@ -74,36 +72,11 @@ if not should_notify: ...@@ -74,36 +72,11 @@ if not should_notify:
last_contact = max(DateTime(instance_access_status.get('created_at')), last_contact) last_contact = max(DateTime(instance_access_status.get('created_at')), last_contact)
if (now - DateTime(instance_access_status.get('created_at'))) < 1.05: if (now - DateTime(instance_access_status.get('created_at'))) < 1.05:
should_notify = False should_notify = False
description = ""
break break
if not should_notify: if should_notify:
ticket_title = software_ticket_title description = "The Compute Node %s (%s) didnt process its instances for more them 24 hours, last contact: %s" % (
notification_message_reference = 'slapos-crm-compute_node_check_stalled_software_state.notification' context.getTitle(), context.getReference(), last_contact)
last_contact = "No Contact Information"
# Since server is contacting, check for stalled software releases processes
software_installation_list = portal.portal_catalog(
portal_type='Software Installation',
default_aggregate_uid=context.getUid(),
validation_state='validated')
if software_installation_list:
should_notify = True
description = "The Compute Node %s (%s) didnt process its software releases for more them 24 hours, last contact %s"
# Test if server didnt process the internal softwares releases for more them 24h
for installation in software_installation_list:
installation_access_status = installation.getAccessStatus()
if installation_access_status.get('no_data', None):
# Ignore if there isnt any data on it
continue
last_contact = max(DateTime(installation_access_status.get('created_at')), last_contact)
if (now - DateTime(installation_access_status.get('created_at'))) < 1.01:
should_notify = False
description = ""
break
if should_notify: if should_notify:
support_request = person.Base_getSupportRequestInProgress( support_request = person.Base_getSupportRequestInProgress(
...@@ -117,7 +90,7 @@ if should_notify: ...@@ -117,7 +90,7 @@ if should_notify:
if support_request is None: if support_request is None:
person.notify(support_request_title=ticket_title, person.notify(support_request_title=ticket_title,
support_request_description=description % (context.getTitle(), reference, last_contact), support_request_description=description,
aggregate=context.getRelativeUrl()) aggregate=context.getRelativeUrl())
support_request_relative_url = context.REQUEST.get("support_request_relative_url") support_request_relative_url = context.REQUEST.get("support_request_relative_url")
...@@ -134,7 +107,7 @@ if should_notify: ...@@ -134,7 +107,7 @@ if should_notify:
reference=notification_message_reference) reference=notification_message_reference)
if notification_message is None: if notification_message is None:
message = """%s""" % (description % (context.getTitle(), reference, last_contact)) message = """%s""" % description
else: else:
mapping_dict = {'compute_node_title':context.getTitle(), mapping_dict = {'compute_node_title':context.getTitle(),
'compute_node_id':reference, 'compute_node_id':reference,
......
...@@ -58,29 +58,6 @@ if aggregate_portal_type == "Compute Node": ...@@ -58,29 +58,6 @@ if aggregate_portal_type == "Compute Node":
if is_instance_stalled and len(instance_list): if is_instance_stalled and len(instance_list):
return "Process instance stalled, last contact was %s" % last_contact return "Process instance stalled, last contact was %s" % last_contact
# Since server is contacting, check for stalled software releases processes
is_software_stalled = True
last_contact = None
software_installation_list = portal.portal_catalog(
portal_type='Software Installation',
default_aggregate_uid=document.getUid(),
validation_state='validated')
# Test if server didnt process the internal softwares releases for more them 24h
for installation in software_installation_list:
installation_access_status = installation.getAccessStatus()
if installation_access_status.get('no_data', None):
# Ignore if there isnt any data on it
continue
last_contact = max(DateTime(installation_access_status.get('created_at')), last_contact)
if (now - DateTime(installation_access_status.get('created_at'))) < 1.01:
is_software_stalled = False
break
if is_software_stalled and len(software_installation_list):
return "Process instance stalled, last contact was %s" % last_contact
return "All OK, latest contact: %s " % last_contact return "All OK, latest contact: %s " % last_contact
else: else:
return "Problem, latest contact: %s" % last_contact return "Problem, latest contact: %s" % last_contact
......
...@@ -968,48 +968,6 @@ class TestSlapOSComputeNode_CheckState(TestCRMSkinsMixin): ...@@ -968,48 +968,6 @@ class TestSlapOSComputeNode_CheckState(TestCRMSkinsMixin):
self.assertEqual(event.getSource(), person.getRelativeUrl()) self.assertEqual(event.getSource(), person.getRelativeUrl())
@simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0')
@simulate('NotificationTool_getDocumentValue',
'reference=None',
'assert reference == "slapos-crm-compute_node_check_stalled_software_state.notification", reference\n' \
'return context.restrictedTraverse(' \
'context.REQUEST["test_ComputeNode_checkState_stalled_software"])')
def test_ComputeNode_checkState_stalled_software(self):
compute_node = self._makeComputeNode(owner=self.makePerson(user=0))[0]
self._makeComplexComputeNode()
person = compute_node.getSourceAdministrationValue()
self.portal.REQUEST['test_ComputeNode_checkState_stalled_software'] = \
self._makeNotificationMessage(compute_node.getReference())
# Computer is getting access, also internal instance
compute_node.setAccessStatus("")
self.start_requested_software_instance.setAccessStatus("")
try:
self.pinDateTime(DateTime()-1.1)
self.start_requested_software_installation.setAccessStatus("")
finally:
self.unpinDateTime()
compute_node.ComputeNode_checkState()
self.tic()
ticket_title = "[MONITORING] Compute Node %s has a stalled software process" % compute_node.getReference()
ticket = self._getGeneratedSupportRequest(compute_node.getUid(), ticket_title)
self.assertNotEqual(ticket, None)
event_list = ticket.getFollowUpRelatedValueList()
self.assertEqual(len(event_list), 1)
event = event_list[0]
self.assertEqual(event.getTitle(), ticket.getTitle())
self.assertIn(compute_node.getReference(), event.getTextContent())
self.assertEqual(event.getDestination(), ticket.getSourceSection())
self.assertEqual(event.getSource(), person.getRelativeUrl())
@simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0') @simulate('ERP5Site_isSupportRequestCreationClosed', '*args, **kwargs','return 0')
@simulate('NotificationTool_getDocumentValue', @simulate('NotificationTool_getDocumentValue',
'reference=None', 'reference=None',
......
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