Commit cec843b2 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@13-12-stable-ee

parent 2dd5a517
...@@ -36,7 +36,7 @@ class Namespace ...@@ -36,7 +36,7 @@ class Namespace
SET traversal_ids = cte.traversal_ids SET traversal_ids = cte.traversal_ids
FROM (#{recursive_traversal_ids}) as cte FROM (#{recursive_traversal_ids}) as cte
WHERE namespaces.id = cte.id WHERE namespaces.id = cte.id
AND namespaces.traversal_ids <> cte.traversal_ids AND namespaces.traversal_ids::bigint[] <> cte.traversal_ids
""" """
Namespace.transaction do Namespace.transaction do
@root.lock! @root.lock!
...@@ -51,7 +51,7 @@ class Namespace ...@@ -51,7 +51,7 @@ class Namespace
def incorrect_traversal_ids def incorrect_traversal_ids
Namespace Namespace
.joins("INNER JOIN (#{recursive_traversal_ids}) as cte ON namespaces.id = cte.id") .joins("INNER JOIN (#{recursive_traversal_ids}) as cte ON namespaces.id = cte.id")
.where('namespaces.traversal_ids <> cte.traversal_ids') .where('namespaces.traversal_ids::bigint[] <> cte.traversal_ids')
end end
private private
...@@ -66,9 +66,9 @@ class Namespace ...@@ -66,9 +66,9 @@ class Namespace
<<~SQL <<~SQL
WITH RECURSIVE cte(id, traversal_ids, cycle) AS ( WITH RECURSIVE cte(id, traversal_ids, cycle) AS (
VALUES(#{root_id}, ARRAY[#{root_id}], false) VALUES(#{root_id}::bigint, ARRAY[#{root_id}]::bigint[], false)
UNION ALL UNION ALL
SELECT n.id, cte.traversal_ids || n.id, n.id = ANY(cte.traversal_ids) SELECT n.id, cte.traversal_ids || n.id::bigint, n.id = ANY(cte.traversal_ids)
FROM namespaces n, cte FROM namespaces n, cte
WHERE n.parent_id = cte.id AND NOT cycle WHERE n.parent_id = cte.id AND NOT cycle
) )
......
...@@ -2085,7 +2085,7 @@ class User < ApplicationRecord ...@@ -2085,7 +2085,7 @@ class User < ApplicationRecord
end end
def check_username_format def check_username_format
return if username.blank? || Mime::EXTENSION_LOOKUP.keys.none? { |type| username.end_with?(type) } return if username.blank? || Mime::EXTENSION_LOOKUP.keys.none? { |type| username.end_with?(".#{type}") }
errors.add(:username, _('ending with MIME type format is not allowed.')) errors.add(:username, _('ending with MIME type format is not allowed.'))
end end
......
...@@ -24,6 +24,12 @@ def master_process? ...@@ -24,6 +24,12 @@ def master_process?
end end
warmup do |app| warmup do |app|
# The following is necessary to ensure stale Prometheus metrics don't accumulate over time.
# It needs to be done as early as here to ensure metrics files aren't deleted.
# After we hit our app in `warmup`, first metrics and corresponding files already being created,
# for example in `lib/gitlab/metrics/requests_rack_middleware.rb`.
Prometheus::CleanupMultiprocDirService.new.execute if master_process?
client = Rack::MockRequest.new(app) client = Rack::MockRequest.new(app)
client.get('/') client.get('/')
end end
......
...@@ -44,9 +44,6 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled? ...@@ -44,9 +44,6 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled?
# When running Puma in a Single mode, `on_master_start` and `on_worker_start` are the same. # When running Puma in a Single mode, `on_master_start` and `on_worker_start` are the same.
# Thus, we order these events to run `reinitialize_on_pid_change` with `force: true` first. # Thus, we order these events to run `reinitialize_on_pid_change` with `force: true` first.
Gitlab::Cluster::LifecycleEvents.on_master_start do Gitlab::Cluster::LifecycleEvents.on_master_start do
# Ensure that stale Prometheus metrics don't accumulate over time
Prometheus::CleanupMultiprocDirService.new.execute
::Prometheus::Client.reinitialize_on_pid_change(force: true) ::Prometheus::Client.reinitialize_on_pid_change(force: true)
if Gitlab::Runtime.unicorn? if Gitlab::Runtime.unicorn?
......
...@@ -383,6 +383,7 @@ RSpec.describe User do ...@@ -383,6 +383,7 @@ RSpec.describe User do
expect(user).not_to be_valid expect(user).not_to be_valid
expect(user.errors.full_messages).to include('Username ending with MIME type format is not allowed.') expect(user.errors.full_messages).to include('Username ending with MIME type format is not allowed.')
expect(build(:user, username: "test#{type}")).to be_valid
end end
end end
......
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