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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/puppet/provider/augeasprovider/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ def self.augsave!(aug, reload = false)
raise Augeas::Error, 'Failed to save Augeas tree to file. See debug logs for details.'
ensure
aug.load! if reload
# 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(aug_version, '1.13.0') >= 0
end

# Define a method with a block passed to #augopen
Expand Down
20 changes: 20 additions & 0 deletions spec/unit/puppet/provider/augeasprovider/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,26 @@ class Test < provider_class
-> { provider.augsave!(aug) }.should raise_error Augeas::Error, %r{Failed to save Augeas tree}
end
end

describe 'with reload' do
it 'is expected to call #load! once with augeas < 1.13.0' do
provider.augopen(resource) do |aug|
allow(provider).to receive(:aug_version).twice.and_return '1.12.0' # rubocop:disable RSpec/SubjectStub
expect(aug).to receive(:load!).once
aug.set("/files#{thetarget}/dummy")
provider.augsave!(aug, true)
end
end

it 'is expected to call #load! twice with augeas >= 1.13.0' do
provider.augopen(resource) do |aug|
allow(provider).to receive(:aug_version).twice.and_return '1.13.0' # rubocop:disable RSpec/SubjectStub
expect(aug).to receive(:load!).twice
aug.set("/files#{thetarget}/dummy")
provider.augsave!(aug, true)
end
end
end
end

describe '#path_label' do
Expand Down