Skip to content

Commit 02dc6ae

Browse files
authored
Build: delete old finish_inactive_builds (#12417)
We are using healthcheck for all the projects now and it has its own task to finish unhealthy builds.
1 parent 4f325f1 commit 02dc6ae

File tree

3 files changed

+0
-63
lines changed

3 files changed

+0
-63
lines changed

readthedocs/projects/tasks/utils.py

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -155,61 +155,6 @@ def finish_unhealthy_builds():
155155
)
156156

157157

158-
@app.task()
159-
def finish_inactive_builds():
160-
"""
161-
Finish inactive builds.
162-
163-
A build is consider inactive if it's not in a final state and it has been
164-
"running" for more time that the allowed one (``Project.container_time_limit``
165-
or ``BUILD_TIME_LIMIT`` plus a 20% of it).
166-
167-
These inactive builds will be marked as ``success`` and ``CANCELLED`` with an
168-
``error`` to be communicated to the user.
169-
"""
170-
# TODO: delete this task once we are fully migrated to ``BUILD_HEALTHCHECK``
171-
time_limit = settings.BUILD_TIME_LIMIT * 1.2
172-
delta = datetime.timedelta(seconds=time_limit)
173-
query = (
174-
~Q(state__in=BUILD_FINAL_STATES)
175-
& Q(date__lt=timezone.now() - delta)
176-
& Q(date__gt=timezone.now() - datetime.timedelta(days=1))
177-
& ~Q(project__feature__feature_id=Feature.BUILD_HEALTHCHECK)
178-
)
179-
180-
projects_finished = set()
181-
builds_finished = []
182-
builds = Build.objects.filter(query)[:50]
183-
for build in builds:
184-
if build.project.container_time_limit:
185-
custom_delta = datetime.timedelta(
186-
seconds=int(build.project.container_time_limit),
187-
)
188-
if build.date + custom_delta > timezone.now():
189-
# Do not mark as CANCELLED builds with a custom time limit that wasn't
190-
# expired yet (they are still building the project version)
191-
continue
192-
193-
build.success = False
194-
build.state = BUILD_STATE_CANCELLED
195-
build.save()
196-
197-
Notification.objects.add(
198-
message_id=BuildAppError.BUILD_TERMINATED_DUE_INACTIVITY,
199-
attached_to=build,
200-
)
201-
202-
builds_finished.append(build.pk)
203-
projects_finished.add(build.project.slug)
204-
205-
log.info(
206-
'Builds marked as "Terminated due inactivity".',
207-
count=len(builds_finished),
208-
project_slugs=projects_finished,
209-
build_pks=builds_finished,
210-
)
211-
212-
213158
def send_external_build_status(version_type, build_pk, commit, status):
214159
"""
215160
Check if build is external and Send Build Status for project external versions.

readthedocs/rtd_tests/tests/test_project.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
)
3131
from readthedocs.projects.exceptions import ProjectConfigurationError
3232
from readthedocs.projects.models import Project
33-
from readthedocs.projects.tasks.utils import finish_inactive_builds
3433

3534

3635
class ProjectMixin:

readthedocs/settings/base.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -651,13 +651,6 @@ def BUILD_MEMORY_LIMIT(self):
651651
"schedule": crontab(minute="*"),
652652
"options": {"queue": "web"},
653653
},
654-
# TODO: delete `quarter-finish-inactive-builds` once we are fully
655-
# migrated into build healthcheck
656-
"quarter-finish-inactive-builds": {
657-
"task": "readthedocs.projects.tasks.utils.finish_inactive_builds",
658-
"schedule": crontab(minute="*/15"),
659-
"options": {"queue": "web"},
660-
},
661654
"every-day-delete-old-search-queries": {
662655
"task": "readthedocs.search.tasks.delete_old_search_queries_from_db",
663656
"schedule": crontab(minute=0, hour=0),

0 commit comments

Comments
 (0)