From 78978ed3b163bcd71f18ecc8ca9d85f19e2cd2b2 Mon Sep 17 00:00:00 2001 From: "mallikarjuna.kolagatla" Date: Thu, 22 Feb 2018 09:30:06 +0000 Subject: [PATCH] Remove the disk erase timeout This patch modifies the erase_devices clean_step to wait beyond 50 minutes for the secure disk erase to complete as the disks bigger in size may take longer than 50 minutes to complete the operation. Making it a perpetual wait as disk erase operation cannot be killed once started until it is completed. Change-Id: I822d7097689478905e206a4ccbaea9c4b48c8b1b Closes-bug: 1748436 --- proliantutils/hpssa/manager.py | 9 +++------ proliantutils/tests/hpssa/raid_constants.py | 21 +++++++++++++++++++++ proliantutils/tests/hpssa/test_manager.py | 21 ++++++++++++++++++--- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/proliantutils/hpssa/manager.py b/proliantutils/hpssa/manager.py index 66829277..35a111a5 100644 --- a/proliantutils/hpssa/manager.py +++ b/proliantutils/hpssa/manager.py @@ -14,6 +14,7 @@ import json import os +import time import jsonschema from jsonschema import exceptions as json_schema_exc @@ -22,7 +23,6 @@ from proliantutils import exception from proliantutils.hpssa import constants from proliantutils.hpssa import disk_allocator from proliantutils.hpssa import objects -from proliantutils.ilo import common CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) RAID_CONFIG_SCHEMA = os.path.join(CURRENT_DIR, "raid_config_schema.json") @@ -378,11 +378,8 @@ def erase_devices(): if drives: controller.erase_devices(drives) - common.wait_for_operation_to_complete( - has_erase_completed, - delay_bw_retries=300, - failover_msg='Disk erase failed.' - ) + while not has_erase_completed(): + time.sleep(300) server.refresh() diff --git a/proliantutils/tests/hpssa/raid_constants.py b/proliantutils/tests/hpssa/raid_constants.py index 69aa9e48..cdb9780e 100644 --- a/proliantutils/tests/hpssa/raid_constants.py +++ b/proliantutils/tests/hpssa/raid_constants.py @@ -2486,3 +2486,24 @@ Smart Array P440 in Slot 2 Sanitize Estimated Max Erase Time: 0 hour(s)36 minute(s) Unrestricted Sanitize Supported: False ''' + +SSA_ERASE_IN_PROGRESS_NOT_SUPPORTED = ''' +Smart Array P440 in Slot 2 + Controller Mode: RAID + Pending Controller Mode: RAID + Sanitize Erase Supported: True + Primary Boot Volume: None + Secondary Boot Volume: None + + unassigned + + physicaldrive 1I:2:1 + Drive Type: Unassigned Drive + Interface Type: SAS + Size: 300 GB + Status: Erase In Progress + Drive Type: Unassigned Drive + Sanitize Erase Supported: False + Sanitize Estimated Max Erase Time: 0 hour(s)36 minute(s) + Unrestricted Sanitize Supported: False +''' diff --git a/proliantutils/tests/hpssa/test_manager.py b/proliantutils/tests/hpssa/test_manager.py index f5ed3408..ce3adb78 100644 --- a/proliantutils/tests/hpssa/test_manager.py +++ b/proliantutils/tests/hpssa/test_manager.py @@ -14,6 +14,7 @@ import mock import testtools +import time from proliantutils import exception from proliantutils.hpssa import manager @@ -480,8 +481,10 @@ class ManagerTestCases(testtools.TestCase): 'Raid enabled') self.assertEqual(ctrl_expected, server.controllers) + @mock.patch.object(time, 'sleep') @mock.patch.object(objects.Controller, 'execute_cmd') def test_erase_devices(self, controller_exec_cmd_mock, + sleep_mock, get_all_details_mock): erase_drive = raid_constants.SSA_ERASE_DRIVE erase_complete = raid_constants.SSA_ERASE_COMPLETE @@ -503,10 +506,15 @@ class ManagerTestCases(testtools.TestCase): self.assertTrue(controller_exec_cmd_mock.called) controller_exec_cmd_mock.assert_any_call(*cmd_args) self.assertEqual(expt_ret, ret) + self.assertFalse(sleep_mock.called) + @mock.patch.object(time, 'sleep') @mock.patch.object(objects.Controller, 'execute_cmd') def test_erase_devices_in_progress(self, controller_exec_cmd_mock, + sleep_mock, get_all_details_mock): + + erase_drive = raid_constants.SSA_ERASE_DRIVE erase_progress = raid_constants.SSA_ERASE_IN_PROGRESS erase_complete = raid_constants.SSA_ERASE_COMPLETE @@ -515,19 +523,24 @@ class ManagerTestCases(testtools.TestCase): '1I:2:1': 'Erase Complete. Reenable Before Using.', 'Summary': ('Sanitize Erase performed on the disks attached to' ' the controller.')}} - get_all_details_mock.side_effect = [erase_progress, erase_complete, - erase_complete] + get_all_details_mock.side_effect = [erase_drive, erase_progress, + erase_complete, erase_complete] ret = manager.erase_devices() - self.assertFalse(controller_exec_cmd_mock.called) + self.assertTrue(controller_exec_cmd_mock.called) self.assertEqual(expt_ret, ret) + self.assertTrue(sleep_mock.called) + @mock.patch.object(time, 'sleep') @mock.patch.object(objects.Controller, 'execute_cmd') def test_erase_devices_not_supported(self, controller_exec_cmd_mock, + sleep_mock, get_all_details_mock): erase_not_supported = raid_constants.SSA_ERASE_NOT_SUPPORTED erase_complete = raid_constants.SSA_ERASE_COMPLETE_NOT_SUPPORTED + erase_progress = raid_constants.SSA_ERASE_IN_PROGRESS_NOT_SUPPORTED get_all_details_mock.side_effect = [erase_not_supported, + erase_progress, erase_complete, erase_complete] value = ("Drive 1I:2:1: This operation is not supported in this " "physical drive") @@ -542,6 +555,8 @@ class ManagerTestCases(testtools.TestCase): ret = manager.erase_devices() self.assertEqual(expt_ret, ret) + self.assertTrue(controller_exec_cmd_mock.called) + self.assertTrue(sleep_mock.called) class RaidConfigValidationTestCases(testtools.TestCase):