diff options
-rw-r--r-- | app/models/namespace/traversal_hierarchy.rb | 8 | ||||
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | config.ru | 6 | ||||
-rw-r--r-- | config/initializers/7_prometheus_metrics.rb | 3 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 1 |
5 files changed, 12 insertions, 8 deletions
diff --git a/app/models/namespace/traversal_hierarchy.rb b/app/models/namespace/traversal_hierarchy.rb index 093b7dae246..34086a8af5d 100644 --- a/app/models/namespace/traversal_hierarchy.rb +++ b/app/models/namespace/traversal_hierarchy.rb @@ -36,7 +36,7 @@ class Namespace SET traversal_ids = cte.traversal_ids FROM (#{recursive_traversal_ids}) as cte WHERE namespaces.id = cte.id - AND namespaces.traversal_ids <> cte.traversal_ids + AND namespaces.traversal_ids::bigint[] <> cte.traversal_ids """ Namespace.transaction do @root.lock! @@ -51,7 +51,7 @@ class Namespace def incorrect_traversal_ids Namespace .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 private @@ -66,9 +66,9 @@ class Namespace <<~SQL 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 - 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 WHERE n.parent_id = cte.id AND NOT cycle ) diff --git a/app/models/user.rb b/app/models/user.rb index 5feb3485b84..cae36ca6794 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2085,7 +2085,7 @@ class User < ApplicationRecord end 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.')) end diff --git a/config.ru b/config.ru index 0c50b3fdf6f..ff73b902ea8 100644 --- a/config.ru +++ b/config.ru @@ -24,6 +24,12 @@ def master_process? end 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.get('/') end diff --git a/config/initializers/7_prometheus_metrics.rb b/config/initializers/7_prometheus_metrics.rb index a304f861db8..a010417bdc4 100644 --- a/config/initializers/7_prometheus_metrics.rb +++ b/config/initializers/7_prometheus_metrics.rb @@ -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. # Thus, we order these events to run `reinitialize_on_pid_change` with `force: true` first. 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) if Gitlab::Runtime.unicorn? diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index bce3083ab94..551cd425f38 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -383,6 +383,7 @@ RSpec.describe User do expect(user).not_to be_valid 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 |