GitLab upgraded to 13.8.1-ee.0 - changelog: https://gitlab.com/gitlab-org/gitlab/blob/master/CHANGELOG-EE.md

Commit a2c50932 authored by Ryan Frantz's avatar Ryan Frantz Committed by Tim Smith

Modifies systemd? behavior. (#175)

* Modifies systemd? behavior.

- Checks for the presence and executable-ness of 'systemctl', similar to the pattern used for other supervisors.
- This also help support cases where chef-sugar is used on containers (i.e. for unit testing) where /proc/1/comm will not be 'systemd' but the name of the process running in the container (i.e. 'bash' or 'ssh').
Signed-off-by: default avatarRyan Frantz <ryanleefrantz@gmail.com>

* Bumps version and upadtes CHANGELOG
Signed-off-by: default avatarRyan Frantz <ryanleefrantz@gmail.com>

* Update to use File::exist?

- This should properly cover all Linux distros like RHEL, Ubuntu, and SLES because they have, at a minimum, a symlink at /bin/systemctl.
- NOTE: All distros except Ubuntu have /usr/bin/systemctl. Weird, eh?
parent 47114797
......@@ -2,6 +2,11 @@
This file is used to list changes made in each version of the chef-sugar cookbook and gem.
## v5.0.1 (2019-03-13)
- Modifies the behavior of `systemd?` so that it works equally well on physical/virtual
machines as well as within containers.
## v5.0.0 (2018-12-26)
- BREAKING CHANGE: Require Chef 13 or later
......
......@@ -25,8 +25,7 @@ class Chef
# @return [Boolean]
#
def systemd?(node)
file = '/proc/1/comm'
File.exist?(file) && IO.read(file).chomp == 'systemd'
File.exist?('/bin/systemctl')
end
#
......
......@@ -16,6 +16,6 @@
class Chef
module Sugar
VERSION = '5.0.0'
VERSION = '5.0.1'
end
end
......@@ -16,23 +16,19 @@ describe Chef::Sugar::Init do
end
describe '#systemd?' do
it 'is true when /proc/1/comm is systemd' do
allow(IO).to receive(:read)
.with("/proc/1/comm")
.and_return("systemd")
systemctl_path = '/bin/systemctl'
it "is true when #{systemctl_path} exists" do
allow(File).to receive(:exist?)
.with(systemctl_path)
.and_return(true)
node = {}
expect(described_class.systemd?(node)).to be true
end
it 'is false when /proc/1/comm is not systemd' do
node = {}
expect(described_class.systemd?(node)).to be false
end
it 'is false when /proc/1/comm does not exist' do
it "is false when #{systemctl_path} does not exist" do
allow(File).to receive(:exist?)
.with("/proc/1/comm")
.with(systemctl_path)
.and_return(false)
node = {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment