mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
Make schedule teardown more reliable
This commit is contained in:
@@ -15,13 +15,15 @@ class Schedule(HasCreate, base.Base):
|
|||||||
NATURAL_KEY = ('unified_job_template', 'name')
|
NATURAL_KEY = ('unified_job_template', 'name')
|
||||||
|
|
||||||
def silent_delete(self):
|
def silent_delete(self):
|
||||||
"""If we are told to prevent_teardown of schedules, then keep them
|
"""
|
||||||
but do not leave them activated, or system will be swamped quickly"""
|
In every case, we start by disabling the schedule
|
||||||
|
to avoid cascading errors from a cleanup failure.
|
||||||
|
Then, if we are told to prevent_teardown of schedules, we keep them
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
|
self.patch(enabled=False)
|
||||||
if not config.prevent_teardown:
|
if not config.prevent_teardown:
|
||||||
return self.delete()
|
return self.delete()
|
||||||
else:
|
|
||||||
self.patch(enabled=False)
|
|
||||||
except (exc.NoContent, exc.NotFound, exc.Forbidden):
|
except (exc.NoContent, exc.NotFound, exc.Forbidden):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
from awxkit.api.resources import resources
|
from awxkit.api.resources import resources
|
||||||
from awxkit.utils import random_title, update_payload
|
from awxkit.utils import random_title, update_payload
|
||||||
from awxkit.api.mixins import HasStatus
|
from awxkit.api.mixins import HasStatus
|
||||||
from awxkit.config import config
|
|
||||||
from . import base
|
from . import base
|
||||||
from . import page
|
from . import page
|
||||||
|
|
||||||
@@ -53,9 +52,7 @@ class UnifiedJobTemplate(HasStatus, base.Base):
|
|||||||
return schedule
|
return schedule
|
||||||
|
|
||||||
def silent_delete(self):
|
def silent_delete(self):
|
||||||
if hasattr(self, '_schedules_store') and config.prevent_teardown:
|
if hasattr(self, '_schedules_store'):
|
||||||
# when prevent_teardown is off, we rely on cascade deletes
|
|
||||||
# in this case, looping is needed to turn them off
|
|
||||||
for schedule in self._schedules_store:
|
for schedule in self._schedules_store:
|
||||||
schedule.silent_delete()
|
schedule.silent_delete()
|
||||||
return super(UnifiedJobTemplate, self).silent_delete()
|
return super(UnifiedJobTemplate, self).silent_delete()
|
||||||
|
|||||||
Reference in New Issue
Block a user