Skip to content

Commit

Permalink
landing_worker: delete patch content after landing (bug 1879536)
Browse files Browse the repository at this point in the history
- delete patch content after landing
- add one-time cli command to do this for previously landed jobs
  • Loading branch information
zzzeid committed Feb 9, 2024
1 parent fb22533 commit 1a13811
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions landoapi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ def run_post_deploy_sequence():
)


@cli.command(name="clean-landing-job-patches")
def clean_landing_job_patches():
"""Iterate over all landed jobs and delete their patches."""
from landoapi.models.landing_job import LandingJob, LandingJobStatus
from landoapi.storage import db, db_subsystem

db_subsystem.ensure_ready()
jobs = LandingJob.query.filter(LandingJob.status == LandingJobStatus.LANDED).all()
for job in jobs:
for revision in job.revisions:
revision.patch_bytes = b""
db.session.commit()


@cli.command(context_settings={"ignore_unknown_options": True})
@click.argument("celery_arguments", nargs=-1, type=click.UNPROCESSED)
def celery(celery_arguments):
Expand Down
5 changes: 5 additions & 0 deletions landoapi/workers/landing_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ def run_job(
LandingJobAction.LAND, commit_id=commit_id, commit=True, db=db
)

# Patches are no longer necessary, delete them.
for revision in job.revisions:
revision.patch_bytes = b""
db.session.commit()

mots_path = Path(hgrepo.path) / "mots.yaml"
if mots_path.exists():
logger.info(f"{mots_path} found, setting reviewer data.")
Expand Down

0 comments on commit 1a13811

Please sign in to comment.