-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add check that /var/lib/pgsql and /var/lib/pgsql/data is on the same dev
- Loading branch information
Showing
8 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module Checks | ||
module Disk | ||
class PostgresqlMountpoint < ForemanMaintain::Check | ||
metadata do | ||
label :postgresql_mountpoint | ||
description 'Check to make sure PostgreSQL data is not on an own mountpoint' | ||
confine do | ||
feature(:instance).postgresql_local? && ForemanMaintain.el? | ||
end | ||
end | ||
|
||
def run | ||
assert(psql_dir_device == psql_data_dir_device, warning_message) | ||
end | ||
|
||
def psql_dir_device | ||
device = ForemanMaintain::Utils::Disk::Device.new('/var/lib/pgsql') | ||
device.name | ||
end | ||
|
||
def psql_data_dir_device | ||
device = ForemanMaintain::Utils::Disk::Device.new('/var/lib/pgsql/data') | ||
device.name | ||
end | ||
|
||
def warning_message | ||
<<~MSG | ||
PostgreSQL data (/var/lib/pgsql/data) is on a different device than /var/lib/pgsql. | ||
This is not supported and breaks PostgreSQL upgrades. | ||
Please ensure PostgreSQL data is on the same mountpoint as the /var/lib/pgsql. | ||
MSG | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
test/definitions/checks/disk/postgresql_mountpoint_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'test_helper' | ||
describe Checks::Disk::PostgresqlMountpoint do | ||
include DefinitionsTestHelper | ||
include UnitTestHelper | ||
|
||
let(:check) { described_class.new } | ||
|
||
before do | ||
assume_feature_present(:instance) do |feature| | ||
feature.any_instance.stubs(:postgresql_local?).returns(true) | ||
end | ||
ForemanMaintain.stubs(:el?).returns(true) | ||
end | ||
|
||
it 'executes successfully for data on same disks' do | ||
check.stubs(:psql_dir_device).returns('/dev/mapper/foreman-postgresql') | ||
check.stubs(:psql_data_dir_device).returns('/dev/mapper/foreman-postgresql') | ||
|
||
step = run_step(check) | ||
assert_empty(step.output) | ||
assert_equal(:success, step.status) | ||
end | ||
|
||
it 'prints warnings for data on separate disk' do | ||
check.stubs(:psql_dir_device).returns('/dev/mapper/foreman-root') | ||
check.stubs(:psql_data_dir_device).returns('/dev/mapper/foreman-postgresql') | ||
|
||
step = run_step(check) | ||
|
||
warning = <<~MSG | ||
PostgreSQL data (/var/lib/pgsql/data) is on a different device than /var/lib/pgsql. | ||
This is not supported and breaks PostgreSQL upgrades. | ||
Please ensure PostgreSQL data is on the same mountpoint as the /var/lib/pgsql. | ||
MSG | ||
assert_equal(warning, step.output) | ||
assert_equal(:fail, step.status) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters