diff --git a/SOURCES/0001-FACT-3116-Ignore-EROFS-when-deleting-fact-cache.patch b/SOURCES/0001-FACT-3116-Ignore-EROFS-when-deleting-fact-cache.patch new file mode 100644 index 0000000..da74e1f --- /dev/null +++ b/SOURCES/0001-FACT-3116-Ignore-EROFS-when-deleting-fact-cache.patch @@ -0,0 +1,66 @@ +From 66f688f2b3ddc795a087c81746da57190675e624 Mon Sep 17 00:00:00 2001 +From: Takashi Kajinami +Date: Wed, 27 Apr 2022 15:33:16 +0900 +Subject: [PATCH] (FACT-3116) Ignore EROFS when deleting fact cache + +When fact cache is placed in read only file system, deleting a file +fails with EROFS instead of EACCES . +--- + lib/facter/framework/core/cache_manager.rb | 2 +- + spec/facter/cache_manager_spec.rb | 20 +++++++++++++++++++- + 2 files changed, 20 insertions(+), 2 deletions(-) + +diff --git a/lib/facter/framework/core/cache_manager.rb b/lib/facter/framework/core/cache_manager.rb +index 100a7656a..d93020264 100644 +--- a/lib/facter/framework/core/cache_manager.rb ++++ b/lib/facter/framework/core/cache_manager.rb +@@ -227,7 +227,7 @@ cache_format_version is incorrect!") + + begin + File.delete(cache_file_name) if File.readable?(cache_file_name) +- rescue Errno::EACCES => e ++ rescue Errno::EACCES, Errno::EROFS => e + @log.warn("Could not delete cache: #{e.message}") + end + end +diff --git a/spec/facter/cache_manager_spec.rb b/spec/facter/cache_manager_spec.rb +index 8b3194340..324964bd5 100644 +--- a/spec/facter/cache_manager_spec.rb ++++ b/spec/facter/cache_manager_spec.rb +@@ -132,7 +132,7 @@ describe Facter::CacheManager do + ) + end + +- context 'when file cannot be deleted' do ++ context 'when file cannot be deleted because of access denied' do + let(:cache_file) { File.join(cache_dir, 'ext_file.txt') } + + it 'logs warn if it cannot delete' do +@@ -149,6 +149,24 @@ describe Facter::CacheManager do + expect(logger).to have_received(:warn) + end + end ++ ++ context 'when file cannot be deleted because of read-only filesystem' do ++ let(:cache_file) { File.join(cache_dir, 'ext_file.txt') } ++ ++ it 'logs warn if it cannot delete' do ++ allow(fact_groups).to receive(:get_fact).with('ext_file.txt').and_return(external_fact) ++ allow(File).to receive(:readable?).with(cache_file_name).and_return(false) ++ allow(Facter::Util::FileHelper).to receive(:safe_read).with(cache_file) ++ .and_return(cached_external_fact) ++ allow(JSON).to receive(:parse).with(cached_external_fact).and_raise(JSON::ParserError) ++ allow(File).to receive(:readable?).with(cache_file).and_return(true) ++ allow(File).to receive(:mtime).with(File.join(cache_dir, 'ext_file.txt')).and_return(Time.now) ++ allow(File).to receive(:delete).with(cache_file).and_raise(Errno::EROFS) ++ ++ cache_manager.resolve_facts([searched_external_fact]) ++ expect(logger).to have_received(:warn) ++ end ++ end + end + + context 'with timer' do +-- +2.35.1 + diff --git a/SPECS/facter.spec b/SPECS/facter.spec index ced3f32..80cea6a 100644 --- a/SPECS/facter.spec +++ b/SPECS/facter.spec @@ -1,7 +1,7 @@ ## START: Set by rpmautospec ## (rpmautospec version 0.2.5) %define autorelease(e:s:pb:) %{?-p:0.}%{lua: - release_number = 2; + release_number = 3; base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); print(release_number + base_release_number - 1); }%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{?dist} @@ -18,7 +18,7 @@ Name: facter Version: 4.2.8 -Release: %autorelease +Release: %autorelease -s c7e3f55b6git %if 0%{?has_epoch} Epoch: 1 %endif @@ -29,6 +29,7 @@ URL: https://github.com/puppetlabs/facter Source0: https://downloads.puppetlabs.com/%{name}/%{name}-%{version}.gem Source1: https://downloads.puppetlabs.com/%{name}/%{name}-%{version}.gem.asc Source2: https://downloads.puppetlabs.com/puppet-gpg-signing-key-20250406.pub +Patch0001: 0001-FACT-3116-Ignore-EROFS-when-deleting-fact-cache.patch BuildRequires: gnupg2 BuildRequires: rubygems-devel @@ -111,6 +112,9 @@ GEM_HOME="%{buildroot}%{gem_dir}" %{buildroot}%{_bindir}/facter %doc %{gem_docdir} %changelog +* Mon May 16 2022 Joel Capitao 4.2.8-3.c7e3f55b6git +- Apply upstream patch to fix fact cache issue + * Tue Apr 26 2022 Alfredo Moralejo 4.2.8-2 - Fix epoch in requirement of doc subpackage