summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-15 10:33:15 +0000
committerGerrit Code Review <review@openstack.org>2017-06-15 10:33:15 +0000
commite677f12d4b3e18042cf4ea40e5d6bee90e820d3e (patch)
tree25a5f570914103613371a3051e4f566688c70ccc
parent1e2c73fea5d262b71ed35ecd1c3564565aefe741 (diff)
parentdd37dbaae9db80c0791553b5077cfec5c553f253 (diff)
Merge "Deprecate removing old status and disable it by default"
-rw-r--r--example.conf10
-rw-r--r--ironic_inspector/conf.py6
-rw-r--r--ironic_inspector/node_cache.py31
-rw-r--r--ironic_inspector/test/unit/test_node_cache.py12
-rw-r--r--releasenotes/notes/status-removal-fa1d9a98ffad9f60.yaml11
5 files changed, 49 insertions, 21 deletions
diff --git a/example.conf b/example.conf
index fa29ca0..82185aa 100644
--- a/example.conf
+++ b/example.conf
@@ -22,10 +22,12 @@
22# disable. (integer value) 22# disable. (integer value)
23#timeout = 3600 23#timeout = 3600
24 24
25# For how much time (in seconds) to keep status information about 25# DEPRECATED: For how much time (in seconds) to keep status
26# nodes after introspection was finished for them. Default value is 1 26# information about nodes after introspection was finished for them.
27# week. (integer value) 27# Set to 0 (the default) to disable the timeout. (integer value)
28#node_status_keep_time = 604800 28# This option is deprecated for removal.
29# Its value may be silently ignored in the future.
30#node_status_keep_time = 0
29 31
30# Amount of time in seconds, after which repeat clean up of timed out 32# Amount of time in seconds, after which repeat clean up of timed out
31# nodes and old nodes status information. (integer value) 33# nodes and old nodes status information. (integer value)
diff --git a/ironic_inspector/conf.py b/ironic_inspector/conf.py
index a67f934..97f1360 100644
--- a/ironic_inspector/conf.py
+++ b/ironic_inspector/conf.py
@@ -155,10 +155,12 @@ SERVICE_OPTS = [
155 help=_('Timeout after which introspection is considered ' 155 help=_('Timeout after which introspection is considered '
156 'failed, set to 0 to disable.')), 156 'failed, set to 0 to disable.')),
157 cfg.IntOpt('node_status_keep_time', 157 cfg.IntOpt('node_status_keep_time',
158 default=604800, 158 default=0,
159 help=_('For how much time (in seconds) to keep status ' 159 help=_('For how much time (in seconds) to keep status '
160 'information about nodes after introspection was ' 160 'information about nodes after introspection was '
161 'finished for them. Default value is 1 week.')), 161 'finished for them. Set to 0 (the default) '
162 'to disable the timeout.'),
163 deprecated_for_removal=True),
162 cfg.IntOpt('clean_up_period', 164 cfg.IntOpt('clean_up_period',
163 default=60, 165 default=60,
164 help=_('Amount of time in seconds, after which repeat clean up ' 166 help=_('Amount of time in seconds, after which repeat clean up '
diff --git a/ironic_inspector/node_cache.py b/ironic_inspector/node_cache.py
index 7ccaa5e..d0da563 100644
--- a/ironic_inspector/node_cache.py
+++ b/ironic_inspector/node_cache.py
@@ -865,22 +865,23 @@ def clean_up():
865 865
866 :return: list of timed out node UUID's 866 :return: list of timed out node UUID's
867 """ 867 """
868 status_keep_threshold = (timeutils.utcnow() - datetime.timedelta( 868 if CONF.node_status_keep_time > 0:
869 seconds=CONF.node_status_keep_time)) 869 status_keep_threshold = (timeutils.utcnow() - datetime.timedelta(
870 seconds=CONF.node_status_keep_time))
871 with db.ensure_transaction() as session:
872 db.model_query(db.Node, session=session).filter(
873 db.Node.finished_at.isnot(None),
874 db.Node.finished_at < status_keep_threshold).delete()
875
876 timeout = CONF.timeout
877 if timeout <= 0:
878 return []
879 threshold = timeutils.utcnow() - datetime.timedelta(seconds=timeout)
880 uuids = [row.uuid for row in
881 db.model_query(db.Node.uuid).filter(
882 db.Node.started_at < threshold,
883 db.Node.finished_at.is_(None)).all()]
870 884
871 with db.ensure_transaction() as session:
872 db.model_query(db.Node, session=session).filter(
873 db.Node.finished_at.isnot(None),
874 db.Node.finished_at < status_keep_threshold).delete()
875
876 timeout = CONF.timeout
877 if timeout <= 0:
878 return []
879 threshold = timeutils.utcnow() - datetime.timedelta(seconds=timeout)
880 uuids = [row.uuid for row in
881 db.model_query(db.Node.uuid, session=session).filter(
882 db.Node.started_at < threshold,
883 db.Node.finished_at.is_(None)).all()]
884 if not uuids: 885 if not uuids:
885 return [] 886 return []
886 887
diff --git a/ironic_inspector/test/unit/test_node_cache.py b/ironic_inspector/test/unit/test_node_cache.py
index 2c185ce..ff0f1f7 100644
--- a/ironic_inspector/test/unit/test_node_cache.py
+++ b/ironic_inspector/test/unit/test_node_cache.py
@@ -410,6 +410,18 @@ class TestNodeCacheCleanUp(test_base.NodeTest):
410 410
411 self.assertEqual([], db.model_query(db.Node).all()) 411 self.assertEqual([], db.model_query(db.Node).all())
412 412
413 def test_old_status_disabled(self):
414 # Status clean up is disabled by default
415 session = db.get_session()
416 with session.begin():
417 db.model_query(db.Node).update(
418 {'finished_at': (datetime.datetime.utcnow() -
419 datetime.timedelta(days=10000))})
420
421 self.assertEqual([], node_cache.clean_up())
422
423 self.assertNotEqual([], db.model_query(db.Node).all())
424
413 425
414class TestNodeCacheGetNode(test_base.NodeTest): 426class TestNodeCacheGetNode(test_base.NodeTest):
415 def test_ok(self): 427 def test_ok(self):
diff --git a/releasenotes/notes/status-removal-fa1d9a98ffad9f60.yaml b/releasenotes/notes/status-removal-fa1d9a98ffad9f60.yaml
new file mode 100644
index 0000000..226102f
--- /dev/null
+++ b/releasenotes/notes/status-removal-fa1d9a98ffad9f60.yaml
@@ -0,0 +1,11 @@
1---
2upgrade:
3 - |
4 Old status records are no longer removed by default. They are still
5 removed if a node is removed from Ironic.
6deprecations:
7 - |
8 The ``node_status_keep_time`` configuration option is deprecated. Now that
9 we can remove status information about nodes removed from **ironic**, this
10 option does not make much sense, and maybe be confusing (see `bug 1695858
11 <https://bugs.launchpad.net/ironic-inspector/+bug/1695858>`_).