You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add timeout flag to CLI commands for improved resilience (#194)
This pull request implements robust, configurable network retry logic
for the Envault CLI, improving resilience to transient API/network
failures. It introduces a unified `--timeout` flag (and
`ENVAULT_RETRY_MAX_DURATION` env var) for `pull` and `run` commands,
which controls the maximum duration for retrying failed API requests.
The retry logic uses exponential backoff with jitter and is thoroughly
tested for various scenarios.
**Network Resilience & Retry Logic:**
* Adds exponential backoff with jitter for retrying transient network
and server (5xx) errors in the API client, up to a configurable maximum
duration (`ENVAULT_RETRY_MAX_DURATION`, default 5 minutes).
* Refactors API client to respect context cancellation and to avoid
retrying on 4xx errors (except for 401, which triggers a token refresh).
**CLI Command Improvements:**
* Adds a `--timeout` flag to both `pull` and `run` commands, allowing
users to override the maximum retry duration from the command line.
* Both commands now use a unified timeout resolver, defaulting to 5
minutes if not set by flag or env var.
**Testing & Documentation:**
* Adds comprehensive tests for retry logic, including network errors,
5xx/4xx handling, token refresh, and timeout configuration.
* Updates CLI documentation for `pull` and `run` commands, and adds a
new section on network resilience and timeouts.
---
Co-authored-by: Rajat Patra <113469515+RawJat@users.noreply.github.com>
returnnil, &APIError{StatusCode: resp.StatusCode, Body: "Server returned HTML instead of expected JSON API response. Ensure the API server is running."}
returnnil, &APIError{StatusCode: resp.StatusCode, Body: "Server returned HTML instead of expected JSON API response. Ensure the API server is running."}
0 commit comments