Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watches with ruby 2.7 fails modifying a frozen string #442

Open
agrare opened this issue Apr 25, 2020 · 6 comments
Open

Watches with ruby 2.7 fails modifying a frozen string #442

agrare opened this issue Apr 25, 2020 · 6 comments

Comments

@agrare
Copy link
Member

agrare commented Apr 25, 2020

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

@agrare
Copy link
Member Author

agrare commented Apr 25, 2020

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

@cben
Copy link
Collaborator

cben commented Apr 26, 2020

Thanks! Reopening to decide if I can bump dependencies (maybe only in 5.0) to guarantee 2.7 compatibility...

@cben
Copy link
Collaborator

cben commented Jul 1, 2020

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 httprb/http#582 (comment), 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 ❗ so I think we can safely require http >= 4.0 http >= 4.3.0 now 😁

@agrare
Copy link
Member Author

agrare commented Jul 1, 2020

Thanks for following up @cben !

@cben
Copy link
Collaborator

cben commented Jul 1, 2020

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 🤔 🤷

@agrare
Copy link
Member Author

agrare commented Jul 1, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants