@@ -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-
213158def 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.
0 commit comments