File tree Expand file tree Collapse file tree 3 files changed +17
-10
lines changed
files/gitlab-ctl-commands
spec/chef/gitlab-ctl-commands/lib Expand file tree Collapse file tree 3 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ def tmp_data_dir
48
48
@tmp_data_dir = @tmp_dir ? "#{ @tmp_dir } /data" : data_dir
49
49
end
50
50
51
- def enough_free_space? ( dir )
52
- space_needed ( dir ) <= space_free ( dir )
51
+ def enough_free_space? ( dir , needed )
52
+ needed <= space_free ( dir )
53
53
end
54
54
55
55
def space_needed ( dir )
Original file line number Diff line number Diff line change 189
189
Kernel . exit 0
190
190
end
191
191
192
+ total_space_needed = 0 # in MiB
192
193
unless options [ :skip_disk_check ]
193
- check_dirs = [ @db_worker . tmp_dir ]
194
- check_dirs << @db_worker . data_dir if pg_enabled || patroni_enabled
195
- check_dirs << File . join ( @attributes [ 'gitlab' ] [ 'geo_postgresql' ] [ 'dir' ] , 'data' ) if geo_enabled
194
+ check_dirs = { }
195
+ check_dirs [ @db_worker . data_dir ] = 0 if pg_enabled || patroni_enabled
196
+ check_dirs [ File . join ( @attributes [ 'gitlab' ] [ 'geo_postgresql' ] [ 'dir' ] , 'data' ) ] = 0 if geo_enabled
197
+ check_dirs . each_key do |dir |
198
+ check_dirs [ dir ] = @db_worker . space_needed ( dir )
199
+ total_space_needed += check_dirs [ dir ]
200
+ end
201
+ # We need space for all databases if using --tmp-dir.
202
+ check_dirs = { @db_worker . tmp_dir => total_space_needed } if @db_worker . tmp_dir
196
203
197
- check_dirs . compact . uniq . each do |dir |
204
+ check_dirs . each do |dir , space_needed |
198
205
unless GitlabCtl ::Util . progress_message (
199
206
"Checking if disk for directory #{ dir } has enough free space for PostgreSQL upgrade"
200
207
) do
201
- @db_worker . enough_free_space? ( dir )
208
+ @db_worker . enough_free_space? ( dir , space_needed )
202
209
end
203
- log "Upgrade requires #{ @db_worker . space_needed ( dir ) } MB, but only #{ @db_worker . space_free ( dir ) } MB is free."
210
+ log "Upgrade requires #{ space_needed } MB, but only #{ @db_worker . space_free ( dir ) } MB is free."
204
211
Kernel . exit 1
205
212
end
206
213
next
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ def stub_postgresql_json_attributes(config = nil)
68
68
"df -P --block-size=1m #{ @dbw . data_dir } | awk '{print $4}'" , nil , 123
69
69
) . and_return ( "Available\n 220000" )
70
70
71
- expect ( @dbw . enough_free_space? ( @dbw . data_dir ) ) . to eq ( false )
71
+ expect ( @dbw . enough_free_space? ( @dbw . data_dir , 440000 ) ) . to eq ( false )
72
72
end
73
73
74
74
it 'detects when there is enough available disk space for upgrade' do
@@ -80,7 +80,7 @@ def stub_postgresql_json_attributes(config = nil)
80
80
"df -P --block-size=1m #{ @dbw . data_dir } | awk '{print $4}'" , nil , 123
81
81
) . and_return ( "Available\n 250000" )
82
82
83
- expect ( @dbw . enough_free_space? ( @dbw . data_dir ) ) . to eq ( true )
83
+ expect ( @dbw . enough_free_space? ( @dbw . data_dir , 100000 ) ) . to eq ( true )
84
84
end
85
85
end
86
86
You can’t perform that action at this time.
0 commit comments