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

Workaround libaugeas save/load issue #49

Merged
merged 1 commit into from
Apr 24, 2023
Merged

Workaround libaugeas save/load issue #49

merged 1 commit into from
Apr 24, 2023

Conversation

h-haaks
Copy link
Contributor

@h-haaks h-haaks commented Apr 22, 2023

Pull Request (PR) description

hercules-team/augeas#691 introduced a bug in libaugeas bundled with puppet 7.
The bug manifests it self in this modules augsave! method when invoked with reload=true.
A workaround is to invoke aug.load! twice after an aug.save!
See voxpupuli/puppet-augeasproviders_sysctl#65

@h-haaks
Copy link
Contributor Author

h-haaks commented Apr 22, 2023

Should resolve the test issues in voxpupuli/puppet-augeasproviders_sysctl#65

# https://github.com/hercules-team/augeas/commit/eb04250a05671b2d001444b72b8778328d209d75 introduced a bug in libaugeas.so.0.25.0
# bundled with puppet7.
# A temporary fix is to invoke load! twice.
aug.load! if reload && Puppet::Util::Package.versioncmp(Puppet.version, '7.0.0') >= 0
Copy link
Member

Choose a reason for hiding this comment

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

This depends on the Augeas version, not Puppet. So I'd prefer to use aug_version instead. So something like:

Suggested change
aug.load! if reload && Puppet::Util::Package.versioncmp(Puppet.version, '7.0.0') >= 0
aug.load! if reload && Puppet::Util::Package.versioncmp(aug_version, '1.13.0') >= 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I tried this but then my test broke ....
puts "Puppet version: #{Puppet.version}, Augeas version: #{aug_version}" says

Puppet version: 6.29.0, Augeas version: 1.12.0
Puppet version: 7.24.0, Augeas version: 1.12.0

Copy link
Member

Choose a reason for hiding this comment

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

Oh that's weird. On my Fedora with system Ruby:

$ pry
[1] pry(main)> require 'augeas'
=> true
[2] pry(main)> Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD) { |aug| aug.get('/augeas/version') }
=> "1.13.0"

On my EL8 AIO:

$ rpm -qv puppet-agent
puppet-agent-7.24.0-1.el8.x86_64
$ /opt/puppetlabs/puppet/bin/ruby 
require 'augeas'
puts Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD) { |aug| aug.get('/augeas/version') }

1.13.0

On a Debian 11 machine with puppet-agent-7.24.0-1bullseye:

# /opt/puppetlabs/puppet/bin/ruby
require 'augeas'
puts Augeas.open(nil, nil, Augeas::NO_MODL_AUTOLOAD) { |aug| aug.get('/augeas/version') }
1.13.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, unit tests does not use puppet agent, and on my rockylinux-8 vagrant box augeas-lib 1.12.0 is installed.
Should I just drop the unit test I added then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Figured out how to stub it :)

@ekohl
Copy link
Member

ekohl commented Apr 23, 2023

And it would also be good to verify if hercules-team/augeas#810 solves it.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Thanks!

@ekohl ekohl merged commit 401a167 into voxpupuli:master Apr 24, 2023
@h-haaks
Copy link
Contributor Author

h-haaks commented Apr 25, 2023

And it would also be good to verify if hercules-team/augeas#810 solves it.

Verified on

[root@localhost ~]# cat /etc/os-release 
NAME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"

[root@localhost vagrant]# ruby --version
ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-linux]
[root@localhost vagrant]# gem list augeas

*** LOCAL GEMS ***

ruby-augeas (0.5.0)

verification script

#!/usr/bin/env ruby

require 'augeas'
file = '/etc/sysctl.d/20-fs.conf'

aug = Augeas.open

def augset(aug, file, name, value)
  aug.set("/files/#{file}/#{name}", value) 
  aug.save!
  aug.load!
end

puts aug.get('/augeas/version')
augset(aug, file, 'fs.nr_open', '100001')
augset(aug, file, 'fs.inotify.max_user_watches', '8193')

aug.close

Test with manual build of the release-1.13.0 tag

[root@localhost vagrant]# rm -f /etc/sysctl.d/20-fs.conf
[root@localhost vagrant]# LD_LIBRARY_PATH=/usr/local/lib ~/broken_sysctl.rb 
1.13.0
[root@localhost vagrant]# cat /etc/sysctl.d/20-fs.conf
fs.inotify.max_user_watches = 8193

Test with manual build of fix_691_modified branch

[root@localhost vagrant]# rm -f /etc/sysctl.d/20-fs.conf
[root@localhost vagrant]# LD_LIBRARY_PATH=/usr/local/lib ~/broken_sysctl.rb 
1.14.0
[root@localhost vagrant]# cat /etc/sysctl.d/20-fs.conf
fs.nr_open = 100001
fs.inotify.max_user_watches = 8193

@h-haaks h-haaks deleted the Workaround-libaugeas-save/load-issue branch April 25, 2023 20:50
@h-haaks h-haaks mentioned this pull request Apr 25, 2023
@ekohl ekohl added the bug Something isn't working label Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants