From 4e15496c8f1290928a47c2428bb62b75118e0c90 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Mon, 11 Nov 2013 16:09:06 -0500 Subject: [PATCH 1/3] Display error and send failure exit status if redis-cli fails This should help prevent a misconfigured redis causing silent failures and fix issue #108. --- lib/gitlab_update.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/gitlab_update.rb b/lib/gitlab_update.rb index 038253a361..5836b2e22e 100644 --- a/lib/gitlab_update.rb +++ b/lib/gitlab_update.rb @@ -56,6 +56,9 @@ def ssh? def update_redis queue = "#{config.redis_namespace}:queue:post_receive" msg = JSON.dump({'class' => 'PostReceive', 'args' => [@repo_path, @oldrev, @newrev, @refname, @key_id]}) - system(*config.redis_command, 'rpush', queue, msg, err: '/dev/null', out: '/dev/null') + unless system(*config.redis_command, 'rpush', queue, msg, err: '/dev/null', out: '/dev/null') + puts "GitLab: An unexpected error occurred (redis-cli returned #{$?.exitstatus}). " + exit 1 + end end end From ba2248f968ba0806c3c97be10ee15a7560685dcd Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Thu, 14 Nov 2013 12:41:04 -0500 Subject: [PATCH 2/3] Redis configuration check The bin/check script now checks if Redis is configured properly. --- bin/check | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/check b/bin/check index c867e387f9..f4588a25c9 100755 --- a/bin/check +++ b/bin/check @@ -12,13 +12,13 @@ resp = GitlabNet.new.check if resp.code == "200" print 'OK' else - puts "FAILED. code: #{resp.code}" + abort "FAILED. code: #{resp.code}" end puts "\nCheck directories and files: " config = GitlabConfig.new -dirs = [config.repos_path, config.auth_file, config.redis['bin']] +dirs = [config.repos_path, config.auth_file] dirs.each do |dir| abort("ERROR: missing option in config.yml") unless dir @@ -26,7 +26,13 @@ dirs.each do |dir| if File.exists?(dir) print 'OK' else - puts "FAILED" + abort "FAILED" end puts "\n" end + +print "Test redis-cli executable: " +abort('FAILED') unless system(*config.redis_command, '--version') + +print "Send ping to redis server: " +abort unless system(*config.redis_command, 'ping') From acab321d8fb357f69420915ec584865f7145e443 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Wed, 20 Nov 2013 10:21:03 -0500 Subject: [PATCH 3/3] Removing extra space from the end of gitlab_update error messages --- lib/gitlab_update.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gitlab_update.rb b/lib/gitlab_update.rb index 5836b2e22e..6b3271c31d 100644 --- a/lib/gitlab_update.rb +++ b/lib/gitlab_update.rb @@ -34,7 +34,7 @@ def exec update_redis exit 0 else - puts "GitLab: You are not allowed to access #{@branch_name}! " + puts "GitLab: You are not allowed to access #{@branch_name}!" exit 1 end else @@ -57,7 +57,7 @@ def update_redis queue = "#{config.redis_namespace}:queue:post_receive" msg = JSON.dump({'class' => 'PostReceive', 'args' => [@repo_path, @oldrev, @newrev, @refname, @key_id]}) unless system(*config.redis_command, 'rpush', queue, msg, err: '/dev/null', out: '/dev/null') - puts "GitLab: An unexpected error occurred (redis-cli returned #{$?.exitstatus}). " + puts "GitLab: An unexpected error occurred (redis-cli returned #{$?.exitstatus})." exit 1 end end