Skip to content

Set and maintain archived in notes index

Ravi Kumar requested to merge 414905-add-archived-note-instance-proxy into master

What does this MR do and why?

This MR is setting the boolean archived field value for the notes index if the migration add_archived_to_notes is finished. Also setting elastic_index_dependant_association on notes to synch the archived values in the notes index.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  • Ensure Elasticsearch is enabled in the gdk

Case migration add_archived_to_notes is not finished

  • To simulate this case make an early return here
      def migration_has_finished?(name)
        return false if name.eql?(:add_archived_to_notes)
        Rails.cache.fetch cache_key(:migration_has_finished, name.to_s.underscore), expires_in: CACHE_TIMEOUT do
          migration_has_finished_uncached?(name)
        end
      end
  • Create a new note on any project item like an issue, merge_request
  • Check the Elastic that the new note should not have an archived field
  • Now archive that project, and again check on Elastic, the archived field still should not be present for this note
  • Again unarchive the project and make sure on Elastic, the archived field still should not be present for this note

Case migration add_archived_to_notes is finished

  • To be sure the migration is finished, run the following commands in the rails console. To start the rails console run the following command.
bundle exec rails c
  • Now in the console run the following commands
require_relative 'ee/elastic/migrate/20230719142200_add_archived_to_notes.rb'
AddArchivedToNotes.new(20230719142200).migrate
  • Create a new note on any project item like an issue, merge_request
  • Check the Elastic that the new note should have an archived field
  • Now archive that project, and again check on Elastic, the archived field should be set to true
  • Again unarchive the project and make sure on Elastic, the archived field should be set to false

This is a curl request you can use to check the note. Replace the project_id with the one you used for the testing

curl -XGET "http://localhost:9200/gitlab-development-notes/_search" -H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
{
  "query": {
    "bool": {
      "filter": {
        "term": {
          "project_id": #{project_id}
        }
      }
    }
  }
}' | json_pp

MR acceptance checklist

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

Related to #414905 (closed)

Edited by Ravi Kumar

Merge request reports

Loading