summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-05-16 16:25:02 +0200
committerPawel Chojnacki <pawel@chojnacki.ws>2017-05-17 16:22:47 +0200
commit6ced4d138e56a82fc460d6281ae445fb7b739636 (patch)
tree4aaf211e9781ee017d29dbddfe91aa4935b8ac0d /lib
parent43befaf25f4f929d01a0af5ef3c2148002be7f4e (diff)
downloadgitlab-ce-6ced4d138e56a82fc460d6281ae445fb7b739636.tar.gz
Fix transient CI errors by increasing command execution timeouts from 1s to 30s
+ actually make local tests correctly detect wether 'timeout' or 'gtimeout' is available
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/health_checks/fs_shards_check.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/gitlab/health_checks/fs_shards_check.rb b/lib/gitlab/health_checks/fs_shards_check.rb
index df962d203b7..90612af3d63 100644
--- a/lib/gitlab/health_checks/fs_shards_check.rb
+++ b/lib/gitlab/health_checks/fs_shards_check.rb
@@ -42,6 +42,7 @@ module Gitlab
private
RANDOM_STRING = SecureRandom.hex(1000).freeze
+ COMMAND_TIMEOUT = 1.second
def operation_metrics(ok_metric, latency_metric, operation, **labels)
with_timing operation do |result, elapsed|
@@ -64,7 +65,11 @@ module Gitlab
end
def with_timeout(args)
- %w{timeout 1}.concat(args)
+ %W{timeout #{COMMAND_TIMEOUT.to_i}}.concat(args)
+ end
+
+ def exec_with_timeout(cmd_args, *args, &block)
+ Gitlab::Popen.popen(with_timeout(cmd_args), *args, &block)
end
def tmp_file_path(storage_name)
@@ -78,7 +83,7 @@ module Gitlab
def storage_stat_test(storage_name)
stat_path = File.join(path(storage_name), '.')
begin
- _, status = Gitlab::Popen.popen(with_timeout(%W{ stat #{stat_path} }))
+ _, status = exec_with_timeout(%W{ stat #{stat_path} })
status == 0
rescue Errno::ENOENT
File.exist?(stat_path) && File::Stat.new(stat_path).readable?
@@ -86,7 +91,7 @@ module Gitlab
end
def storage_write_test(tmp_path)
- _, status = Gitlab::Popen.popen(with_timeout(%W{ tee #{tmp_path} })) do |stdin|
+ _, status = exec_with_timeout(%W{ tee #{tmp_path} }) do |stdin|
stdin.write(RANDOM_STRING)
end
status == 0
@@ -96,7 +101,7 @@ module Gitlab
end
def storage_read_test(tmp_path)
- _, status = Gitlab::Popen.popen(with_timeout(%W{ diff #{tmp_path} - })) do |stdin|
+ _, status = exec_with_timeout(%W{ diff #{tmp_path} - }) do |stdin|
stdin.write(RANDOM_STRING)
end
status == 0
@@ -106,7 +111,7 @@ module Gitlab
end
def delete_test_file(tmp_path)
- _, status = Gitlab::Popen.popen(with_timeout(%W{ rm -f #{tmp_path} }))
+ _, status = exec_with_timeout(%W{ rm -f #{tmp_path} })
status == 0
rescue Errno::ENOENT
File.delete(tmp_path) rescue Errno::ENOENT