Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-10987

Avoid the ES index to be dropped because of the new security standards fields

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.3
    • Component/s: ElasticSearch
    • Labels:
      None
    • Edition:
      Community
    • Production Notes:
      The issues.indexStructure hash has to be manually updated to avoid the index to be dropped.

      Description

      We should try to avoid having to drop/rebuild the entire index, especially on SonarCloud.

      The plan is to deploy on pre-production without any specific action. Since the ES structure has changed, it will be detected and the index will be dropped/recreated. It will take time but this is fine since this is pre-prod.

      Then run the following ES query on pre-prod to get the new ES index hash:
      curl <pre-prod es server>:<port>/metadatas/_search?pretty&size=100
      We are interested by the has of the issues.indexStructure

          {
              "_index" : "metadatas",
              "_type" : "metadata",
              "_id" : "issues.indexStructure",
              "_score" : 1.0,
              "_source" : {
                "value" : "<the value>"
              }
            },
      

      Just before installing the new version on production, update the ES entry to match the one on pre-prod:
      curl localhost:9200/metadatas/metadata/issues.indexStructure?refresh=true -XPUT -d '{"value":"<the value>"}'

      And add the 3 new fields to the issues index:

      curl localhost:9200/issues/_mapping/issue -XPUT -d'{"properties":{"owaspTop10":{"type":"keyword"}}}'
      curl localhost:9200/issues/_mapping/issue -XPUT -d'{"properties":{"sansTop25":{"type":"keyword"}}}'
      curl localhost:9200/issues/_mapping/issue -XPUT -d'{"properties":{"cwe":{"type":"keyword"}}}'
      

      Then install the new SonarCloud version.

      This should prevent the index to be dropped by the next startup.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                henri.gomez Henri Gomez (Inactive)
                Reporter:
                julien.henry Julien Henry
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: