Skip to content

Refactor HTTP requests to use centralized Invoke-HttpRequestWithRetry#529

Merged
jaredfholgate merged 3 commits intomainfrom
feature/invoke-http-request-with-retry
Mar 25, 2026
Merged

Refactor HTTP requests to use centralized Invoke-HttpRequestWithRetry#529
jaredfholgate merged 3 commits intomainfrom
feature/invoke-http-request-with-retry

Conversation

@jaredfholgate
Copy link
Copy Markdown
Member

Summary

Introduces a new Invoke-HttpRequestWithRetry cmdlet that centralizes HTTP retry logic for transient errors (408, 429, 500, 502, 503, 504) and refactors existing callers to use it.

Changes

  • New cmdlet: Invoke-HttpRequestWithRetry in Private/Shared — wraps Invoke-WebRequest with configurable retry count, interval, and transient status code handling
  • Refactored Invoke-GitHubApiRequest to delegate retry logic to the new shared cmdlet instead of implementing its own retry loop
  • Updated Test-NetworkConnectivity to use Invoke-HttpRequestWithRetry instead of calling Invoke-WebRequest directly
  • Updated Get-TerraformTool to use Invoke-HttpRequestWithRetry for HashiCorp API calls and file downloads
  • Updated unit tests to mock Invoke-HttpRequestWithRetry instead of Invoke-WebRequest

Benefits

  • Single place to maintain retry logic, reducing duplication
  • Consistent retry behavior across all HTTP calls in the module
  • Easier to test and extend retry behavior in the future

- Add new Invoke-HttpRequestWithRetry cmdlet with built-in retry logic for transient HTTP errors (408, 429, 500, 502, 503, 504)
- Refactor Invoke-GitHubApiRequest to delegate retry logic to the new shared cmdlet
- Update Test-NetworkConnectivity to use Invoke-HttpRequestWithRetry instead of Invoke-WebRequest
- Update Get-TerraformTool to use Invoke-HttpRequestWithRetry for HashiCorp API calls and downloads
- Update unit tests to mock the new cmdlet
- Rename github_max_retry_count to http_request_max_retry_count in Deploy-Accelerator (old name kept as alias)
- Add http_request_retry_interval_seconds and http_request_timeout_seconds params to Deploy-Accelerator
- Thread all three params through New-ModuleSetup, New-FolderStructure, Get-GithubRelease, Get-GithubReleaseTag, Get-HCLParserTool, Get-TerraformTool, Invoke-GitHubApiRequest
- Add Write-ToConsoleLog progress messages to all Test- check cmdlets
- Add HttpRequestMaxRetryCount, HttpRequestRetryIntervalSeconds, HttpRequestTimeoutSeconds params to Test-NetworkConnectivity and Test-Tooling
- Pass params from Deploy-Accelerator and Test-AcceleratorRequirement through Test-Tooling to Test-NetworkConnectivity
- Remove hardcoded MaxRetryCount 0 and TimeoutSec 10 from network connectivity checks
@jaredfholgate jaredfholgate merged commit 99dfb71 into main Mar 25, 2026
6 of 7 checks passed
@jaredfholgate jaredfholgate deleted the feature/invoke-http-request-with-retry branch March 25, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Triage 🔍 Needs triaging by the team

Projects

Development

Successfully merging this pull request may close these issues.

2 participants