kubeclient
kubeclient copied to clipboard
Watches with ruby 2.7 fails modifying a frozen string
When using watches with ruby 2.7 fails when modifying a frozen string
[----] E, [2020-04-25T12:05:49.682245 #355472:325104] ERROR -- : [FrozenError]: can't modify frozen String: "" Method:[block (2 levels) in <class:LogProxy>]
[----] E, [2020-04-25T12:05:49.682542 #355472:325104] ERROR -- : ~/.gems/2.7.0/gems/http-3.3.0/lib/http/response/body.rb:31:in 'force_encoding'
~/.gems/2.7.0/gems/http-3.3.0/lib/http/response/body.rb:31:in 'readpartial'
~/.gems/2.7.0/gems/http-3.3.0/lib/http/response/body.rb:36:in 'each'
~/.gems/2.7.0/gems/kubeclient-4.3.0/lib/kubeclient/watch_stream.rb:25:in 'each'
While debugging this I found that here chunk
is ""
and is frozen. It is the result of here with chunk
being nil
and nil.to_s.frozen?
is true
This appears to have been fixed in http v4 which upgrading to kubeclient v4.5+ allows, we just happen to be stuck for now on 4.3.0.
Going to close this since this isn't an issue on the most recent version
Thanks! Reopening to decide if I can bump dependencies (maybe only in 5.0) to guarantee 2.7 compatibility...
I haven't managed to reproduce yet on http 3.3.0, but your analysis is right.
Ruby 2.7 pre-release experimented with a more radical change making Symbol#to_s return frozen strings but that broke too much and was reverted;
NilClass#to_s returning frozen was retained, with exactly this place in http
gem called out as resulting breakage – https://bugs.ruby-lang.org/issues/16150#note-61 — but people agreed http
code should be fixed instead.
http issue https://github.com/httprb/http/issues/582#issuecomment-572618580, fix released in http 4.3.0. I was thinking to support http 3.y until kubeclient 5.0 as I'm not sure forcing a major bump of other (possibly widely used) libraries in a minor release is "polite", but I see http 3.y https://github.com/httprb/http/tree/3-x-stable doesn't promise (and wasn't even tested) anything newer than Ruby 2.4 :exclamation: so I think we can safely require ~~http >= 4.0~~ http >= 4.3.0 now :grin:
Thanks for following up @cben !
hmm, 4.0 dropped ruby 2.2 support, which is again ancient EOL but now I feel worse about dropping it in kubeclient before 5.0 :thinking: :shrug:
It is up to you, but now that we (MIQ) have moved to kubeclient 4.6 and are able to use a newer http gem we are no longer blocked by this. Perfectly happy to wait until 5.0 for you to require a newer http gem version.