Skip to content

Conversation

@AndreKurait
Copy link
Member

@AndreKurait AndreKurait commented Nov 7, 2025

Description

Allow setting index.creation_date on index creation for plugin compatibility and migrations.

Aligns behavior with snapshot restore to let migrations retain original creation timestamps.

Manual Testing

Verified with script which ran with output

➜  ~ ./validation.sh
=== CONFIG ===
Endpoint: http://localhost:9200
Suffix:   1762548057

=== 1) Create index WITHOUT explicit creation_date (test-index-auto-1762548057) ===
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "test-index-auto-1762548057"
}

--- GET settings (test-index-auto-1762548057) ---
{
  "test-index-auto-1762548057": {
    "settings": {
      "index": {
        "replication": {
          "type": "DOCUMENT"
        },
        "number_of_shards": "1",
        "provided_name": "test-index-auto-1762548057",
        "creation_date": "1762548057850",
        "number_of_replicas": "1",
        "uuid": "p9myRyg8S4SpIey0vMXIrw",
        "version": {
          "created": "137257827"
        }
      }
    }
  }
}
Requested: (auto-generated)
Actual:    1762548057850

=== 2) Create index WITH explicit creation_date (test-index-explicit-1762548057) ===
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "test-index-explicit-1762548057"
}

--- GET settings (test-index-explicit-1762548057) ---
{
  "test-index-explicit-1762548057": {
    "settings": {
      "index": {
        "replication": {
          "type": "DOCUMENT"
        },
        "number_of_shards": "1",
        "provided_name": "test-index-explicit-1762548057",
        "creation_date": "1234567890000",
        "number_of_replicas": "1",
        "uuid": "I3-vNRqLQz2xW4PKX3-Izw",
        "version": {
          "created": "137257827"
        }
      }
    }
  }
}
Requested: 1234567890000
Actual:    1234567890000

=== 3) Create INDEX TEMPLATE WITHOUT creation_date (no-date-template-1762548057) ===
{
  "acknowledged": true
}

--- GET template (no-date-template-1762548057) ---
{
  "index_templates": [
    {
      "name": "no-date-template-1762548057",
      "index_template": {
        "index_patterns": [
          "no-date-*1762548057"
        ],
        "template": {
          "settings": {
            "index": {
              "number_of_shards": "1"
            }
          }
        },
        "composed_of": []
      }
    }
  ]
}

--- Create index matching that template (no-date-1762548057) ---
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "no-date-1762548057"
}

--- GET settings (no-date-1762548057) ---
{
  "no-date-1762548057": {
    "settings": {
      "index": {
        "replication": {
          "type": "DOCUMENT"
        },
        "number_of_shards": "1",
        "provided_name": "no-date-1762548057",
        "creation_date": "1762548058741",
        "number_of_replicas": "1",
        "uuid": "LEAlsbeyQfSsCkAaV5sL7Q",
        "version": {
          "created": "137257827"
        }
      }
    }
  }
}
Requested: (auto-generated)
Actual:    1762548058741

=== 4) Create INDEX TEMPLATE WITH creation_date (with-date-template-1762548057) ===
{
  "acknowledged": true
}

--- GET template (with-date-template-1762548057) ---
{
  "index_templates": [
    {
      "name": "with-date-template-1762548057",
      "index_template": {
        "index_patterns": [
          "with-date-*1762548057"
        ],
        "template": {
          "settings": {
            "index": {
              "number_of_shards": "1",
              "creation_date": "1234567890000"
            }
          }
        },
        "composed_of": []
      }
    }
  ]
}

--- Create index matching that template (with-date-1762548057) ---
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "with-date-1762548057"
}

--- GET settings (with-date-1762548057) ---
{
  "with-date-1762548057": {
    "settings": {
      "index": {
        "replication": {
          "type": "DOCUMENT"
        },
        "number_of_shards": "1",
        "provided_name": "with-date-1762548057",
        "creation_date": "1234567890000",
        "number_of_replicas": "1",
        "uuid": "G_-aknqPSKaucpMWlK4QSw",
        "version": {
          "created": "137257827"
        }
      }
    }
  }
}
Requested: 1234567890000
Actual:    1234567890000

=== SUMMARY ===
Index                        | Source                 | Requested (ms)      | Actual (ms)         | Match
--------------------------------------------------------------------------------------------------------------
test-index-auto-1762548057   | direct (no date)       | (auto-generated)    | 1762548057850       | n/a  
test-index-explicit-1762548057 | direct (explicit date) | 1234567890000       | 1234567890000       | yes  
no-date-1762548057           | template (no date)     | (auto-generated)    | 1762548058741       | n/a  
with-date-1762548057         | template (explicit date) | 1234567890000       | 1234567890000       | yes  

Done.

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@AndreKurait AndreKurait requested a review from a team as a code owner November 7, 2025 22:16
@peternied
Copy link
Member

@AndreKurait Thanks for the PR, looks like you need to run ./gradlew spotlessApply and add a change log entry

@peternied
Copy link
Member

@mch2 This seems like a pretty safe change that helps unblock migration scenarios with index state management, any concerns about taking this?

@peternied peternied self-assigned this Nov 7, 2025
…ibility and migrations

Aligns behavior with snapshot restore to let migrations retain original creation timestamps.

Signed-off-by: Andre Kurait <akurait@amazon.com>
@AndreKurait AndreKurait force-pushed the AllowSettingIndexCreationDateOnIndexCreation branch from d99347a to 07cb2b9 Compare November 7, 2025 22:49
@AndreKurait
Copy link
Member Author

@AndreKurait Thanks for the PR, looks like you need to run ./gradlew spotlessApply and add a change log entry

Updated spotless and added the changelog

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

❌ Gradle check result for 07cb2b9: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@peternied
Copy link
Member

@AndreKurait Looking at the failure - pretty sure it was impacted by this change, look into org.opensearch.client.IndicesClientIT.testCreateIndexFailPrivateSetting

@github-actions
Copy link
Contributor

❌ Gradle check result for 07cb2b9: null

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

…al and non-private

Signed-off-by: Andre Kurait <akurait@amazon.com>
Signed-off-by: Andre Kurait <akurait@amazon.com>
@github-actions
Copy link
Contributor

✅ Gradle check result for d23db8a: SUCCESS

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.18%. Comparing base (332efe3) to head (d23db8a).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #19931      +/-   ##
============================================
- Coverage     73.21%   73.18%   -0.04%     
- Complexity    71416    71553     +137     
============================================
  Files          5779     5785       +6     
  Lines        326332   326584     +252     
  Branches      47227    47291      +64     
============================================
+ Hits         238918   239001      +83     
- Misses        68189    68374     +185     
+ Partials      19225    19209      -16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AndreKurait
Copy link
Member Author

@peternied, I've addressed all tests failures and added new tests to verify behavior. I've updated the behavior to allow updating creation_date during restore of an index with snapshot_restore too

Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @AndreKurait !

@peternied peternied merged commit ad9794b into opensearch-project:main Nov 11, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants