Skip to content

feat: add configurable HTTP client timeouts via config file#1887

Merged
piotrjanik merged 12 commits into
open-component-model:mainfrom
piotrjanik:feat/timeout-config
Apr 14, 2026
Merged

feat: add configurable HTTP client timeouts via config file#1887
piotrjanik merged 12 commits into
open-component-model:mainfrom
piotrjanik:feat/timeout-config

Conversation

@piotrjanik
Copy link
Copy Markdown
Contributor

What this PR does / why we need it

Adds a new http.config.ocm.software config type that allows users to configure HTTP client timeout settings for OCI registry and Docker daemon connections. This prevents requests from hanging indefinitely on slow or broken networks.

Supported timeout fields (all optional, Go duration strings like "30s", "5m"):

  • timeout — overall http.Client deadline
  • tcpDialTimeout — TCP connection establishment
  • tcpKeepAlive — TCP keep-alive probe interval
  • tlsHandshakeTimeout — TLS handshake
  • responseHeaderTimeout — waiting for response headers
  • idleConnTimeout — idle connection lifetime

Design:

  • Follows the regular OCI config pattern (like credentials config) — HTTPSettings is stored on the OCI context via GetHTTPSettings()/SetHTTPSettings(), not as a datacontext attribute.
  • Duration is a validated string type with TimeDuration() returning (*time.Duration, error) — nil means "not configured" (use default), distinct from zero ("explicitly disabled").
  • httpclient.NewTransport() clones http.DefaultTransport and selectively overrides only the configured timeouts.
  • Integration tests use Toxiproxy to verify timeout behavior against a real registry with injected latency.

Which issue(s) this PR fixes

Fixes: #1731

What this PR does / why we need it

Which issue(s) this PR is related to

@github-actions github-actions Bot added kind/feature new feature, enhancement, improvement, extension area/documentation Documentation related kind/dependency dependency update, etc. size/l Large labels Mar 30, 2026
@piotrjanik piotrjanik force-pushed the feat/timeout-config branch from 8599a48 to b8ce426 Compare March 31, 2026 08:28
@piotrjanik piotrjanik marked this pull request as ready for review March 31, 2026 08:52
@piotrjanik piotrjanik requested a review from a team as a code owner March 31, 2026 08:52
@piotrjanik piotrjanik force-pushed the feat/timeout-config branch 2 times, most recently from 0a0b33f to 3323822 Compare March 31, 2026 10:55
Copy link
Copy Markdown
Contributor

@Skarlso Skarlso left a comment

Choose a reason for hiding this comment

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

Largely okay, just spotted a few things here :)

Comment thread api/oci/internal/context.go Outdated
Comment thread api/oci/internal/context.go Outdated
Comment thread api/oci/extensions/repositories/ocireg/repository.go Outdated
Comment thread docs/reference/ocm_configfile.md
Comment thread api/oci/internal/httpsettings.go Outdated
Comment thread api/oci/internal/httpsettings.go Outdated
Comment thread api/utils/httpclient/transport.go Outdated
Comment thread api/oci/config/httpconfig.go
Comment thread api/oci/extensions/repositories/ocireg/timeout_integration_test.go Outdated
Comment thread api/oci/extensions/repositories/ocireg/timeout_integration_test.go Outdated
Comment thread api/oci/internal/httpsettings.go Outdated
Comment thread api/utils/httpclient/transport_test.go
@github-actions github-actions Bot added the component/github-actions Changes on GitHub Actions or within `.github/` directory label Apr 8, 2026
@piotrjanik piotrjanik force-pushed the feat/timeout-config branch from b4c1225 to eec9940 Compare April 8, 2026 15:17
Comment thread api/oci/internal/httpsettings.go Outdated
@piotrjanik piotrjanik force-pushed the feat/timeout-config branch from 5ce8494 to 6ab17a2 Compare April 9, 2026 22:08
Comment thread api/oci/config/httpconfig.go
Comment thread api/oci/extensions/repositories/ocireg/repository.go Outdated
Comment thread api/oci/internal/httpsettings.go Outdated
Comment thread api/oci/internal/httpsettings.go Outdated
Comment thread api/utils/httpclient/transport.go
Adds a new `http.config.ocm.software` config type that allows users to
configure HTTP client timeout settings for OCI registry and Docker daemon
connections. This prevents requests from hanging indefinitely on slow or
broken networks.

Supported timeout fields (all optional, Go duration strings like "30s", "5m"):
- timeout — overall http.Client deadline
- tcpDialTimeout — TCP connection establishment
- tcpKeepAlive — TCP keep-alive probe interval
- tlsHandshakeTimeout — TLS handshake
- responseHeaderTimeout — waiting for response headers
- idleConnTimeout — idle connection lifetime

Design:
- Follows the regular OCI config pattern (like credentials config) —
  HTTPSettings is stored on the OCI context via
  GetHTTPSettings()/SetHTTPSettings(), not as a datacontext attribute.
- Duration is a validated string type with TimeDuration() returning
  (*time.Duration, error) — nil means "not configured" (use default),
  distinct from zero ("explicitly disabled").
- httpclient.NewTransport() clones http.DefaultTransport and selectively
  overrides only the configured timeouts.
- Integration tests use Toxiproxy to verify timeout behavior against a
  real registry with injected latency.

Fixes: open-component-model#1731

Signed-off-by: Piotr Janik <piotr.janik@sap.com>

# Conflicts:
#	go.mod
#	go.sum
Signed-off-by: Piotr Janik <piotr.janik@sap.com>

# Conflicts:
#	go.mod
#	go.sum
Signed-off-by: Piotr Janik <piotr.janik@sap.com>
Signed-off-by: Piotr Janik <piotr.janik@sap.com>
Signed-off-by: Piotr Janik <piotr.janik@sap.com>
Signed-off-by: Piotr Janik <piotr.janik@sap.com>
Signed-off-by: Piotr Janik <piotr.janik@sap.com>
Signed-off-by: Piotr Janik <piotr.janik@sap.com>
@piotrjanik piotrjanik force-pushed the feat/timeout-config branch from 9e2fae1 to 5ef77a3 Compare April 13, 2026 15:27
Signed-off-by: Piotr Janik <piotr.janik@sap.com>
@piotrjanik piotrjanik force-pushed the feat/timeout-config branch from 5ef77a3 to 5e31965 Compare April 13, 2026 15:38
@piotrjanik piotrjanik enabled auto-merge (squash) April 14, 2026 08:34
@jakobmoellerdev
Copy link
Copy Markdown
Member

please go through and resolve conversations

@piotrjanik piotrjanik merged commit f35213c into open-component-model:main Apr 14, 2026
24 checks passed
@piotrjanik piotrjanik deleted the feat/timeout-config branch April 14, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Documentation related component/github-actions Changes on GitHub Actions or within `.github/` directory kind/dependency dependency update, etc. kind/feature new feature, enhancement, improvement, extension size/l Large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add timeout configuration flag to OCM CLI

6 participants