Skip to content

Add min attribute to elasticsearch form

sameer shaik requested to merge sshaik-elasticreplicas into master

What does this MR do and why?

Related Issue: #245219 (closed)

The elasticsearch settings form allows users to select negative values. The corresponding model IndexSetting has the necessary validations for number_of_replicas and number_of_shard attributes.

class IndexSetting < ApplicationRecord
    self.table_name = 'elastic_index_settings'

    validates :alias_name, uniqueness: true, length: { maximum: 255 }
    validates :number_of_replicas, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
    validates :number_of_shards, presence: true, numericality: { only_integer: true, greater_than: 0 }

In the _elasticsearch_form.html.haml file, the number_field helper doesn't have the min attribute.

This MR adds a minor change to the _elasticsearch_form.html.haml file to set the min attribute for number_of_replicas and number_of_shard settings.

Screenshots or screen recordings

Before:

Screenshot_2022-10-07_at_9.09.36_PM

After:

Screenshot_2022-10-07_at_9.10.06_PM

How to set up and validate locally

  1. Switch to sshaik-elasticreplicas branch
  2. Once the app is up and running, navigate to https://gitlab.example.com/admin/application_settings/advanced_search (Please not that it's a paid feature)
  3. Expand the Advanced Search section and change/test the values under Number of Elasticsearch shards and replicas per index

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by sameer shaik

Merge request reports

Loading