-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from ctrliq/devel
Sync to upstream 23.1.0
- Loading branch information
Showing
40 changed files
with
1,371 additions
and
1,060 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,3 +165,7 @@ use_dev_supervisor.txt | |
|
||
awx/ui_next/src | ||
awx/ui_next/build | ||
|
||
# Docs build stuff | ||
docs/docsite/build/ | ||
_readthedocs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
from awx.main.models import HostMetric | ||
from django.core.management.base import BaseCommand | ||
from django.conf import settings | ||
from awx.main.tasks.host_metrics import HostMetricTask | ||
|
||
|
||
class Command(BaseCommand): | ||
""" | ||
Run soft-deleting of HostMetrics | ||
This command provides cleanup task for HostMetric model. | ||
There are two modes, which run in following order: | ||
- soft cleanup | ||
- - Perform soft-deletion of all host metrics last automated 12 months ago or before. | ||
This is the same as issuing a DELETE request to /api/v2/host_metrics/N/ for all host metrics that match the criteria. | ||
- - updates columns delete, deleted_counter and last_deleted | ||
- hard cleanup | ||
- - Permanently erase from the database all host metrics last automated 36 months ago or before. | ||
This operation happens after the soft deletion has finished. | ||
""" | ||
|
||
help = 'Run soft-deleting of HostMetrics' | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('--months-ago', type=int, dest='months-ago', action='store', help='Threshold in months for soft-deleting') | ||
help = 'Run soft and hard-deletion of HostMetrics' | ||
|
||
def handle(self, *args, **options): | ||
months_ago = options.get('months-ago') or None | ||
|
||
if not months_ago: | ||
months_ago = getattr(settings, 'CLEANUP_HOST_METRICS_SOFT_THRESHOLD', 12) | ||
|
||
HostMetric.cleanup_task(months_ago) | ||
HostMetricTask().cleanup(soft_threshold=settings.CLEANUP_HOST_METRICS_SOFT_THRESHOLD, hard_threshold=settings.CLEANUP_HOST_METRICS_HARD_THRESHOLD) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.utils.timezone import now | ||
from rest_framework.fields import DateTimeField | ||
|
||
|
||
def is_run_threshold_reached(setting, threshold_seconds): | ||
last_time = DateTimeField().to_internal_value(setting) if setting else None | ||
if not last_time: | ||
return True | ||
else: | ||
return (now() - last_time).total_seconds() > threshold_seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.