Skip to content

Commit a56a9e6

Browse files
authored
Merge pull request #5602 from StackStorm/ttl_param_rename
2 parents 1041007 + 9f6c7e7 commit a56a9e6

14 files changed

Lines changed: 62 additions & 59 deletions

File tree

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Added
152152

153153
Contributed by @Kami.
154154

155-
* Added garbage collection for rule_enforcement and trace models #5596
155+
* Added garbage collection for rule_enforcement and trace models #5596/5602
156156
Contributed by Amanda McGuinness (@amanda11 intive)
157157

158158

conf/st2.conf.sample

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,23 +167,23 @@ dump_dir = /opt/stackstorm/exports/
167167
logging = /etc/st2/logging.exporter.conf
168168

169169
[garbagecollector]
170-
# Action execution output objects (ones generated by action output streaming) older than this value (days) will be automatically deleted.
170+
# Action execution output objects (ones generated by action output streaming) older than this value (days) will be automatically deleted. Defaults to 7.
171171
action_executions_output_ttl = 7
172-
# Action executions and related objects (live actions, action output objects) older than this value (days) will be automatically deleted.
172+
# Action executions and related objects (live actions, action output objects) older than this value (days) will be automatically deleted. Defaults to None (disabled).
173173
action_executions_ttl = None
174174
# How often to check database for old data and perform garbage collection.
175175
collection_interval = 600
176176
# Location of the logging configuration file.
177177
logging = /etc/st2/logging.garbagecollector.conf
178178
# Set to True to perform garbage collection on Inquiries (based on the TTL value per Inquiry)
179179
purge_inquiries = False
180-
# Rule enforcements older than this value (days) will be automatically deleted.
181-
rule_enforcement_ttl = None
180+
# Rule enforcements older than this value (days) will be automatically deleted. Defaults to None (disabled).
181+
rule_enforcements_ttl = None
182182
# How long to wait / sleep (in seconds) between collection of different object types.
183183
sleep_delay = 2
184-
# Trace objects older than this value (days) will be automatically deleted.
185-
trace_ttl = None
186-
# Trigger instances older than this value (days) will be automatically deleted.
184+
# Trace objects older than this value (days) will be automatically deleted. Defaults to None (disabled).
185+
traces_ttl = None
186+
# Trigger instances older than this value (days) will be automatically deleted. Defaults to None (disabled).
187187
trigger_instances_ttl = None
188188

189189
[keyvalue]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import sys
1818

19-
from st2common.cmd.purge_rule_enforcement import main
19+
from st2common.cmd.purge_rule_enforcements import main
2020

2121
if __name__ == "__main__":
2222
sys.exit(main())
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import sys
1818

19-
from st2common.cmd.purge_trace import main
19+
from st2common.cmd.purge_traces import main
2020

2121
if __name__ == "__main__":
2222
sys.exit(main())

st2common/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
"bin/st2-register-content",
5454
"bin/st2-purge-executions",
5555
"bin/st2-purge-trigger-instances",
56-
"bin/st2-purge-trace",
57-
"bin/st2-purge-rule-enforcement",
56+
"bin/st2-purge-traces",
57+
"bin/st2-purge-rule-enforcements",
5858
"bin/st2-run-pack-tests",
5959
"bin/st2ctl",
6060
"bin/st2-generate-symmetric-crypto-key",

st2common/st2common/cmd/purge_rule_enforcement.py renamed to st2common/st2common/cmd/purge_rule_enforcements.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from st2common.script_setup import teardown as common_teardown
3636
from st2common.constants.exit_codes import SUCCESS_EXIT_CODE
3737
from st2common.constants.exit_codes import FAILURE_EXIT_CODE
38-
from st2common.garbage_collection.rule_enforcement import purge_rule_enforcement
38+
from st2common.garbage_collection.rule_enforcement import purge_rule_enforcements
3939

4040
__all__ = ["main"]
4141

@@ -71,7 +71,7 @@ def main():
7171

7272
# Purge models.
7373
try:
74-
purge_rule_enforcement(logger=LOG, timestamp=timestamp)
74+
purge_rule_enforcements(logger=LOG, timestamp=timestamp)
7575
except Exception as e:
7676
LOG.exception(six.text_type(e))
7777
return FAILURE_EXIT_CODE
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from st2common.script_setup import teardown as common_teardown
3636
from st2common.constants.exit_codes import SUCCESS_EXIT_CODE
3737
from st2common.constants.exit_codes import FAILURE_EXIT_CODE
38-
from st2common.garbage_collection.trace import purge_trace
38+
from st2common.garbage_collection.trace import purge_traces
3939

4040
__all__ = ["main"]
4141

@@ -71,7 +71,7 @@ def main():
7171

7272
# Purge models.
7373
try:
74-
purge_trace(logger=LOG, timestamp=timestamp)
74+
purge_traces(logger=LOG, timestamp=timestamp)
7575
except Exception as e:
7676
LOG.exception(six.text_type(e))
7777
return FAILURE_EXIT_CODE

st2common/st2common/garbage_collection/rule_enforcement.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
from st2common.persistence.rule_enforcement import RuleEnforcement
2525
from st2common.util import isotime
2626

27-
__all__ = ["purge_rule_enforcement"]
27+
__all__ = ["purge_rule_enforcements"]
2828

2929

30-
def purge_rule_enforcement(logger, timestamp):
30+
def purge_rule_enforcements(logger, timestamp):
3131
"""
3232
:param timestamp: Rule enforcement instances older than this timestamp will be deleted.
3333
:type timestamp: ``datetime.datetime

st2common/st2common/garbage_collection/trace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
from st2common.persistence.trace import Trace
2525
from st2common.util import isotime
2626

27-
__all__ = ["purge_trace"]
27+
__all__ = ["purge_traces"]
2828

2929

30-
def purge_trace(logger, timestamp):
30+
def purge_traces(logger, timestamp):
3131
"""
3232
:param timestamp: Trace instances older than this timestamp will be deleted.
3333
:type timestamp: ``datetime.datetime

st2common/tests/unit/test_purge_rule_enforcement.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import bson
1818

1919
from st2common import log as logging
20-
from st2common.garbage_collection.rule_enforcement import purge_rule_enforcement
20+
from st2common.garbage_collection.rule_enforcement import purge_rule_enforcements
2121
from st2common.models.db.rule_enforcement import RuleEnforcementDB
2222
from st2common.persistence.rule_enforcement import RuleEnforcement
2323
from st2common.util import date as date_utils
@@ -46,7 +46,7 @@ def test_no_timestamp_doesnt_delete(self):
4646
self.assertRaisesRegexp(
4747
ValueError,
4848
expected_msg,
49-
purge_rule_enforcement,
49+
purge_rule_enforcements,
5050
logger=LOG,
5151
timestamp=None,
5252
)
@@ -63,7 +63,7 @@ def test_purge(self):
6363
)
6464

6565
self.assertEqual(len(RuleEnforcement.get_all()), 2)
66-
purge_rule_enforcement(logger=LOG, timestamp=now - timedelta(days=10))
66+
purge_rule_enforcements(logger=LOG, timestamp=now - timedelta(days=10))
6767
self.assertEqual(len(RuleEnforcement.get_all()), 1)
6868

6969
@staticmethod

0 commit comments

Comments
 (0)