From 20c95c4142c7a701653fd3acccc7d26ff1f1b9c5 Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Mon, 25 Sep 2023 16:19:16 +0000 Subject: [PATCH 1/3] Update CHANGELOG.md to reflect the promotion of 9.0.23 Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebd631071..225073e8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,16 @@ - -## [9.0.23](https://github.com/chef/omnibus/tree/9.0.23) (2023-09-22) - -#### Merged Pull Requests -- CHEF-5815: Update signing of all msi packages with new cli tool - `smctl` [#1128](https://github.com/chef/omnibus/pull/1128) ([ahasunos](https://github.com/ahasunos)) - -### Changes not yet released to rubygems.org + + + + +## [9.0.23](https://github.com/chef/omnibus/tree/9.0.23) (2023-09-25) #### Merged Pull Requests -- CHEF-5815: Update signing of all msi packages with new cli tool - `smctl` [#1128](https://github.com/chef/omnibus/pull/1128) ([ahasunos](https://github.com/ahasunos)) - +- CHEF-5815: Update signing of all msi packages with new cli tool - `smctl` [#1128](https://github.com/chef/omnibus/pull/1128) ([ahasunos](https://github.com/ahasunos)) + ## [9.0.22](https://github.com/chef/omnibus/tree/9.0.22) (2023-08-18) #### Merged Pull Requests @@ -21,7 +19,6 @@ - Fix Ruby 3.1 deprecation warning with ERB.new [#1108](https://github.com/chef/omnibus/pull/1108) ([stanhu](https://github.com/stanhu)) - Update gpg_name to fix RockyLinux rpm signing issue [#1118](https://github.com/chef/omnibus/pull/1118) ([poorndm](https://github.com/poorndm)) - Update metadata with rocky platform [#1125](https://github.com/chef/omnibus/pull/1125) ([poorndm](https://github.com/poorndm)) - ## [9.0.17](https://github.com/chef/omnibus/tree/9.0.17) (2023-02-20) From 82dae896a066542f1b66dc866186f856f37e518e Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Mon, 25 Sep 2023 16:20:31 +0000 Subject: [PATCH 2/3] Update CHANGELOG.md to reflect the promotion of 9.0.23 Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 225073e8c..8aa6dabed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,17 @@ - + +### Changes not yet released to rubygems.org +## [9.0.23](https://github.com/chef/omnibus/tree/9.0.23) (2023-09-25) + + ## [9.0.23](https://github.com/chef/omnibus/tree/9.0.23) (2023-09-25) #### Merged Pull Requests - CHEF-5815: Update signing of all msi packages with new cli tool - `smctl` [#1128](https://github.com/chef/omnibus/pull/1128) ([ahasunos](https://github.com/ahasunos)) - ## [9.0.22](https://github.com/chef/omnibus/tree/9.0.22) (2023-08-18) From feb28e316bd72b965375e1f9088f8048318ba4d1 Mon Sep 17 00:00:00 2001 From: Alan Foster Date: Thu, 4 Jun 2020 02:30:41 +0100 Subject: [PATCH 3/3] Update healthchecks to handle ldd failures Signed-off-by: adfoster-r7 --- lib/omnibus/health_check.rb | 38 +++++++++++++++++++----- spec/unit/health_check_spec.rb | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 7 deletions(-) diff --git a/lib/omnibus/health_check.rb b/lib/omnibus/health_check.rb index 282a66b25..8772036aa 100644 --- a/lib/omnibus/health_check.rb +++ b/lib/omnibus/health_check.rb @@ -511,16 +511,40 @@ def read_shared_libs(find_command, ldd_command, &output_proc) # feed the list of files to the "ldd" command # - # this command will typically fail if the last file isn't a valid lib/binary which happens often - ldd_output = shellout(ldd_command, input: find_output.join).stdout + # instance Mixlib::ShellOut + ldd_cmd = shellout(ldd_command, input: find_output.join) + + # Optimized path: Attempt to run the `ldd` command on all file paths. If it succeeds, then process + # the stdout result in bulk. If the command returned a non-zero exit status code, then something went wrong. + # Each path will have to be manually resolved + unless ldd_cmd.error? + # do the output process to determine if the files are good or bad + ldd_cmd.stdout.each_line do |line| + output_proc.call(line) + end + else + log.debug(log_key) { "Failed running #{ldd_command} with exit status #{ldd_cmd.exitstatus} when resolving individually" } - # - # do the output process to determine if the files are good or bad - # + # Verify each path separately + find_output.each do |path| + ldd_cmd = shellout(ldd_command, input: path) + if ldd_cmd.error? + log.debug(log_key) { "Failed running #{ldd_command} with exit status #{ldd_cmd.exitstatus} against: #{path}" } + end - ldd_output.each_line do |line| - output_proc.call(line) + ldd_output = ldd_cmd.stdout + + # Yield the path first + output_proc.call("#{path.rstrip}:") + + # do the output process to determine if the files are good or bad + ldd_output.each_line do |line| + output_proc.call(line) + end + end end + + nil end # diff --git a/spec/unit/health_check_spec.rb b/spec/unit/health_check_spec.rb index 9178d7798..398d2c973 100644 --- a/spec/unit/health_check_spec.rb +++ b/spec/unit/health_check_spec.rb @@ -103,15 +103,28 @@ def mkdump(base, size, x64 = false) let(:file_list) do double("Mixlib::Shellout", error!: false, + error?: false, stdout: <<~EOH /opt/chefdk/shouldnt/matter EOH ) end + let(:file_list_multiple) do + double("Mixlib::Shellout", + error!: false, + error?: false, + stdout: <<~EOH + /opt/chefdk/first + /opt/chefdk/second + EOH + ) + end + let(:empty_list) do double("Mixlib::Shellout", error!: false, + error?: false, stdout: <<~EOH EOH ) @@ -130,6 +143,7 @@ def mkdump(base, size, x64 = false) let(:bad_list) do double("Mixlib::Shellout", error!: false, + error?: false, stdout: <<~EOH /somewhere/other/than/install/dir EOH @@ -139,6 +153,7 @@ def mkdump(base, size, x64 = false) let(:bad_healthcheck) do double("Mixlib::Shellout", error!: false, + error?: false, stdout: <<~EOH /bin/ls: linux-vdso.so.1 => (0x00007fff583ff000) @@ -161,6 +176,7 @@ def mkdump(base, size, x64 = false) let(:good_healthcheck) do double("Mixlib::Shellout", error!: false, + error?: false, stdout: <<~EOH /bin/echo: linux-vdso.so.1 => (0x00007fff8a6ee000) @@ -174,6 +190,17 @@ def mkdump(base, size, x64 = false) ) end + let(:bad_exitstatus_healthcheck) do + double("Mixlib::Shellout", + error!: -> { raise Mixlib::ShellOut::ShellCommandFailed }, + error?: true, + exitstatus: 135, + stdout: <<~EOH + /bin/echo: + EOH + ) + end + it "raises an exception when there are external dependencies" do allow(subject).to receive(:shellout) .with("find /opt/chefdk/ -type f | xargs file | grep \"ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'") @@ -198,6 +225,33 @@ def mkdump(base, size, x64 = false) expect { subject.run! }.to_not raise_error end + it "does checks lld for each file if the initial bulk ldd command fails" do + allow(subject).to receive(:shellout) + .with("find /opt/chefdk/ -type f | xargs file | grep \"ELF\" | awk -F: '{print $1}' | sed -e 's/:$//'") + .and_return(file_list_multiple) + + # Bulk ldd command fails + allow(subject).to receive(:shellout) + .with("xargs ldd", { input: "/opt/chefdk/first\n/opt/chefdk/second\n" }) + .and_return(bad_exitstatus_healthcheck) + + # First file ldd fails + allow(subject).to receive(:shellout) + .with("xargs ldd", { input: "/opt/chefdk/first\n" }) + .and_return(bad_exitstatus_healthcheck) + + # Second file lld succeeds + allow(subject).to receive(:shellout) + .with("xargs ldd", { input: "/opt/chefdk/second\n" }) + .and_return(good_healthcheck) + + output = capture_logging do + expect { subject.run! }.to_not raise_error + end + expect(output).to match(/Failed running xargs ldd with exit status 135 when resolving individually/) + expect(output).to match(%r{Failed running xargs ldd with exit status 135 against: /opt/chefdk/first}) + end + it "will not perform dll base relocation checks" do expect(subject.relocation_checkable?).to be false end