mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +00:00
[2244] renamed BaseComponent.is_failed() to is_restarting().
so it sounds more natural as an English term.
This commit is contained in:
@@ -45,7 +45,7 @@ COMPONENT_RESTART_DELAY = 10
|
|||||||
|
|
||||||
STATE_DEAD = 'dead'
|
STATE_DEAD = 'dead'
|
||||||
STATE_STOPPED = 'stopped'
|
STATE_STOPPED = 'stopped'
|
||||||
STATE_FAILED = 'failed'
|
STATE_RESTARTING = 'restarting'
|
||||||
STATE_RUNNING = 'running'
|
STATE_RUNNING = 'running'
|
||||||
|
|
||||||
def get_signame(signal_number):
|
def get_signame(signal_number):
|
||||||
@@ -69,7 +69,7 @@ class BaseComponent:
|
|||||||
explicitly).
|
explicitly).
|
||||||
- Running - after start() was called, it started successfully and is
|
- Running - after start() was called, it started successfully and is
|
||||||
now running.
|
now running.
|
||||||
- Failed - the component failed (crashed) and is waiting for a restart
|
- Restarting - the component failed (crashed) and is waiting for a restart
|
||||||
- Dead - it failed and can not be resurrected.
|
- Dead - it failed and can not be resurrected.
|
||||||
|
|
||||||
Init
|
Init
|
||||||
@@ -85,7 +85,7 @@ class BaseComponent:
|
|||||||
+<-----------+ |
|
+<-----------+ |
|
||||||
| |
|
| |
|
||||||
| kind == dispensable or kind|== needed and failed late
|
| kind == dispensable or kind|== needed and failed late
|
||||||
+-----------------------> Failed
|
+-----------------------> Restarting
|
||||||
|
|
|
|
||||||
| kind == core or kind == needed and it failed too soon
|
| kind == core or kind == needed and it failed too soon
|
||||||
v
|
v
|
||||||
@@ -238,7 +238,7 @@ class BaseComponent:
|
|||||||
exit_str)
|
exit_str)
|
||||||
if not self.is_running():
|
if not self.is_running():
|
||||||
raise ValueError("Can't fail component that isn't running")
|
raise ValueError("Can't fail component that isn't running")
|
||||||
self.__state = STATE_FAILED
|
self.__state = STATE_RESTARTING # tentatively set, maybe changed to DEAD
|
||||||
self._failed_internal()
|
self._failed_internal()
|
||||||
# If it is a core component or the needed component failed to start
|
# If it is a core component or the needed component failed to start
|
||||||
# (including it stopped really soon)
|
# (including it stopped really soon)
|
||||||
@@ -298,14 +298,14 @@ class BaseComponent:
|
|||||||
"""
|
"""
|
||||||
return self.__state == STATE_RUNNING
|
return self.__state == STATE_RUNNING
|
||||||
|
|
||||||
def is_failed(self):
|
def is_restarting(self):
|
||||||
"""Informs if the component has failed and is waiting for a restart.
|
"""Informs if the component has failed and is waiting for a restart.
|
||||||
|
|
||||||
Unlike the case of is_running(), if this returns True it always means
|
Unlike the case of is_running(), if this returns True it always means
|
||||||
the corresponding process has died and not yet restarted.
|
the corresponding process has died and not yet restarted.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.__state == STATE_FAILED
|
return self.__state == STATE_RESTARTING
|
||||||
|
|
||||||
def _start_internal(self):
|
def _start_internal(self):
|
||||||
"""
|
"""
|
||||||
@@ -609,7 +609,7 @@ class Configurator:
|
|||||||
for cname in old.keys():
|
for cname in old.keys():
|
||||||
if cname not in new:
|
if cname not in new:
|
||||||
component = self._components[cname][1]
|
component = self._components[cname][1]
|
||||||
if component.is_running() or component.is_failed():
|
if component.is_running() or component.is_restarting():
|
||||||
plan.append({
|
plan.append({
|
||||||
'command': STOP_CMD,
|
'command': STOP_CMD,
|
||||||
'component': component,
|
'component': component,
|
||||||
|
@@ -192,7 +192,7 @@ class ComponentTests(BossUtils, unittest.TestCase):
|
|||||||
self.assertFalse(self.__stop_called)
|
self.assertFalse(self.__stop_called)
|
||||||
self.assertFalse(self.__failed_called)
|
self.assertFalse(self.__failed_called)
|
||||||
self.assertFalse(component.is_running())
|
self.assertFalse(component.is_running())
|
||||||
self.assertFalse(component.is_failed())
|
self.assertFalse(component.is_restarting())
|
||||||
# We can't stop or fail the component yet
|
# We can't stop or fail the component yet
|
||||||
self.assertRaises(ValueError, component.stop)
|
self.assertRaises(ValueError, component.stop)
|
||||||
self.assertRaises(ValueError, component.failed, 1)
|
self.assertRaises(ValueError, component.failed, 1)
|
||||||
@@ -206,7 +206,7 @@ class ComponentTests(BossUtils, unittest.TestCase):
|
|||||||
self.assertFalse(self.__stop_called)
|
self.assertFalse(self.__stop_called)
|
||||||
self.assertFalse(self.__failed_called)
|
self.assertFalse(self.__failed_called)
|
||||||
self.assertTrue(component.is_running())
|
self.assertTrue(component.is_running())
|
||||||
self.assertFalse(component.is_failed())
|
self.assertFalse(component.is_restarting())
|
||||||
|
|
||||||
def __check_dead(self, component):
|
def __check_dead(self, component):
|
||||||
"""
|
"""
|
||||||
@@ -218,7 +218,7 @@ class ComponentTests(BossUtils, unittest.TestCase):
|
|||||||
self.assertTrue(self.__failed_called)
|
self.assertTrue(self.__failed_called)
|
||||||
self.assertEqual(1, self._exitcode)
|
self.assertEqual(1, self._exitcode)
|
||||||
self.assertFalse(component.is_running())
|
self.assertFalse(component.is_running())
|
||||||
self.assertFalse(component.is_failed())
|
self.assertFalse(component.is_restarting())
|
||||||
# Surely it can't be stopped when already dead
|
# Surely it can't be stopped when already dead
|
||||||
self.assertRaises(ValueError, component.stop)
|
self.assertRaises(ValueError, component.stop)
|
||||||
# Nor started
|
# Nor started
|
||||||
@@ -238,7 +238,7 @@ class ComponentTests(BossUtils, unittest.TestCase):
|
|||||||
self.assertFalse(self.__stop_called)
|
self.assertFalse(self.__stop_called)
|
||||||
self.assertTrue(self.__failed_called)
|
self.assertTrue(self.__failed_called)
|
||||||
self.assertTrue(component.is_running())
|
self.assertTrue(component.is_running())
|
||||||
self.assertFalse(component.is_failed())
|
self.assertFalse(component.is_restarting())
|
||||||
# Check it can't be started again
|
# Check it can't be started again
|
||||||
self.assertRaises(ValueError, component.start)
|
self.assertRaises(ValueError, component.start)
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ class ComponentTests(BossUtils, unittest.TestCase):
|
|||||||
self.assertFalse(self.__stop_called)
|
self.assertFalse(self.__stop_called)
|
||||||
self.assertTrue(self.__failed_called)
|
self.assertTrue(self.__failed_called)
|
||||||
self.assertFalse(component.is_running())
|
self.assertFalse(component.is_running())
|
||||||
self.assertTrue(component.is_failed())
|
self.assertTrue(component.is_restarting())
|
||||||
|
|
||||||
def __do_start_stop(self, kind):
|
def __do_start_stop(self, kind):
|
||||||
"""
|
"""
|
||||||
@@ -276,7 +276,7 @@ class ComponentTests(BossUtils, unittest.TestCase):
|
|||||||
self.assertTrue(self.__stop_called)
|
self.assertTrue(self.__stop_called)
|
||||||
self.assertFalse(self.__failed_called)
|
self.assertFalse(self.__failed_called)
|
||||||
self.assertFalse(component.is_running())
|
self.assertFalse(component.is_running())
|
||||||
self.assertFalse(component.is_failed())
|
self.assertFalse(component.is_restarting())
|
||||||
# Check it can't be stopped twice
|
# Check it can't be stopped twice
|
||||||
self.assertRaises(ValueError, component.stop)
|
self.assertRaises(ValueError, component.stop)
|
||||||
# Or failed
|
# Or failed
|
||||||
|
Reference in New Issue
Block a user