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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good but I wonder if we're going to run into this again for any other requests we make directly to the Kubernetes API server in the future. Do you think we could have a more general solution by adding a RoundTripper to the client in
k8sAPI.NewClient()
which prepends url path prefix to request paths?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That already works correctly. This specific instance doesn’t work because we’re building the URL specific to tap requests and replacing the already constructed one by
NewClient()
wholesale here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, you're right! thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pietervogelaar
I figured out the cause for the error, and it is not unique to rancher.
According to the
url.Join
docs:This is relevant because the path for the kubernetes API uses two slashes in a row when an item is "namespaced".
Here are examples of the commands that are executed and the k8s API URLs that are generated when
url.Path = path.Join(url.Path, protohttp.TapReqToURL(req))
is replaced withurl.Path = fmt.Sprintf("%s%s",url.Path, protohttp.TapReqToURL(req))
:command:
bin/go-run cli tap -n linkerd deploy/linkerd-controller --verbose
URL:
https://<rancher-url>/k8s/clusters/c-66q2l/apis/tap.linkerd.io/v1alpha1/watch/namespaces/linkerd/deployments/linkerd-controller/tap
command:
bin/go-run cli tap -n linkerd deploy --verbose
URL:
https://<rancher-url>/k8s/clusters/c-66q2l/apis/tap.linkerd.io/v1alpha1/watch/namespaces/linkerd/deployments//tap
Notice the consecutive slashes
//
betweendeployments
andtap
I get the same results when running against a single node
kind
cluster on my local machine.To summarize, the gotcha here is that
join.Path
callsjoin.Clean
which results in consecutive slashes//
being cleaned to/