Skip to content

Commit 1a13811

Browse files
committed
landing_worker: delete patch content after landing (bug 1879536)
- delete patch content after landing - add one-time cli command to do this for previously landed jobs
1 parent fb22533 commit 1a13811

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

landoapi/cli.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ def run_post_deploy_sequence():
107107
)
108108

109109

110+
@cli.command(name="clean-landing-job-patches")
111+
def clean_landing_job_patches():
112+
"""Iterate over all landed jobs and delete their patches."""
113+
from landoapi.models.landing_job import LandingJob, LandingJobStatus
114+
from landoapi.storage import db, db_subsystem
115+
116+
db_subsystem.ensure_ready()
117+
jobs = LandingJob.query.filter(LandingJob.status == LandingJobStatus.LANDED).all()
118+
for job in jobs:
119+
for revision in job.revisions:
120+
revision.patch_bytes = b""
121+
db.session.commit()
122+
123+
110124
@cli.command(context_settings={"ignore_unknown_options": True})
111125
@click.argument("celery_arguments", nargs=-1, type=click.UNPROCESSED)
112126
def celery(celery_arguments):

landoapi/workers/landing_worker.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ def run_job(
439439
LandingJobAction.LAND, commit_id=commit_id, commit=True, db=db
440440
)
441441

442+
# Patches are no longer necessary, delete them.
443+
for revision in job.revisions:
444+
revision.patch_bytes = b""
445+
db.session.commit()
446+
442447
mots_path = Path(hgrepo.path) / "mots.yaml"
443448
if mots_path.exists():
444449
logger.info(f"{mots_path} found, setting reviewer data.")

0 commit comments

Comments
 (0)