summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-03 21:07:29 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-03 21:07:29 +0000
commit1da3754b25657f49afdcb0b942506d365b1ee89d (patch)
tree9f4bfa94fdd1762ef99e6a61bf180ac8cd7b5616 /lib
parent25521def84a6987fe9d4265b560e930bfb32c195 (diff)
downloadgitlab-ce-1da3754b25657f49afdcb0b942506d365b1ee89d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ci/parsers/test/junit.rb6
-rw-r--r--lib/gitlab/health_checks/checks.rb14
-rw-r--r--lib/gitlab/health_checks/gitaly_check.rb8
-rw-r--r--lib/gitlab/health_checks/metric.rb6
-rw-r--r--lib/gitlab/health_checks/prometheus_text_format.rb42
-rw-r--r--lib/gitlab/health_checks/result.rb14
-rw-r--r--lib/gitlab/health_checks/simple_abstract_check.rb8
-rw-r--r--lib/gitlab/shell.rb5
-rw-r--r--lib/gitlab/url_blocker.rb5
9 files changed, 52 insertions, 56 deletions
diff --git a/lib/gitlab/ci/parsers/test/junit.rb b/lib/gitlab/ci/parsers/test/junit.rb
index dca60eabc1c..8f8cae0b5f2 100644
--- a/lib/gitlab/ci/parsers/test/junit.rb
+++ b/lib/gitlab/ci/parsers/test/junit.rb
@@ -49,6 +49,12 @@ module Gitlab
if data['failure']
status = ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED
system_output = data['failure']
+ elsif data['error']
+ # For now, as an MVC, we are grouping error test cases together
+ # with failed ones. But we will improve this further on
+ # https://gitlab.com/gitlab-org/gitlab/issues/32046.
+ status = ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED
+ system_output = data['error']
else
status = ::Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS
system_output = nil
diff --git a/lib/gitlab/health_checks/checks.rb b/lib/gitlab/health_checks/checks.rb
new file mode 100644
index 00000000000..c4016c5fffd
--- /dev/null
+++ b/lib/gitlab/health_checks/checks.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module HealthChecks
+ CHECKS = [
+ Gitlab::HealthChecks::DbCheck,
+ Gitlab::HealthChecks::Redis::RedisCheck,
+ Gitlab::HealthChecks::Redis::CacheCheck,
+ Gitlab::HealthChecks::Redis::QueuesCheck,
+ Gitlab::HealthChecks::Redis::SharedStateCheck,
+ Gitlab::HealthChecks::GitalyCheck
+ ].freeze
+ end
+end
diff --git a/lib/gitlab/health_checks/gitaly_check.rb b/lib/gitlab/health_checks/gitaly_check.rb
index e560f87bf98..f5f142c251f 100644
--- a/lib/gitlab/health_checks/gitaly_check.rb
+++ b/lib/gitlab/health_checks/gitaly_check.rb
@@ -29,7 +29,13 @@ module Gitlab
def check(storage_name)
serv = Gitlab::GitalyClient::HealthCheckService.new(storage_name)
result = serv.check
- HealthChecks::Result.new(result[:success], result[:message], shard: storage_name)
+
+ HealthChecks::Result.new(
+ name,
+ result[:success],
+ result[:message],
+ shard: storage_name
+ )
end
private
diff --git a/lib/gitlab/health_checks/metric.rb b/lib/gitlab/health_checks/metric.rb
index 184083de2bc..b697cb0d027 100644
--- a/lib/gitlab/health_checks/metric.rb
+++ b/lib/gitlab/health_checks/metric.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
-module Gitlab::HealthChecks
- Metric = Struct.new(:name, :value, :labels)
+module Gitlab
+ module HealthChecks
+ Metric = Struct.new(:name, :value, :labels)
+ end
end
diff --git a/lib/gitlab/health_checks/prometheus_text_format.rb b/lib/gitlab/health_checks/prometheus_text_format.rb
deleted file mode 100644
index 2a8f9d31cd5..00000000000
--- a/lib/gitlab/health_checks/prometheus_text_format.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module HealthChecks
- class PrometheusTextFormat
- def marshal(metrics)
- "#{metrics_with_type_declarations(metrics).join("\n")}\n"
- end
-
- private
-
- def metrics_with_type_declarations(metrics)
- type_declaration_added = {}
-
- metrics.flat_map do |metric|
- metric_lines = []
-
- unless type_declaration_added.key?(metric.name)
- type_declaration_added[metric.name] = true
- metric_lines << metric_type_declaration(metric)
- end
-
- metric_lines << metric_text(metric)
- end
- end
-
- def metric_type_declaration(metric)
- "# TYPE #{metric.name} gauge"
- end
-
- def metric_text(metric)
- labels = metric.labels&.map { |key, value| "#{key}=\"#{value}\"" }&.join(',') || ''
-
- if labels.empty?
- "#{metric.name} #{metric.value}"
- else
- "#{metric.name}{#{labels}} #{metric.value}"
- end
- end
- end
- end
-end
diff --git a/lib/gitlab/health_checks/result.rb b/lib/gitlab/health_checks/result.rb
index 4586b1d94a7..38a36100ec7 100644
--- a/lib/gitlab/health_checks/result.rb
+++ b/lib/gitlab/health_checks/result.rb
@@ -1,5 +1,15 @@
# frozen_string_literal: true
-module Gitlab::HealthChecks
- Result = Struct.new(:success, :message, :labels)
+module Gitlab
+ module HealthChecks
+ Result = Struct.new(:name, :success, :message, :labels) do
+ def payload
+ {
+ status: success ? 'ok' : 'failed',
+ message: message,
+ labels: labels
+ }.compact
+ end
+ end
+ end
end
diff --git a/lib/gitlab/health_checks/simple_abstract_check.rb b/lib/gitlab/health_checks/simple_abstract_check.rb
index bc02f0da98d..959f28791c3 100644
--- a/lib/gitlab/health_checks/simple_abstract_check.rb
+++ b/lib/gitlab/health_checks/simple_abstract_check.rb
@@ -8,14 +8,14 @@ module Gitlab
def readiness
check_result = check
if successful?(check_result)
- HealthChecks::Result.new(true)
+ HealthChecks::Result.new(name, true)
elsif check_result.is_a?(Timeout::Error)
- HealthChecks::Result.new(false, "#{human_name} check timed out")
+ HealthChecks::Result.new(name, false, "#{human_name} check timed out")
else
- HealthChecks::Result.new(false, "unexpected #{human_name} check result: #{check_result}")
+ HealthChecks::Result.new(name, false, "unexpected #{human_name} check result: #{check_result}")
end
rescue => e
- HealthChecks::Result.new(false, "unexpected #{human_name} check result: #{e}")
+ HealthChecks::Result.new(name, false, "unexpected #{human_name} check result: #{e}")
end
def metrics
diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb
index ec9b2a2022e..7722480903d 100644
--- a/lib/gitlab/shell.rb
+++ b/lib/gitlab/shell.rb
@@ -113,10 +113,6 @@ module Gitlab
success
end
- # Move repository reroutes to mv_directory which is an alias for
- # mv_namespace. Given the underlying implementation is a move action,
- # indescriminate of what the folders might be.
- #
# storage - project's storage path
# path - project disk path
# new_path - new project disk path
@@ -275,7 +271,6 @@ module Gitlab
false
end
- alias_method :mv_directory, :mv_namespace # Note: ShellWorker uses this alias
def url_to_repo(path)
Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git"
diff --git a/lib/gitlab/url_blocker.rb b/lib/gitlab/url_blocker.rb
index 4285b2675c5..0adca34440c 100644
--- a/lib/gitlab/url_blocker.rb
+++ b/lib/gitlab/url_blocker.rb
@@ -125,6 +125,11 @@ module Gitlab
# If the addr can't be resolved or the url is invalid (i.e http://1.1.1.1.1)
# we block the url
raise BlockedUrlError, "Host cannot be resolved or invalid"
+ rescue ArgumentError => error
+ # Addrinfo.getaddrinfo errors if the domain exceeds 1024 characters.
+ raise unless error.message.include?('hostname too long')
+
+ raise BlockedUrlError, "Host is too long (maximum is 1024 characters)"
end
def validate_local_request(