summaryrefslogtreecommitdiff
path: root/app/models/performance_monitoring/prometheus_dashboard.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/performance_monitoring/prometheus_dashboard.rb')
-rw-r--r--app/models/performance_monitoring/prometheus_dashboard.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/performance_monitoring/prometheus_dashboard.rb b/app/models/performance_monitoring/prometheus_dashboard.rb
index bf87d2c3916..40d14aaa1de 100644
--- a/app/models/performance_monitoring/prometheus_dashboard.rb
+++ b/app/models/performance_monitoring/prometheus_dashboard.rb
@@ -53,14 +53,23 @@ module PerformanceMonitoring
# This method is planned to be refactored as a part of https://gitlab.com/gitlab-org/gitlab/-/issues/219398
# implementation. For new existing logic was reused to faster deliver MVC
def schema_validation_warnings
+ return run_custom_validation.map(&:message) if Feature.enabled?(:metrics_dashboard_exhaustive_validations, environment&.project)
+
self.class.from_json(reload_schema)
- nil
+ []
+ rescue Gitlab::Metrics::Dashboard::Errors::LayoutError => error
+ [error.message]
rescue ActiveModel::ValidationError => exception
exception.model.errors.map { |attr, error| "#{attr}: #{error}" }
end
private
+ def run_custom_validation
+ Gitlab::Metrics::Dashboard::Validator
+ .errors(reload_schema, dashboard_path: path, project: environment&.project)
+ end
+
# dashboard finder methods are somehow limited, #find includes checking if
# user is authorised to view selected dashboard, but modifies schema, which in some cases may
# cause false positives returned from validation, and #find_raw does not authorise users