Patching resolv.rb to load conditionally #1883
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We fixed a bug regarding Windows fqdn resolution in Ohai on the 17-stable branch. That Ohai update requires the Resolv class. The 'resolv' class unconditionally loads the Win32::Registry class as a dependency. Chef Infra already loads Win32::Registry and has a monkeypatch for the export_string method. When the Resolv class loads again in Ohai, it overwrites the monkeypatch and that
leads to registry encoding/decoding errors - Base Ruby classes return text encoded in UTF-16LE format and we need UTF-8.
Here we patch the Ruby Win32/Resolv.rb file to make reloading the Win32::Registry class conditional and therefore prevent the monkeypatch from being overwritten.
Related Issue
Types of changes
Checklist:
Gemfile.lock
has changed, I have used--conservative
to do it and included the full output in the Description above.