Repository navigation
Conversation
First step towards replacing the copy-pasted HTTP request helpers with a single client for the VK to interLink API. This only adds the endpoint resolution and the constructor, together with their tests; nothing uses the client yet. The constructor validates the URL scheme up front and captures the HTTP client at construction time. Loopback hosts are allowed, since the interLink API commonly runs next to the VK. Signed-off-by: dciangot <dciangot@cern.ch>
✅ Deploy Preview for interlink-dev canceled.
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
With TLS enabled, a supplied log transport does not inherit the configured CA or client certificates, causing log requests to fail against private-CA or mTLS endpoints even when the regular client works.
1 open issue
What changed in this PR
Introduces InterlinkClient as the foundation for replacing duplicated HTTP request helpers in the Virtual Kubelet. No callers are migrated yet, so existing behavior remains unchanged.
Changes:
- Adds a constructor that initializes HTTP clients and retains configuration for future requests.
- Adds endpoint resolution for HTTP, HTTPS, and Unix sockets, accepting localhost and handling empty ports.
- Adds tests for endpoint resolution, constructor configuration, TLS errors, and log transport isolation.
| File | Description |
|---|---|
pkg/virtualkubelet/interlink_client.go |
Adds the client constructor and endpoint resolution. |
pkg/virtualkubelet/interlink_client_test.go |
Tests constructor behavior, endpoints, and transport isolation. |
Review effort: Balanced
|
|
||
| logHTTPClient := httpClient | ||
| if logTransport != nil { | ||
| transport := logTransport.Clone() |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Part of a refactor that replaces the six copy-pasted HTTP request functions in
pkg/virtualkubelet/execute.gowith oneInterlinkClient. The work ships as a stack of small PRs, in this order: introduce the client, migrate the callers one group at a time, then remove the old helpers. This is the first one.This PR adds
NewInterlinkClientand the endpoint resolution (pkg/virtualkubelet/interlink_client.go). It builds the TLS HTTP client once at construction time, and a separate client for log retrieval with keep-alives disabled because the log body is streamed.Nothing uses the client yet, so there is no change in behavior. The new code differs from the existing
getSidecarEndpointin three ways, which matter once callers move over in later PRs:log.Fatal;http://host:);http://localhost:3000are accepted, since the interLink API commonly runs next to the VK.Tested:
go build ./...andgo vet ./pkg/virtualkubelet/.go test -race ./pkg/virtualkubelet/, with new tests ininterlink_client_test.gofor the endpoint resolution (http, https, no port, unix socket, bad scheme, empty URL), localhost, TLS configuration errors, and the dedicated log transport (not shared with the input).Size: 170 changed lines in 2 files.
Next in the stack: request plumbing and
Ping.Related issue :