kontena / k8s-client

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

excon malformed headers when doing resource update inside of watch #77

Closed matti closed 5 years ago

matti commented 5 years ago
  asia_resource.watch() do |asia_watch_event|
    resource = asia_watch_event.resource
    name = resource[:metadata][:name]
    who = resource[:spec][:who]

    resource[:spec][:greeting] = "Hello, #{who}"
    asia_resource.update_resource(resource)
  end

will

1: from /Users/mpa/.rvm/gems/ruby-2.6.0@operaattori/gems/excon-0.62.0/lib/excon/response.rb:89:in `parse'
/Users/mpa/.rvm/gems/ruby-2.6.0@operaattori/gems/excon-0.62.0/lib/excon/response.rb:186:in `parse_headers': malformed header (Excon::Error::ResponseParse) (Excon::Error::Socket) (Excon::Error::Socket)

while

  asia_resource.watch() do |asia_watch_event|
    resource = asia_watch_event.resource
    name = resource[:metadata][:name]
    who = resource[:spec][:who]

    resource[:spec][:greeting] = "Hello, #{who}"
    Thread.new do
      asia_resource.update_resource(resource)
    end
  end

works

kke commented 5 years ago

Anything relevant with EXCON_DEBUG=true?

matti commented 5 years ago

@kke sent debug output in slack

kke commented 5 years ago

The debug info does not contain the piece of header that actually caused the failure :(

          key, value = data.split(':', 2)
          raise Excon::Error::ResponseParse, 'malformed header' unless value

Would be interesting to know what the data looks like, empty values are not allowed in HTTP headers though.

kke commented 5 years ago

Though, likely the problem is in the k8s-client and not the server or excon anyway.

kke commented 5 years ago

I think it's trying to reuse the SSL socket for the update request while still reading the response for the watch stream.