Skip to content

Commit

Permalink
Remove runtime dependency on SCL (#3952)
Browse files Browse the repository at this point in the history
* Remove runtime dependency on SCL
Also remove references to SCL Apache
Fixes #3904

* Require runtime 4.0.2
  • Loading branch information
treydock authored Nov 14, 2024
1 parent 3ffd396 commit 829839d
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 154 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gem 'rake'
gem 'dotenv', '~> 2.1'

group :package do
gem 'ood_packaging', '~> 0.16.1'
gem 'ood_packaging', '~> 0.16.2'
end

group :test do
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ GEM
oga (3.3)
ast
ruby-ll (~> 2.1)
ood_packaging (0.16.1)
ood_packaging (0.16.2)
rake (~> 13.0.1)
open_uri_redirections (0.2.1)
parallel (1.21.0)
Expand Down Expand Up @@ -177,7 +177,7 @@ DEPENDENCIES
beaker-docker (~> 1.4.0)
beaker-rspec
dotenv (~> 2.1)
ood_packaging (~> 0.16.1)
ood_packaging (~> 0.16.2)
rake
rspec
rubocop
Expand Down
9 changes: 0 additions & 9 deletions lib/tasks/rake_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,6 @@ def os_release
end
end

def scl_apache?
return true if el? && os_release['VERSION_ID'] =~ /^7/

false
end

def el?
return true if "#{os_release['ID']} #{os_release['ID_LIKE']}" =~ /(rhel|fedora)/

Expand All @@ -279,8 +273,6 @@ def debian?
end

def apache_daemon
return '/opt/rh/httpd24/root/usr/sbin/httpd-scl-wrapper' if scl_apache?

"/usr/sbin/#{apache_service}"
end

Expand All @@ -298,7 +290,6 @@ def apache_user

def apache_service
return 'apache2' if debian?
return 'httpd24-httpd' if scl_apache?

'httpd'
end
Expand Down
18 changes: 3 additions & 15 deletions nginx_stage/etc/profile
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
# For Software Collections 2.0
# Read the environment from /opt/ood/ondemand/enable
#
# 1. Read in environment variable SCL_PKGS which may be set in `sudo` call
# otherwise fallback to default software collection packages.
#
# 2. Check if Software Collections is installed, then source the defined
# package scripts.
#
SCL_PKGS=${SCL_PKGS:-"ondemand"}
SCL_SOURCE="$(command -v scl_source)"
DEB_SOURCE="/opt/ood/ondemand/enable"
if [[ "${SCL_SOURCE}" ]]; then
source "${SCL_SOURCE}" enable ${SCL_PKGS}
else
[[ -e "${DEB_SOURCE}" ]] && source "${DEB_SOURCE}" || :
fi
OOD_SOURCE="/opt/ood/ondemand/enable"
[[ -e "${OOD_SOURCE}" ]] && source "${OOD_SOURCE}" || :
18 changes: 3 additions & 15 deletions ood-portal-generator/etc/profile
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
# For Software Collections 2.0
# Read the environment from /opt/ood/ondemand/enable
#
# 1. Read in environment variable SCL_PKGS which may be set in `sudo` call
# otherwise fallback to default software collection packages.
#
# 2. Check if Software Collections is installed, then source the defined
# package scripts.
#
SCL_PKGS=${SCL_PKGS:-"ondemand"}
SCL_SOURCE="$(command -v scl_source)"
DEB_SOURCE="/opt/ood/ondemand/enable"
if [[ "${SCL_SOURCE}" ]]; then
source "${SCL_SOURCE}" enable ${SCL_PKGS}
else
[[ -e "${DEB_SOURCE}" ]] && source "${DEB_SOURCE}" || :
fi
OOD_SOURCE="/opt/ood/ondemand/enable"
[[ -e "${OOD_SOURCE}" ]] && source "${OOD_SOURCE}" || :
10 changes: 0 additions & 10 deletions ood-portal-generator/lib/ood_portal_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ def os_release_file
path
end

def scl_apache?
return true if os_release_file.nil?
return false if debian?

env = Dotenv.parse(os_release_file)
return true if "#{env['ID']} #{env['ID_LIKE']}" =~ /(rhel|fedora)/ && env['VERSION_ID'] =~ /^7/

false
end

def debian?
return false if os_release_file.nil?

Expand Down
4 changes: 0 additions & 4 deletions ood-portal-generator/lib/ood_portal_generator/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ def apache

path = if OodPortalGenerator.debian?
'/etc/apache2/sites-available/ood-portal.conf'
elsif OodPortalGenerator.scl_apache?
'/opt/rh/httpd24/root/etc/httpd/conf.d/ood-portal.conf'
else
'/etc/httpd/conf.d/ood-portal.conf'
end
Expand All @@ -95,8 +93,6 @@ def apache_bak
def apache_services
if OodPortalGenerator.debian?
['apache2']
elsif OodPortalGenerator.scl_apache?
['httpd24-httpd']
else
['httpd']
end
Expand Down
29 changes: 6 additions & 23 deletions ood-portal-generator/spec/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -477,26 +477,17 @@ def test_generate(input, output)
end
end

it 'should use SCL apache' do
allow(OodPortalGenerator).to receive(:scl_apache?).and_return(true)
allow(OodPortalGenerator).to receive(:debian?).and_return(false)
expect(described_class.apache).to eq('/opt/rh/httpd24/root/etc/httpd/conf.d/ood-portal.conf')
end

it 'should not use SCL apache' do
allow(OodPortalGenerator).to receive(:scl_apache?).and_return(false)
it 'should use EL apache' do
allow(OodPortalGenerator).to receive(:debian?).and_return(false)
expect(described_class.apache).to eq('/etc/httpd/conf.d/ood-portal.conf')
end

it 'should work for Debian systems' do
allow(OodPortalGenerator).to receive(:scl_apache?).and_return(false)
allow(OodPortalGenerator).to receive(:debian?).and_return(true)
expect(described_class.apache).to eq('/etc/apache2/sites-available/ood-portal.conf')
end

it 'handles prefix from env' do
allow(OodPortalGenerator).to receive(:scl_apache?).and_return(false)
allow(OodPortalGenerator).to receive(:debian?).and_return(false)
with_modified_env PREFIX: '/foo' do
expect(described_class.apache).to eq('/foo/etc/httpd/conf.d/ood-portal.conf')
Expand All @@ -507,14 +498,13 @@ def test_generate(input, output)
describe 'save_checksum' do
before(:each) do
allow(File).to receive(:exist?).with('/dne.conf').and_return(true)
allow(OodPortalGenerator).to receive(:scl_apache?).and_return(true)
allow(OodPortalGenerator).to receive(:debian?).and_return(false)
end

it 'saves checksum file' do
allow(File).to receive(:readlines).with('/dne.conf').and_return(["# comment\n", "foo\n", " #comment\n"])
described_class.save_checksum('/dne.conf')
expect(File.read(sum_path.path)).to eq("b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c /opt/rh/httpd24/root/etc/httpd/conf.d/ood-portal.conf\n")
expect(File.read(sum_path.path)).to eq("b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c /etc/httpd/conf.d/ood-portal.conf\n")
end
end

Expand All @@ -525,7 +515,7 @@ def test_generate(input, output)
end

it 'matches' do
allow(File).to receive(:readlines).with(sum_path.path).and_return(["b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c /opt/rh/httpd24/root/etc/httpd/conf.d/ood-portal.conf\n"])
allow(File).to receive(:readlines).with(sum_path.path).and_return(["b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c /etc/httpd/conf.d/ood-portal.conf\n"])
allow(File).to receive(:readlines).with('/dne.conf').and_return(["# comment\n", "foo\n", " #comment\n"])
expect(described_class.checksum_matches?('/dne.conf')).to eq(true)
end
Expand All @@ -537,7 +527,7 @@ def test_generate(input, output)
end

it 'does not match' do
allow(File).to receive(:readlines).with(sum_path.path).and_return(["b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c /opt/rh/httpd24/root/etc/httpd/conf.d/ood-portal.conf\n"])
allow(File).to receive(:readlines).with(sum_path.path).and_return(["b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c /etc/httpd/conf.d/ood-portal.conf\n"])
allow(File).to receive(:readlines).with('/dne.conf').and_return(["# comment\n", "bar\n", " #comment\n"])
expect(described_class.checksum_matches?('/dne.conf')).to eq(false)
end
Expand All @@ -546,7 +536,7 @@ def test_generate(input, output)
describe 'checksum_exists?' do
it 'returns true' do
allow(File).to receive(:zero?).with(sum_path.path).and_return(false)
allow(File).to receive(:readlines).with(sum_path.path).and_return(["b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c /opt/rh/httpd24/root/etc/httpd/conf.d/ood-portal.conf\n"])
allow(File).to receive(:readlines).with(sum_path.path).and_return(["b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c /etc/httpd/conf.d/ood-portal.conf\n"])
expect(described_class.checksum_exists?).to eq(true)
end

Expand Down Expand Up @@ -602,19 +592,12 @@ def test_generate(input, output)
end

describe 'apache_changed_output' do
it 'SCL apache' do
allow(OodPortalGenerator).to receive(:debian?).and_return(false)
allow(OodPortalGenerator).to receive(:scl_apache?).and_return(true)
expect(described_class.apache_changed_output.join("\n")).to match(%r{httpd24-httpd.service})
end
it 'EL non-SCL apache' do
it 'EL apache' do
allow(OodPortalGenerator).to receive(:debian?).and_return(false)
allow(OodPortalGenerator).to receive(:scl_apache?).and_return(false)
expect(described_class.apache_changed_output.join("\n")).to match(%r{httpd.service})
end
it 'Debian apache' do
allow(OodPortalGenerator).to receive(:debian?).and_return(true)
allow(OodPortalGenerator).to receive(:scl_apache?).and_return(false)
expect(described_class.apache_changed_output.join("\n")).to match(%r{apache2.service$})
end
end
Expand Down
75 changes: 1 addition & 74 deletions ood-portal-generator/spec/ood_portal_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,79 +23,6 @@
end
end

describe 'scl_apache?' do
it 'returns true if /etc/os-release does not exist' do
allow(described_class).to receive(:os_release_file).and_return(nil)
expect(described_class.scl_apache?).to eq(true)
end

it 'returns true if RHEL7' do
os_release = <<~EOS
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="7.7"
EOS
File.write(os_release_file.path, os_release)
allow(described_class).to receive(:os_release_file).and_return(os_release_file.path)
expect(described_class.scl_apache?).to eq(true)
end

it 'returns true if CentOS7' do
os_release = <<~EOS
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
EOS
File.write(os_release_file.path, os_release)
allow(described_class).to receive(:os_release_file).and_return(os_release_file.path)
expect(described_class.scl_apache?).to eq(true)
end

it 'returns false if RHEL8' do
os_release = <<~EOS
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.0"
EOS
File.write(os_release_file.path, os_release)
allow(described_class).to receive(:os_release_file).and_return(os_release_file.path)
expect(described_class.scl_apache?).to eq(false)
end

it 'returns false if CentOS8' do
os_release = <<~EOS
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
EOS
File.write(os_release_file.path, os_release)
allow(described_class).to receive(:os_release_file).and_return(os_release_file.path)
expect(described_class.scl_apache?).to eq(false)
end

it 'returns false if RHEL9' do
os_release = <<~EOS
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="9.0"
EOS
File.write(os_release_file.path, os_release)
allow(described_class).to receive(:os_release_file).and_return(os_release_file.path)
expect(described_class.scl_apache?).to eq(false)
end

it 'returns false for Ubuntu 20.04' do
os_release = <<~EOS
ID=ubuntu
ID_LIKE=debian
VERSION_ID="20.04"
EOS
File.write(os_release_file.path, os_release)
allow(described_class).to receive(:os_release_file).and_return(os_release_file.path)
expect(described_class.scl_apache?).to eq(false)
end
end

describe 'debian?' do
it 'returns false if CentOS8' do
os_release = <<~EOS
Expand Down Expand Up @@ -134,4 +61,4 @@
expect(described_class.apache_group).to eq('www-data')
end
end
end
end
2 changes: 1 addition & 1 deletion packaging/rpm/ondemand.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
%define git_tag_minus_v %(echo %{git_tag} | sed -r 's/^v//')
%define major_version %(echo %{git_tag_minus_v} | cut -d. -f1)
%define minor_version %(echo %{git_tag_minus_v} | cut -d. -f2)
%define runtime_version %{major_version}.%{minor_version}.1
%define runtime_version %{major_version}.%{minor_version}.2
%define runtime_release 1
%define runtime_version_full %{runtime_version}-%{runtime_release}%{?dist}
%define selinux_policy_ver %(rpm --qf "%%{version}" -q selinux-policy)
Expand Down

0 comments on commit 829839d

Please sign in to comment.