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

Fix platform_version detection on Fedora rawhide #1396

Merged
merged 2 commits into from
Aug 8, 2019
Merged

Fix platform_version detection on Fedora rawhide #1396

merged 2 commits into from
Aug 8, 2019

Conversation

ritzk
Copy link

@ritzk ritzk commented Aug 7, 2019

package resource fails on rawhide. The updated regex - https://rubular.com/r/3JaKsAeOMLbszj , to only return the version string.

Description

package resource fails on fedora rawhide with the below message.

ArgumentError
-------------
Malformed version number string 31 (rawhide)

Cookbook Trace:
---------------
  /var/chef/cache/XXX/recipes/main.rb:37:in `from_file'

Relevant File Content:
----------------------
/var/chef/cache/XXX/main.rb:

 36:  if node.linux?
 37>>   package 'dmidecode' do
 38:      action :nothing
 39:    end.run_action(:install)
 40:  end

System Info:
------------
chef_version=14.10.9
platform=fedora
platform_version=31 (rawhide)   <-- this bit is trouble

the section which fails

$ vi .chef/lib/chef/node_map.rb
269     def filters_match?(node, filters)
270       matches_black_white_list?(node, filters, :os) &&
271         matches_black_white_list?(node, filters, :platform_family) &&
272         matches_black_white_list?(node, filters, :platform) &&
273         matches_version_list?(node, filters, :platform_version) && <-- This breaks
274         matches_target_mode?(filters)
275     end

The stacktrace

chef (14.10.9)> recipe_mode
chef:recipe (14.10.9)> package 'dmidecode' do
chef:recipe > action :nothing
chef:recipe ?> end.run_action(:install)
Traceback (most recent call last):
       16: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/resource_resolver.rb:33:in `resolve'
       15: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/resource_resolver.rb:80:in `resolve'
       14: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/resource_resolver.rb:147:in `prioritized_handlers'
       13: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/resource_resolver.rb:142:in `enabled_handlers'
       12: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/resource_resolver.rb:138:in `potential_handlers'
       11: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/node_map.rb:161:in `list'
       10: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/node_map.rb:161:in `select'
        9: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/node_map.rb:162:in `block in list'
        8: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/node_map.rb:286:in `node_matches?'
        7: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/node_map.rb:276:in `filters_match?'
        6: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/node_map.rb:267:in `matches_version_list?'
        5: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/node_map.rb:267:in `any?'
        4: from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.10.9/lib/chef/node_map.rb:268:in `block in matches_version_list?'
        3: from /opt/chef/embedded/lib/ruby/2.5.0/rubygems/version.rb:199:in `new'
        2: from /opt/chef/embedded/lib/ruby/2.5.0/rubygems/version.rb:199:in `new'
        1: from /opt/chef/embedded/lib/ruby/2.5.0/rubygems/version.rb:208:in `initialize'
ArgumentError (Malformed version number string 31 (rawhide))

Related Issue

Similar one - #1218

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

@@ -53,7 +53,7 @@ def get_redhatish_platform(contents)
# @returns [String] the version string
#
def get_redhatish_version(contents)
contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/(release)? ([\d\.]+)/, 2]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a spec here so we make sure we don't regress this later on. Also it's really useful to add a https://rubular.com/ permalink to the comments that shows the various things the regex is trying to match. That way anyone trying to adjust this regex later on can easily test the matches. We try to add those any time we touch a regex now.

@tas50 tas50 changed the title fix platform_version on rawhide Fix platform_version detection on Fedora rawhide Aug 7, 2019
- lib/ohai/provides_map.rb:34:1: C: Layout/EmptyLines: Extra blank line detected.
- lib/ohai/system.rb:136:1: C: Layout/EmptyLines: Extra blank line detected.

Signed-off-by: Ritesh Khadgaray <ritz@fb.com>
# CentOS release 5.8 (Final)
# CentOS release 6.7 (Final)
# Red Hat Enterprise Linux Server release 7.5 (Maipo)
#
# Red Hat Enterprise Linux release 8.0 (Ootpa)
Copy link
Contributor

@tas50 tas50 Aug 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace all these examples with this:

# See https://rubular.com/r/78c1yXYa7zDhdV for example matches

  - do not capture "rawide" string in platform_version

Signed-off-by: Ritesh Khadgaray <ritz@fb.com>
@tas50 tas50 merged commit 99f5400 into chef:master Aug 8, 2019
@tas50
Copy link
Contributor

tas50 commented Aug 8, 2019

@ritzk I just realized that you're running Chef 14. In Chef 15 the whole platform detection logic was reworked to just use /etc/os-release. This method won't actually be used on Fedora anymore. The fix is still solid, but upgrade Chef/Ohai and you'll be good to go.

@lock
Copy link

lock bot commented Oct 7, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants