Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenSearchISMPolicy - shrink action has a maxShardSize required property which is invalid #750

Conversation

cthtrifork
Copy link
Contributor

@cthtrifork cthtrifork commented Mar 6, 2024

I have the following OpenSearchISMPolicy

apiVersion: opensearch.opster.io/v1
kind: OpenSearchISMPolicy
metadata:
  name: platypus-otto-shared
spec:
  opensearchCluster:
    name: opensearch
  _meta:
    description: platypus-otto-shared
  policyId: platypus-otto-shared
  description: A sample description of the policy
  states:
    - name: hot
      actions:
        - indexPriority:
            priority: 100
      transitions:
        - conditions:
            minIndexAge: 400d
          stateName: warm
    - name: warm
      actions:
        - shrink:
            numNewShards: 1
          forceMerge:
            maxNumSegments: 1
      transitions:
        - conditions:
            minIndexAge: 800d
          stateName: cold
    - name: cold
      actions:
        - readOnly: {}
      transitions:
        - conditions:
            minIndexAge: 3650d
          stateName: delete
    - name: delete
      actions:
        - delete: {}
      transitions: []
  defaultState: hot
  ismTemplate:
    priority: 1
    indexPatterns:
      - otto-reading_*

And I am receving the following error when validating the schema:

stdin - OpenSearchISMPolicy platypus-otto-shared is invalid: problem validating schema. Check JSON formatting: jsonschema: '/spec/states/1/actions/0/shrink' does not validate with file:///.../v1.26.5-standalone-strict/opensearchismpolicy-opensearch-v1.json#/properties/spec/properties/states/items/properties/actions/items/properties/shrink/required: missing properties: 'maxShardSize'

The error is saying that the maxShardSize property is required, but the maxShardSize property is not required in the shrink action for all permutations of how it can be used.
See the official documentation:

https://opensearch.org/docs/latest/im-plugin/ism/policies/#shrink
image

You are already handling the properties here:
opensearch-operator/pkg/reconcilers/ismpolicy.go

But we need to update the schema.

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.

…ates/items/properties/actions/items/properties/shrink/required is false

Signed-off-by: Casper Thygesen <cth@trifork.com>
@cthtrifork cthtrifork marked this pull request as ready for review March 6, 2024 13:45
@cthtrifork cthtrifork changed the title opensearchismpolicy-opensearch-v1.json#/properties/spec/properties/st… OpenSearchISMPolicy - shrink action has a maxShardSize required property which is invalid Mar 6, 2024
@prudhvigodithi
Copy link
Member

Thanks @cthtrifork LGTM.
Adding @bbarani @salyh @jochenkressin @pchmielnik @bbarani

@prudhvigodithi prudhvigodithi merged commit 5c30a77 into opensearch-project:main Mar 25, 2024
7 checks passed
@cthtrifork cthtrifork deleted the feature/ism-shrink-maxShardSize-not-required branch March 26, 2024 09:52
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