Check for strict_dynamic_mapping_exception in elasticsearch log

Adding a new check

This check looks for occurrences of strict_dynamic_mapping_exception in /var/log/gitlab/gitlab-rails/elasticsearch.log, which indicates the elasticsearch index must be recreated.

Fixes #145

Verification steps for review

Example error message to test with:

{"severity":"WARN","time":"2023-06-17T00:04:40.145Z","meta.caller_id":"ElasticIndexBulkCronWorker","correlation_id":"03613bf63ba61023ea9ebdd1294bdcbb","meta.root_caller_id":"Cronjob","meta.feature_category":"global_search","meta.client_id":"ip/","message":"bulk_error","item":{"index":{"_index":"gitlab-production-notes-20211216-2050","_type":"_doc","_id":"note_136643","status":400,"error":{"type":"strict_dynamic_mapping_exception","reason":"mapping set to strict, dynamic introduction of [internal] within [doc] is not allowed"}}}}
  1. Add the error to /var/log/gitlab/gitlab-rails/elasticsearch.log
  2. Run the check and make sure it triggers the notice to recreate the index
  3. Remove the error from /var/log/gitlab/gitlab-rails/elasticsearch.log or just remove the log altogether
  4. Run the check and verify it does not trigger the notice

Author checklist

  • After opening the MR:
    • Set it to the current milestone
    • Ask the Maintainer from the Reviewer roulette suggestion for review

Reviewer checklist

  • I followed the verification steps and confirm the functionality of the new check
    • I executed the check as presented in this MR by running the generated playbook with spot
    • In case of unexpected/odd behavior here, verify the generated playbook to account for potential YAML parsing issues
  • This check does only perform read operations
  • This check does not output more than necessary on stdout for the check to function
  • The message explains what it means when this check does not pass
  • The workaround_url provides actionable information/steps for affected users
    • Consider if a Knowledge Base article should exist to serve as the ideal workaround URL
  • This check is not using the Rails console/runner, or has Maintainer approval for doing so
  • This check is not using a Rake task, or has Maintainer approval for doing so
  • If this is a breaking change check:
    • It has the corresponding xx_breaking_changes tag (xx being the major release version for the change)
    • The workaround_url goes to the entry on the https://docs.gitlab.com/update/deprecations/ page
    • The ref_url goes to the deprecation issue linked from that entry
    • The title is the same as that entry
    • The version_started is equal to the announcement_milestone of the deprecation
    • The version_fixed is equal to the removal_milestone of the deprecation
Edited by Doug Stull

Merge request reports

Loading