Skip to content

Comments

Add retry logic for singularity pull failures#158

Merged
yarikoptic merged 2 commits intomasterfrom
bf-retries-build
Feb 3, 2026
Merged

Add retry logic for singularity pull failures#158
yarikoptic merged 2 commits intomasterfrom
bf-retries-build

Conversation

@yarikoptic
Copy link
Member

Retry singularity pull operations that fail with exit code 255, which typically indicates network-related issues (unexpected EOF, timeouts, connection failures). Uses exponential backoff with up to 3 attempts. Cleans up partial downloads between retries and logs progress for visibility.

Retry singularity pull operations that fail with exit code 255,
which typically indicates network-related issues (unexpected EOF,
timeouts, connection failures). Uses exponential backoff with
up to 3 attempts. Cleans up partial downloads between retries
and logs progress for visibility.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@yarikoptic yarikoptic requested a review from Copilot February 3, 2026 19:23
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yarikoptic, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the reliability of Singularity image acquisition by introducing a robust retry mechanism. It specifically targets transient network-related failures, identified by exit code 255, ensuring that singularity pull operations are more resilient to intermittent connectivity issues. By implementing exponential backoff and cleaning up partial downloads, the change aims to reduce build failures and improve the overall stability of image creation processes.

Highlights

  • Retry Logic for Singularity Pulls: Implemented a retry mechanism for singularity pull operations that fail due to specific error conditions.
  • Targeted Error Handling: Retries are specifically triggered when singularity pull exits with code 255, which commonly indicates network-related issues such as unexpected EOF, timeouts, or connection failures.
  • Exponential Backoff: The retry logic utilizes an exponential backoff strategy, attempting the pull up to 3 times with increasing delays between attempts.
  • Partial Download Cleanup: Between retry attempts, any partially downloaded .sif.tmp files are automatically cleaned up to ensure a fresh start for the next pull attempt.
  • Improved Logging: Added informative warning messages for each retry attempt and a final error message if all attempts fail, providing better visibility into the pull process.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • scripts/create_singularities
    • Added a while True loop with a try-except block around the singularity pull command to implement retry logic.
    • Configured max_attempts to 3 and integrated an exp_wait function for exponential backoff between retries.
    • Modified error handling to specifically catch subprocess.CalledProcessError and retry only if e.returncode is 255.
    • Included tmpfile.unlink() within the retry logic to clean up partial downloads before subsequent attempts.
    • Added log.warning messages for retry attempts and log.error for final failures to provide better operational visibility.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces valuable retry logic for singularity pull operations, which will improve robustness against transient network failures. My review focuses on enhancing the clarity of the retry mechanism and ensuring that temporary files are cleaned up correctly under all failure conditions to prevent orphaned files.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds retry logic to the singularity pull operation to handle transient network failures. When singularity pull fails with exit code 255 (typically indicating network issues like EOF or timeouts), the code now automatically retries with exponential backoff instead of failing immediately. Partial downloads are cleaned up between retry attempts, and progress is logged for visibility.

Changes:

  • Added retry loop with exponential backoff for singularity pull operations
  • Implemented cleanup of partial downloads between retries
  • Added logging for retry attempts and failures

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yarikoptic
Copy link
Member Author

there is fails due to shell check... will push those

Replace complex chained && || construct with clear if/else statements for
better readability and maintainability.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@yarikoptic yarikoptic merged commit 226e70c into master Feb 3, 2026
9 checks passed
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.

1 participant