Skip to content

Add timeout and retry/backoff to Cloudsmith API requests#33

Draft
Copilot wants to merge 37 commits intomainfrom
copilot/sub-pr-15-db658bd8-ce69-4266-ae07-95650327de10
Draft

Add timeout and retry/backoff to Cloudsmith API requests#33
Copilot wants to merge 37 commits intomainfrom
copilot/sub-pr-15-db658bd8-ce69-4266-ae07-95650327de10

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

requests.get and requests.put in exemptions/update_policy.py had no timeout, allowing CI to hang indefinitely if the Cloudsmith API stalled.

Changes

  • Explicit timeoutREQUEST_TIMEOUT = 30 s applied to both GET and PUT calls
  • Retry with backoffurllib3.util.retry.Retry + HTTPAdapter retries up to 3×on 5xx and connection errors with 0.5 s/1 s/2 s exponential backoff; no new dependencies (bundled with requests)
  • Single shared session_session built once at module level, avoiding adapter recreation per request
  • HTTPS-only adapter mount — HTTP mount omitted so the ****** cannot be sent in cleartext
_retry_strategy = Retry(
    total=3,
    backoff_factor=0.5,
    status_forcelist=[500, 502, 503, 504],
    allowed_methods=["GET", "PUT"],
)

def _build_session() -> requests.Session:
    session = requests.Session()
    adapter = HTTPAdapter(max_retries=_retry_strategy)
    session.mount("https://", adapter)  # HTTPS only — no plaintext token leakage
    return session

_session = _build_session()

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

ciaracarey and others added 30 commits February 18, 2026 21:49
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Initial plan

* fix(readme): wrap repository structure in fenced code block

Co-authored-by: ciaracarey <84123925+ciaracarey@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ciaracarey <84123925+ciaracarey@users.noreply.github.com>
* Initial plan

* Fix spelling: "Specialised" -> "Specialized" in README.md

Co-authored-by: ciaracarey <84123925+ciaracarey@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ciaracarey <84123925+ciaracarey@users.noreply.github.com>
* Initial plan

* Remove import rego.v1 from advanced/huggingface-recipes policies

Co-authored-by: ciaracarey <84123925+ciaracarey@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ciaracarey <84123925+ciaracarey@users.noreply.github.com>
Added section on GitOps workflow for managing policy exemptions.
chore: tidy rego based on regal output
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
markmcmurray and others added 6 commits March 11, 2026 11:34
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: ciaracarey <84123925+ciaracarey@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback on Epm baseline refactor PR Add timeout and retry/backoff to Cloudsmith API requests Mar 11, 2026
@ciaracarey ciaracarey force-pushed the epm-baseline-refactor branch from 3185b50 to aa38feb Compare March 12, 2026 13:35
Base automatically changed from epm-baseline-refactor to main March 12, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants