kontena / k8s-client

Ruby Kubernetes API client
Apache License 2.0
76 stars 26 forks source link

Fix path prefix handling in server address #158

Closed kke closed 5 years ago

kke commented 5 years ago

Fixes #157 See #110

rbq commented 5 years ago

Yay! I can verify that with this workaround it runs with Rancher!

I assume it breaks using a path (prefix) like /api/api though?

kke commented 5 years ago

Yep, that's why that check was left out originally. I still don't understand why it gets added twice, and I have not been able to reproduce the problem in the console.

kke commented 5 years ago

Included in 0.10.3 (https://rubygems.org/gems/k8s-client/versions/0.10.3)

rbq commented 5 years ago

Yeah, I tried to understand what's going on but quickly gave up. In K8s::Transport everything seemed fine; when sending a request it builds the path with prefix.

But for some reason K8s::APIClient also reaches into K8s::Transport, adding the prefix a second time?

def path(*path)
  @transport.path(self.class.path(@api_version), *path)
end

So I tried to change that to just:

def path(*path)
  File.join self.class.path(@api_version), *path
end

The result seemed to be one request with a correct URL (not sure what's going on there, discovering available APIs or something?)—immediately followed by an exception with a path that was now missing the prefix. 🤯

rbq commented 5 years ago

Anyway, thanks a lot! I'll now try building a little Sinatra app listing all the Ingresses deployed on our cluster. :)