Add 'Host' header to fix the watcher#249
Add 'Host' header to fix the watcher#249mindfulmonk wants to merge 2 commits intoManageIQ:masterfrom
Conversation
400 Bad Request: missing required Host header .gem/ruby/2.4.1/gems/kubeclient-2.4.0/lib/kubeclient/watch_stream.rb:27:in `each': Bad Request (Kubeclient::HttpError)
|
@cben @moolitayer please review/approve. |
|
@mindfulmonk can you squash the PR in a single commit? Thanks. |
|
@mindfulmonk have you also seen this problem with create/get/update/delete, or only watch? I'm not able to reproduce the underlying problem this PR seems to address: Same with I'll try to reproduce by actually using kubeclient later. |
|
I have seen this issue only with watch, for example this works fine:
I have used the fqdn and tested the API with a curl first to ensure it works. When debugging I've put this into /lib/kubeclient/watch_stream.rb
|
|
According to
https://github.com/httprb/http/blob/256539edd9ad8acf0f8a424114ac9fae6fb44782/lib/http/request.rb#L199-L202
http gem also always set a host header (and if we want to set it ourselves
we maybe should include non-default port as that code does?)
Could you repeat the experiment with logging, before and after your patch
(or at least before, I mostly want to understand why it didn't work)?
Add to Gemfile:
gem "httplog", require: false
and bundle install
Then *after* requiring kubeclient do:
require 'httplog'
HttpLog.configure { |config| config.log_headers = true }
then do the watch...
|
|
Code used: Result without the fix: Result with the fix |
|
Sorry, missed your reply and forgot about this. The message seems to come from Go's http lib: https://tools.ietf.org/html/rfc7230#section-5.4 says client SHOULD put Host first — isn't a MUST. |
|
I ran into this same exact issue today - when using the fluent-plugin-kubernetes_metadata_filter plugin Fluentd was crashing as a result of trying to setup the watch with the error about the missing host header. I confirmed this patch resolves the issue. |
|
Thanks. I'm still reluctant to put in a "magic" fix if I can't explain what's the problem and how it helps... Trying to investigate more... Staring at @JCotton1123 did see this with a numeric IP, or with a domain name? But maybe I should just put something like this in. Please do nag me if I keep this unanswered 😄
|
|
We're utilizing hostnames. K8s version 1.13. @cben |
Hi, I have been debugging an issue with fluent-plugins-nursery/fluent-plugin-kubernetes_metadata_filter#50
I've managed to replicate it with this:
I'm not sure if this is the best way to resolve this, but it works.
Here is the error message I was getting before: