Skip to content

Enforce 5s timeout on all HTTP clients in kubelet-to-gcm#1196

Merged
courageJ merged 1 commit into
GoogleCloudPlatform:masterfrom
courageJ:feature/enforce-http-timeouts
May 20, 2026
Merged

Enforce 5s timeout on all HTTP clients in kubelet-to-gcm#1196
courageJ merged 1 commit into
GoogleCloudPlatform:masterfrom
courageJ:feature/enforce-http-timeouts

Conversation

@courageJ
Copy link
Copy Markdown
Contributor

PR Description: Enforce HTTP Client Timeouts in kubelet-to-gcm

Summary

Enforces a 5-second timeout on http.Client instances in kubelet-to-gcm to ensure requests finish within a predictable window and prevent potential goroutine build-up during slow backend responses.

Context

Currently, the http.Client defaults to an unbounded wait. This change adds a 5-second timeout to ensure that monitoring iterations remain isolated and do not accumulate if the Kubelet or GCE Metadata server is slow to respond.

Changes

  • monitor/config/initialize.go: Added Timeout: 5 * time.Second to the http.Client used for GCE metadata retrieval.
  • monitor/kubelet/source.go:
    • Added Timeout: 5 * time.Second to standard and secured Kubelet HTTP clients.
    • Added missing time package import.
  • monitor/controller/source.go:
    • Added Timeout: 5 * time.Second to the Controller HTTP client.
    • Added missing time package import.

Verification

  • Verified that all components compile successfully.
  • Ran go test ./monitor/kubelet/... and confirmed that existing translation logic remains sound.
  • All requests are now guaranteed to fail-fast within 5 seconds, which is safely below the 10-second polling interval.

@courageJ courageJ requested a review from JeffLuoo May 20, 2026 18:07
@courageJ courageJ merged commit fe8f334 into GoogleCloudPlatform:master May 20, 2026
18 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.

2 participants