Skip to content

Commit

Permalink
Add ipv6 disable check
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed May 14, 2024
1 parent 258aac2 commit a6396ac
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 0 deletions.
23 changes: 23 additions & 0 deletions definitions/checks/check_ipv6_disable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Checks::CheckIpv6Disable < ForemanMaintain::Check
metadata do
label :check_ipv6_disable
description 'Check if ipv6.disable=1 is set at kernel level'
end

def run
cmdline_file = File.read('/proc/cmdline')

assert(!cmdline_file.include?("ipv6.disable=1"), error_message)
end

def error_message
base = "\nThe kernel contains ipv6.disable=1 which is known to break installation and upgrade"\
", remove and reboot before continuining."

if feature(:instance).downstream
base += " See https://access.redhat.com/solutions/5045841 for more details."
end

base
end
end
1 change: 1 addition & 0 deletions definitions/scenarios/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def compose
Checks::SystemRegistration,
Checks::CheckHotfixInstalled,
Checks::CheckTmout,
Checks::CheckIpv6Disable,
Checks::CheckUpstreamRepository,
Checks::Disk::AvailableSpace,
Checks::Disk::AvailableSpaceCandlepin, # if candlepin
Expand Down
1 change: 1 addition & 0 deletions definitions/scenarios/upgrade_to_capsule_6_16.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PreUpgradeCheck < Abstract
def compose
add_steps(find_checks(:default))
add_steps(find_checks(:pre_upgrade))
add_step(Checks::CheckIpv6Disable)
add_step(Checks::Disk::AvailableSpacePostgresql13)
add_step(Checks::Repositories::Validate.new(:version => '6.16'))
end
Expand Down
1 change: 1 addition & 0 deletions definitions/scenarios/upgrade_to_capsule_6_16_z.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PreUpgradeCheck < Abstract
def compose
add_steps(find_checks(:default))
add_steps(find_checks(:pre_upgrade))
add_step(Checks::CheckIpv6Disable)
add_step(Checks::Repositories::Validate.new(:version => '6.16'))
end
end
Expand Down
1 change: 1 addition & 0 deletions definitions/scenarios/upgrade_to_satellite_6_16.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PreUpgradeCheck < Abstract
def compose
add_steps(find_checks(:default))
add_steps(find_checks(:pre_upgrade))
add_step(Checks::CheckIpv6Disable)
add_step(Checks::Disk::AvailableSpacePostgresql13)
add_step(Checks::Repositories::Validate.new(:version => '6.16'))
add_step(Checks::CheckOrganizationContentAccessMode)
Expand Down
1 change: 1 addition & 0 deletions definitions/scenarios/upgrade_to_satellite_6_16_z.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PreUpgradeCheck < Abstract
def compose
add_steps(find_checks(:default))
add_steps(find_checks(:pre_upgrade))
add_step(Checks::CheckIpv6Disable)
add_step(Checks::Repositories::Validate.new(:version => '6.16'))
end
end
Expand Down
21 changes: 21 additions & 0 deletions test/definitions/checks/check_ipv6_disable_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'test_helper'

describe Checks::CheckIpv6Disable do
include DefinitionsTestHelper

subject { Checks::CheckIpv6Disable.new }

it 'throws an error message when ipv6.disable=1 is set' do
File.expects(:read).with('/proc/cmdline').returns('ipv6.disable=1')
result = run_step(subject)

assert result.fail?
end

it 'success when ipv6.disable=1 is not set' do
File.expects(:read).with('/proc/cmdline').returns('test.net=0')
result = run_step(subject)

assert result.success?
end
end

0 comments on commit a6396ac

Please sign in to comment.