Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add retry logic when fetching addons, and save error to cache for user investigation - #493

Open
MarcBresson wants to merge 11 commits into
FreeCAD:devfrom
MarcBresson:dev
Open

Add retry logic when fetching addons, and save error to cache for user investigation#493
MarcBresson wants to merge 11 commits into
FreeCAD:devfrom
MarcBresson:dev

Conversation

@MarcBresson

@MarcBresson MarcBresson commented Sep 3, 2026

Copy link
Copy Markdown

caching errors also allows for failed add-on fetches to be retried first

Mitigates #491

MarcBresson and others added 3 commits September 3, 2026 13:29
A crash during the 6-hourly cache rebuild could permanently drop an addon's cached package.xml/icon for that cycle (since the existing good clone was deleted beforehand). Retry git commands a few times before giving up. If an update ultimately fails, keep the existing good clone. Also retry addons that failed on the previous run first, so a rate-limit-driven failure doesn't always strand the same addons at the tail of a fixed processing order.
@MarcBresson

Copy link
Copy Markdown
Author

sorry for the format issue, ruff is runing when I save files, and it seems like I forgot to undo changes from the test file

@MarcBresson

Copy link
Copy Markdown
Author

Initially I also added an extra step that tried recloning the repo when there was a fetch failure, but I figured it would be redundant so I removed it in the third commit

Comment thread AddonCatalogCacheCreator.py Outdated
@MarcBresson

Copy link
Copy Markdown
Author

also, I did not use logger because the file was using print statements, but I don't know if there is a specific internal policy against the use of logger. If you want, I can replace prints with logger calls

@chennes chennes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks mostly good -- could you please rebuild the changes without the ruff formatting, and address the two inline code comments? Thanks!

Comment on lines -530 to -535
# In the event of basically ANY error, delete the original and re-clone.
print(e)
print("Deleting and re-cloning the original repo")
os.chdir(old_dir)
utils.rmdir(os.path.join(old_dir, name))
self.clone_or_update(name, url, branch)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep the fallback reclone: it wasn't designed for the intermittent failure case you're trying to handle here, but for things like a repo rename, where there is no recovery short of a deletion. If you drop it, then I have to log into the server to manually do this anything someone renames a repo (for example).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think deleting then recloning would have helped with a git pull problem, since the current path already fetches and hard resets the local repo. Renaming a repository has no effect on git itself, except when the remote URL changes, and even then git follows the redirect. A recent example was my own addon, which was renamed from FreeCad-Grid-Export to CarteGrid including the remote URL, and git followed the 301 and cloned successfully.

That said, looking closer there is a real gap that supports your point. The url passed into fetch_and_reset never actually gets applied to the local clone. So there's no git remote set-url origin anywhere in the update path. If a repo's URL changes in the catalog (rename, ownership transfer, host migration), the existing local clone just keeps fetching from whatever origin was set at the original clone. That works only as long as the old host keeps redirecting to the new one, and GitHub doesn't promise that survives a second rename or the old name getting reused by someone else. A move off GitHub wouldn't redirect at all.

So instead of bringing back delete and reclone, I'd rather fix that directly: add git remote set-url origin {url} before the fetch in fetch_and_reset, so the local remote always stays in sync with whatever the catalog currently says. That covers the case you are describing without reintroducing the part of the old code this PR is meant to remove, which is deleting a working copy before a replacement is confirmed.

I'll push that change very soon :)

Comment thread AddonCatalogCacheCreator.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants