mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 15:36:04 -03:30
Fix the job event partition alignment
it really should be always aligned to the hour, so that real job events don't slip through the cracks.
This commit is contained in:
@@ -1113,33 +1113,18 @@ def deepmerge(a, b):
|
|||||||
return b
|
return b
|
||||||
|
|
||||||
|
|
||||||
def create_partition(tblname, start=None, end=None, partition_label=None, minutely=False):
|
def create_partition(tblname, start=None):
|
||||||
"""Creates new partition table for events.
|
"""Creates new partition table for events. By default it covers the current hour."""
|
||||||
- start defaults to beginning of current hour
|
if start is None:
|
||||||
- end defaults to end of current hour
|
start = now()
|
||||||
- partition_label defaults to YYYYMMDD_HH
|
|
||||||
|
start = start.replace(microsecond=0, second=0, minute=0)
|
||||||
|
end = start + timedelta(hours=1)
|
||||||
|
|
||||||
- minutely will create partitions that span _a single minute_ for testing purposes
|
|
||||||
"""
|
|
||||||
current_time = now()
|
|
||||||
if not start:
|
|
||||||
if minutely:
|
|
||||||
start = current_time.replace(microsecond=0, second=0)
|
|
||||||
else:
|
|
||||||
start = current_time.replace(microsecond=0, second=0, minute=0)
|
|
||||||
if not end:
|
|
||||||
if minutely:
|
|
||||||
end = start.replace(microsecond=0, second=0) + timedelta(minutes=1)
|
|
||||||
else:
|
|
||||||
end = start.replace(microsecond=0, second=0, minute=0) + timedelta(hours=1)
|
|
||||||
start_timestamp = str(start)
|
start_timestamp = str(start)
|
||||||
end_timestamp = str(end)
|
end_timestamp = str(end)
|
||||||
|
|
||||||
if not partition_label:
|
partition_label = start.strftime('%Y%m%d_%H')
|
||||||
if minutely:
|
|
||||||
partition_label = start.strftime('%Y%m%d_%H%M')
|
|
||||||
else:
|
|
||||||
partition_label = start.strftime('%Y%m%d_%H')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
|
|||||||
Reference in New Issue
Block a user