Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-26 00:09:23 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-26 00:09:23 +0300
commit32fd4cd5e2134511936899d6bcc4aaf18b9be6fd (patch)
tree10378ceffed52dd0e160a0d9bcf3c5ab72c18958 /lib
parent951616a26a61e880860ad862c1d45a8e3762b4bc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/internal/pages.rb2
-rw-r--r--lib/gitlab/import_export/import_export.yml1
-rw-r--r--lib/gitlab/job_waiter.rb31
-rw-r--r--lib/gitlab/slash_commands/presenters/base.rb2
-rw-r--r--lib/gitlab/tracing.rb37
5 files changed, 30 insertions, 43 deletions
diff --git a/lib/api/internal/pages.rb b/lib/api/internal/pages.rb
index e2e1351c939..4339d2ef490 100644
--- a/lib/api/internal/pages.rb
+++ b/lib/api/internal/pages.rb
@@ -36,7 +36,7 @@ module API
present virtual_domain, with: Entities::Internal::Serverless::VirtualDomain
else
# Handle Pages domains
- host = Namespace.find_by_pages_host(params[:host]) || PagesDomain.find_by_domain(params[:host])
+ host = Namespace.find_by_pages_host(params[:host]) || PagesDomain.find_by_domain_case_insensitive(params[:host])
no_content! unless host
virtual_domain = host.pages_virtual_domain
diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml
index aa275479e63..4fa909ac94b 100644
--- a/lib/gitlab/import_export/import_export.yml
+++ b/lib/gitlab/import_export/import_export.yml
@@ -173,7 +173,6 @@ excluded_attributes:
- :secret
- :encrypted_secret_token
- :encrypted_secret_token_iv
- - :repository_storage
merge_request_diff:
- :external_diff
- :stored_externally
diff --git a/lib/gitlab/job_waiter.rb b/lib/gitlab/job_waiter.rb
index 90dbe4d005d..e7a8cc6305a 100644
--- a/lib/gitlab/job_waiter.rb
+++ b/lib/gitlab/job_waiter.rb
@@ -19,6 +19,9 @@ module Gitlab
class JobWaiter
KEY_PREFIX = "gitlab:job_waiter"
+ STARTED_METRIC = :gitlab_job_waiter_started_total
+ TIMEOUTS_METRIC = :gitlab_job_waiter_timeouts_total
+
def self.notify(key, jid)
Gitlab::Redis::SharedState.with { |redis| redis.lpush(key, jid) }
end
@@ -27,15 +30,16 @@ module Gitlab
key.is_a?(String) && key =~ /\A#{KEY_PREFIX}:\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/
end
- attr_reader :key, :finished
+ attr_reader :key, :finished, :worker_label
attr_accessor :jobs_remaining
# jobs_remaining - the number of jobs left to wait for
# key - The key of this waiter.
- def initialize(jobs_remaining = 0, key = "#{KEY_PREFIX}:#{SecureRandom.uuid}")
+ def initialize(jobs_remaining = 0, key = "#{KEY_PREFIX}:#{SecureRandom.uuid}", worker_label: nil)
@key = key
@jobs_remaining = jobs_remaining
@finished = []
+ @worker_label = worker_label
end
# Waits for all the jobs to be completed.
@@ -45,6 +49,7 @@ module Gitlab
# long to process, or is never processed.
def wait(timeout = 10)
deadline = Time.now.utc + timeout
+ increment_counter(STARTED_METRIC)
Gitlab::Redis::SharedState.with do |redis|
# Fallback key expiry: allow a long grace period to reduce the chance of
@@ -60,7 +65,12 @@ module Gitlab
break if seconds_left <= 0
list, jid = redis.blpop(key, timeout: seconds_left)
- break unless list && jid # timed out
+
+ # timed out
+ unless list && jid
+ increment_counter(TIMEOUTS_METRIC)
+ break
+ end
@finished << jid
@jobs_remaining -= 1
@@ -72,5 +82,20 @@ module Gitlab
finished
end
+
+ private
+
+ def increment_counter(metric)
+ return unless worker_label
+
+ metrics[metric].increment(worker: worker_label)
+ end
+
+ def metrics
+ @metrics ||= {
+ STARTED_METRIC => Gitlab::Metrics.counter(STARTED_METRIC, 'JobWaiter attempts started'),
+ TIMEOUTS_METRIC => Gitlab::Metrics.counter(TIMEOUTS_METRIC, 'JobWaiter attempts timed out')
+ }
+ end
end
end
diff --git a/lib/gitlab/slash_commands/presenters/base.rb b/lib/gitlab/slash_commands/presenters/base.rb
index 54d74ed3998..08de9df14f8 100644
--- a/lib/gitlab/slash_commands/presenters/base.rb
+++ b/lib/gitlab/slash_commands/presenters/base.rb
@@ -63,7 +63,7 @@ module Gitlab
# Convert Markdown to slacks format
def format(string)
- Slack::Notifier::LinkFormatter.format(string)
+ Slack::Messenger::Util::LinkFormatter.format(string)
end
def resource_url
diff --git a/lib/gitlab/tracing.rb b/lib/gitlab/tracing.rb
deleted file mode 100644
index 7732d7c9d9c..00000000000
--- a/lib/gitlab/tracing.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module Tracing
- # Only enable tracing when the `GITLAB_TRACING` env var is configured. Note that we avoid using ApplicationSettings since
- # the same environment variable needs to be configured for Workhorse, Gitaly and any other components which
- # emit tracing. Since other components may start before Rails, and may not have access to ApplicationSettings,
- # an env var makes more sense.
- def self.enabled?
- connection_string.present?
- end
-
- def self.connection_string
- ENV['GITLAB_TRACING']
- end
-
- def self.tracing_url_template
- ENV['GITLAB_TRACING_URL']
- end
-
- def self.tracing_url_enabled?
- enabled? && tracing_url_template.present?
- end
-
- # This will provide a link into the distributed tracing for the current trace,
- # if it has been captured.
- def self.tracing_url
- return unless tracing_url_enabled?
-
- # Avoid using `format` since it can throw TypeErrors
- # which we want to avoid on unsanitised env var input
- tracing_url_template.to_s
- .gsub(/\{\{\s*correlation_id\s*\}\}/, Labkit::Correlation::CorrelationId.current_id.to_s)
- .gsub(/\{\{\s*service\s*\}\}/, Gitlab.process_name)
- end
- end
-end