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

Drop Ruby 2.5 support #2674

Merged
merged 3 commits into from
Jan 31, 2024
Merged

Drop Ruby 2.5 support #2674

merged 3 commits into from
Jan 31, 2024

Conversation

mhashizume
Copy link
Contributor

This PR:

  • Raises Facter's minimum Ruby version from 2.5 to 2.6 in the gemspec.
  • Updates unit tests to use Ruby 2.6 as their minimum version.
  • Update Rubocop and related gems to the last version to support Ruby 2.6 and sets Ruby 2.6 as the TargetRubyVersion in rubocop.yml.
  • Addresses new Rubocop offenses from the above updates.

Ruby 2.5 hit end-of-life on 2021-04-05, nearly three years ago.
Additionally one of Facter's dependencies, Thor, dropped Ruby 2.5
support with Thor 1.3.0 in October 2023.

This commit sets Facter's minimum Ruby version to 2.6 and updates tests
and Rubocop configuration accordingly.
This commit addresses all offenses triggered by the Rubocop
Style/SlicingWithRange cop.
In Ruby 2.6 and greater, passing trim_mode as the third argument of
ERB.new is deprecated.

This commit updates all instances of ERB.new to instead use trim_mode as
a keyword argument.
@mhashizume mhashizume requested a review from a team as a code owner January 23, 2024 19:09
@joshcooper joshcooper merged commit 4080a39 into puppetlabs:main Jan 31, 2024
17 checks passed
@mhashizume mhashizume deleted the drop-ruby-25 branch February 14, 2024 23:05
@mhashizume mhashizume added the maintenance Maintenance chores are excluded from changelogs label Feb 14, 2024
@ekohl
Copy link
Contributor

ekohl commented Mar 6, 2024

I think this broke puppetserver 7:

  Mar 06 15:43:30 centos7-64-puppet7.example.com puppetserver[4297]: SyntaxError: /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/util/api_debugger.rb:37: syntax error, unexpected '{ arg'
  Mar 06 15:43:30 centos7-64-puppet7.example.com puppetserver[4297]: exclude << option[1..].to_sym
  Mar 06 15:43:30 centos7-64-puppet7.example.com puppetserver[4297]: ^

I also see it in our Ubuntu 20.04 test in the same place. https://github.com/theforeman/puppet-puppet/actions/runs/8174732159/job/22350223689?pr=908

@joshcooper
Copy link
Contributor

joshcooper commented Mar 6, 2024

@ekohl are you running puppetserver in a container? I don't see this issue using puppetserver 7 packages on Ubuntu 20.04. As can be seen below, puppetserver's jruby maintains compatibility with Ruby 2.6.8, which supports [1..] syntax

# dpkg -l puppetserver
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version       Architecture Description
+++-==============-=============-============-=================================
ii  puppetserver   7.16.0-1focal all          Puppet Labs puppetserver

# /opt/puppetlabs/server/bin/puppetserver gem install --no-document facter
Fetching thor-1.3.1.gem
Fetching facter-4.6.1.gem
Successfully installed thor-1.3.1
Successfully installed facter-4.6.1
2 gems installed
# /opt/puppetlabs/server/bin/puppetserver irb
irb(main):001:0> require 'facter'
=> true
irb(main):002:0> Facter.to_hash.count
=> 116
irb(main):003:0> arr = [1, 2, 3]
=> [1, 2, 3]
irb(main):004:0> arr[1..]
=> [2, 3]
...
irb(main):007:0> option = '-one'
=> "-one"
irb(main):008:0> option[1..]
=> "one"
irb(main):009:0> option[1..].to_sym
=> :one
irb(main):010:0> RUBY_VERSION
=> "2.6.8"
irb(main):011:0> Facter::VERSION
=> "4.6.1"
irb(main):012:0> JRUBY_VERSION
=> "9.3.9.0"

@ekohl
Copy link
Contributor

ekohl commented Mar 6, 2024

It is indeed a container, because it makes CI in GitHub Actions easier

@joshcooper
Copy link
Contributor

joshcooper commented Mar 6, 2024

You're installing latest puppet-agent:

  Setting up puppet-agent (7.29.1-1focal) ...

But installing a two+ year old puppetserver 7.6.0. That version vendors an older JRuby 9.2, hence the error:

root@diffuse-produce:~# dpkg -s puppetserver
Package: puppetserver
Status: install ok installed
Priority: optional
Section: utils
Installed-Size: 102908
Maintainer: Puppet Labs <info@puppetlabs.com>
Architecture: all
Version: 7.6.0-1focal
...
root@diffuse-produce:~# /opt/puppetlabs/server/bin/puppetserver --version
puppetserver version: 7.6.0
root@diffuse-produce:~# /opt/puppetlabs/server/bin/puppetserver irb
irb(main):001:0> RUBY_VERSION
=> "2.5.8"
irb(main):002:0> JRUBY_VERSION
=> "9.2.17.0"
irb(main):003:0> "one"[1..]
Traceback (most recent call last):
        7: from -e:1:in `<main>'
        6: from org/jruby/RubyKernel.java:1009:in `load'
        5: from /opt/puppetlabs/server/apps/puppetserver/puppet-server-release.jar!/META-INF/jruby.home/bin/irb:17:in `<main>'
        4: from org/jruby/RubyKernel.java:1189:in `catch'
        3: from org/jruby/RubyKernel.java:1189:in `catch'
        2: from org/jruby/RubyKernel.java:1442:in `loop'
        1: from org/jruby/RubyKernel.java:1048:in `eval'
SyntaxError ((irb):4: syntax error, unexpected '{ arg')
"one"[1..]

While we always aim to maintain compatibility within 7.x, the combination of latest agent and ancient puppetserver on the same host seems like a recipe for disaster.

@ekohl
Copy link
Contributor

ekohl commented Mar 6, 2024

Hmm, interesting. We historically had that test to verify upgrades. Maybe we should raise the base version a bit

mhashizume added a commit to mhashizume/facter that referenced this pull request Mar 6, 2024
This was referenced Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Maintenance chores are excluded from changelogs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants