← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] lp:~cjwatson/launchpad/prune-snap-files into lp:launchpad

 

Review: Approve code



Diff comments:

> === modified file 'lib/lp/scripts/garbo.py'
> --- lib/lp/scripts/garbo.py	2018-04-04 13:51:16 +0000
> +++ lib/lp/scripts/garbo.py	2018-04-30 10:45:14 +0000
> @@ -1564,6 +1567,32 @@
>          """
>  
>  
> +class SnapFilePruner(BulkPruner):
> +    """Prune old `SnapFile`s that have been uploaded to the store.
> +
> +    Binary files attached to `SnapBuild`s are typically very large, and once
> +    they've been uploaded to the store we don't really need to keep them in
> +    Launchpad as well.  Text files are typically small (<1MiB) and useful
> +    for retrospective analysis, so we preserve those indefinitely.
> +    """
> +    target_table_class = SnapFile
> +    ids_to_prune_query = """
> +        SELECT DISTINCT SnapFile.id
> +        FROM SnapFile, SnapBuild, SnapBuildJob, Job, LibraryFileAlias
> +        WHERE
> +            SnapFile.snapbuild = SnapBuild.id
> +            AND SnapBuildJob.snapbuild = SnapBuild.id
> +            AND SnapBuildJob.job_type = %s
> +            AND SnapBuildJob.job = Job.id
> +            AND Job.status = %s
> +            AND Job.date_finished <
> +                CURRENT_TIMESTAMP AT TIME ZONE 'UTC'
> +                - CAST('30 days' AS INTERVAL)
> +            AND SnapFile.libraryfile = LibraryFileAlias.id
> +            AND LibraryFileAlias.mimetype != 'text/plain'

For things like snapcraft source archive tarballs we probably don't really want to purge them just because the .snap has been uploaded to the store.

It looks like all but six of the current SnapFiles are .snaps or .manifests, so I wonder if we want to restrict the filename to *.snap rather than the mimetype to !text/plain?

> +        """ % (SnapBuildJobType.STORE_UPLOAD.value, JobStatus.COMPLETED.value)
> +
> +
>  class SnapStoreSeriesPopulator(TunableLoop):
>      """Populates Snap.store_series based on Snap.distro_series.
>  


-- 
https://code.launchpad.net/~cjwatson/launchpad/prune-snap-files/+merge/344825
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.


References