Skip to content

Commit

Permalink
improve available_space check
Browse files Browse the repository at this point in the history
  • Loading branch information
pafernanr committed Aug 30, 2024
1 parent 55bf8b0 commit d0a3563
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions definitions/checks/disk/available_space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ module Disk
class AvailableSpace < ForemanMaintain::Check
metadata do
label :available_space
description 'Check to make sure root(/) partition has enough space'
description 'Check if /var/cache partition has enough space for dnf transaction:'
tags :pre_upgrade
end

MIN_SPACE_IN_MB = 4096

def run
assert(enough_space?, "System has less than #{MIN_SPACE_IN_MB / 1024}GB space available"\
' on root(/) partition')
' on /var/cache partition')
end

def enough_space?
io_obj = ForemanMaintain::Utils::Disk::IODevice.new('/')
device = ForemanMaintain::Utils::Disk::Device.new('/var/cache').name
io_obj = ForemanMaintain::Utils::Disk::IODevice.new(device)
io_obj.available_space > MIN_SPACE_IN_MB
end
end
Expand Down

0 comments on commit d0a3563

Please sign in to comment.