Commit 1f85f7b7 authored by Kirill Smelkov's avatar Kirill Smelkov

NXD lib/tasks/gitlab/check: Exit with non-zero code, if something failed in a check task

This is handy for monitoring tools, which could e.g. periodically call check
tasks and instead of parsing output, rely on exit code.

The way we detect if something failed is via hooking into String#red, and if
anything was ever printed in red - that's an error.
parent d5b83852
# if we ever print anything in red - that's an error
$check_failed = false
class String
alias_method :orig_red, :red
def red(*args)
$check_failed = true
orig_red(*args)
end
end
namespace :gitlab do namespace :gitlab do
desc "GitLab | Check the configuration of GitLab and its environment" desc "GitLab | Check the configuration of GitLab and its environment"
task check: %w{gitlab:gitlab_shell:check task check: %w{gitlab:gitlab_shell:check
...@@ -847,8 +857,9 @@ namespace :gitlab do ...@@ -847,8 +857,9 @@ namespace :gitlab do
def finished_checking(component) def finished_checking(component)
puts "" puts ""
puts "Checking #{component.yellow} ... #{"Finished".green}" puts "Checking #{component.yellow} ... #{$check_failed ? "Failed".red : "OK".green}"
puts "" puts ""
exit 1 if $check_failed
end end
def see_database_guide def see_database_guide
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment