RFR: 1512: MirrorBot may get stuck failing to clone repository
Zhao Song
duke at openjdk.org
Thu Sep 22 23:39:25 UTC 2022
On Wed, 14 Sep 2022 21:01:30 GMT, Erik Joelsson <erikj at openjdk.org> wrote:
>> Optimized the logic in MirrorBot.
>>
>> When MirrorBot tries to create a directory, the directory will have a 'temporary' suffix, then it will attempts cloning. It the cloning succeed, the suffix will be removed. If the clone fails or the bot happens to die, the directory will retain the suffix. On the next time, if we try to rerun the bot, the bot will detect the temporary directory and will delete the temporary directory first, therefore, the bot will not get stuck.
>
> bots/mirror/src/main/java/org/openjdk/skara/bots/mirror/MirrorBot.java line 102:
>
>> 100: } else {
>> 101: log.info("Found existing scratch directory for " + to.name());
>> 102: repo = Repository.get(dir).orElseThrow(() -> {
>
> Instead of introducing a temporary directory, I would recommend just falling back on recloning if `Repository::get` fails. Something like this:
>
> repo = Repository.get(dir).orElseGet(() -> {
> try {
> Files.walk(dir)
> .map(Path::toFile)
> .sorted(Comparator.reverseOrder())
> .forEach(File::delete);
> } catch (IOException e) {
> throw new UncheckedIOException(e);
> }
> Repository.mirror(from.url(), dir);
> );
Yes, it's much better! Thank you!
-------------
PR: https://git.openjdk.org/skara/pull/1374
More information about the skara-dev
mailing list