Stop running a periodic task for the noop PXE filter

Change-Id: I8e46835c56995321c49af5e608b0603c25571148
changes/70/725770/2
Dmitry Tantsur 2 years ago
parent 6e38efffea
commit 8a02e5a538
  1. 10
      ironic_inspector/conductor/manager.py
  2. 3
      ironic_inspector/pxe_filter/base.py
  3. 12
      ironic_inspector/test/unit/test_pxe_filter.py

@ -88,10 +88,14 @@ class ConductorManager(object):
spacing=CONF.clean_up_period
)(sync_with_ironic)
callables = [(periodic_clean_up_, None, None),
(sync_with_ironic_, None, None)]
driver_task = driver.get_periodic_sync_task()
if driver_task is not None:
callables.append((driver_task, None, None))
self._periodics_worker = periodics.PeriodicWorker(
callables=[(driver.get_periodic_sync_task(), None, None),
(periodic_clean_up_, None, None),
(sync_with_ironic_, None, None)],
callables=callables,
executor_factory=periodics.ExistingExecutor(utils.executor()),
on_failure=self._periodics_watchdog)

@ -205,6 +205,9 @@ class BaseFilter(interface.FilterDriver):
class NoopFilter(BaseFilter):
"""A trivial PXE boot filter."""
def get_periodic_sync_task(self):
return None
_DRIVER_MANAGER = None

@ -28,6 +28,10 @@ from ironic_inspector.test import base as test_base
CONF = cfg.CONF
class TestFilter(pxe_filter.BaseFilter):
pass
class TestDriverManager(test_base.BaseTest):
def setUp(self):
super(TestDriverManager, self).setUp()
@ -90,7 +94,7 @@ class BaseFilterBaseTest(test_base.BaseTest):
self.mock_bounded_semaphore = self.useFixture(
fixtures.MockPatchObject(semaphore, 'BoundedSemaphore')).mock
self.mock_bounded_semaphore.return_value = self.mock_lock
self.driver = pxe_filter.NoopFilter()
self.driver = TestFilter()
def assert_driver_is_locked(self):
"""Assert the driver is currently locked and wasn't locked before."""
@ -142,10 +146,10 @@ class TestBaseFilterFsmPrecautions(BaseFilterBaseTest):
def setUp(self):
super(TestBaseFilterFsmPrecautions, self).setUp()
self.mock_fsm = self.useFixture(
fixtures.MockPatchObject(pxe_filter.NoopFilter, 'fsm')).mock
fixtures.MockPatchObject(TestFilter, 'fsm')).mock
# NOTE(milan): overriding driver so that the patch ^ is applied
self.mock_bounded_semaphore.reset_mock()
self.driver = pxe_filter.NoopFilter()
self.driver = TestFilter()
self.mock_reset = self.useFixture(
fixtures.MockPatchObject(self.driver, 'reset')).mock
@ -168,7 +172,7 @@ class TestBaseFilterFsmPrecautions(BaseFilterBaseTest):
raise automaton_errors.NotFound('Oops!')
self.assertRaisesRegex(pxe_filter.InvalidFilterDriverState,
'.*NoopFilter.*Oops!', fun)
'.*TestFilter.*Oops!', fun)
self.mock_reset.assert_not_called()
def test_fsm_reset_on_error_ctx_custom_error(self):

Loading…
Cancel
Save