RFR: 1734: Reduce disk usage in pr bot

Erik Joelsson erikj at openjdk.org
Thu Mar 23 19:59:11 UTC 2023

On Thu, 23 Mar 2023 18:56:01 GMT, Zhao Song <zsong at openjdk.org> wrote:

> As Erik mentioned in the issue, currently, pr bot would create multiple repository clones in different sub directory in the scratch directory which resulting in significant disk space wastage within the container. 
> In this patch, the repository clones will be stored in a single directory at `scratch-x/pr/repos/repoName`, allowing different types of `WorkItems` to reuse this space.

This is a very minimal patch that does solve the issue. However, I don't like that IntegrateCommand has to know to call `getParent` on the scratchPath it gets to be able to resolve the correct path for a repo. I think we should hide this knowledge behind an abstraction. Instead of sending `Path scratchPath` around, we could define a new class `ScratchArea` that has methods for generating paths.

`ScratchArea` is initialized with a Path object. This could happen in `PullRequestWorkItem::run` and `prRun` can be changed to take a `ScratchArea` instance.
`ScratchArea.get(Repository)` would return a global repository path for that repository.
`ScratchArea.get(CommandHandler)` would return a path suitable for that command.
`ScratchArea.get(WorkItem)` would return a path suitable for that WorkItem.

This would move the knowledge of the exact file layout to this class, so individual WorkItems or commands wouldn't need to know the directory hierarchy themselves.


PR Review: https://git.openjdk.org/skara/pull/1491#pullrequestreview-1355469879

More information about the skara-dev mailing list