Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] dont allow to wake up a build if db where drop #671

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions runbot/models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def _filter_to_clean(self, dest_list, label):
if build.local_state == 'done':
full = build.gc_date + datetime.timedelta(days=(full_gc_days)) < fields.datetime.now()
for db in dest_by_builds_ids[build.id]:
yield (db, full)
yield (db, full, build)
elif build.local_state != 'running':
_logger.warning('db (%s) not deleted because state is not done', " ".join(dest_by_builds_ids[build.id]))

Expand All @@ -522,7 +522,7 @@ def filter_ids(dest_list, label):
for dest in dest_list:
build = self._build_from_dest(dest)
if build and build in self:
yield (dest, full)
yield (dest, full, build)
elif not build:
_logger.info('%s (%s) skipped because not dest format', label, dest)
_filter = filter_ids
Expand All @@ -531,9 +531,16 @@ def filter_ids(dest_list, label):

existing_db = list_local_dbs(additionnal_conditions=additionnal_conditions)

for db, _ in _filter(dest_list=existing_db, label='db'):
dropped_db_builds_ids = []
for db, _, build in _filter(dest_list=existing_db, label='db'):
self._logger('Removing database')
self._local_pg_dropdb(db)
dropped_db_builds_ids.append(build.id)

gced_builds = self.browse(dropped_db_builds_ids)
gced_builds.database_ids = False
for gced_build in gced_builds:
gced_build._log('build', 'Build was garbage collected')

builds_dir = Path(self.env['runbot.runbot']._root()) / 'build'

Expand All @@ -542,7 +549,7 @@ def filter_ids(dest_list, label):
else:
dests = _filter(dest_list=builds_dir.iterdir(), label='workspace')

for dest, full in dests:
for dest, full, _ in dests:
build_dir = Path(builds_dir) / dest
if full:
_logger.info('Removing build dir "%s"', dest)
Expand Down