opensearch-project / opensearch-k8s-operator

OpenSearch Kubernetes Operator
Apache License 2.0
365 stars 192 forks source link

[BUG] ISM CRD allocation action is broken #829

Open Jerrimikkihvatai opened 1 month ago

Jerrimikkihvatai commented 1 month ago

What is the bug?

I can't create an ISM policy with only one allocation parameter, though I can do it via api or Opensearch dashboards. I get the following error:

one or more objects failed to apply, reason: OpenSearchISMPolicy.opensearch.opster.io "delete-more-30d" is invalid: [spec.states[1].actions[0].allocation.exclude: Required value, spec.states[1].actions[0].allocation.include: Required value, spec.states[1].actions[0].allocation.waitFor: Required value]

Seems that the problem is in required field in ISM CRD

How can one reproduce the bug?

Try to create ISM CRD like that

---
apiVersion: opensearch.opster.io/v1
kind: OpenSearchISMPolicy
metadata:
   name: delete-more-30d
   namespace: devops-opensearch-infra
spec:
   opensearchCluster:
      name: opensearch-prod
   description: Delete indices older than 30 days
   policyId: delete_more_30d
   defaultState: open
   ismTemplate:
      priority: 1
      indexPatterns:
         - "testindex-*"
   states:
      - name: open
        actions:
           - open: {}
        transitions:
           - stateName: cold
             conditions:
                minIndexAge: "15d"
      - name: cold
        actions:
           - allocation:
                require: "temp: cold"
        transitions:
           - stateName: delete
             conditions:
                minIndexAge: "30d"
      - name: delete
        actions:
           - delete: {}
---

What is the expected behavior?

I expect to create an ISM policy with only one parameter

What is your host/environment?

OS 2.14, operator 2.6.0

Do you have any additional context?

I noticed confusing information on os docs about allocation action It says that all parameters are required, though you can create an ISM policy with only one of them (include, exclude, required) I also noticed wrong description of crd fields there

prudhvigodithi commented 1 week ago

[Triage] Hey @cthtrifork can you please check this, I assume your contribution in this PR https://github.com/opensearch-project/opensearch-k8s-operator/pull/788 should fix the error. Thanks @getsaurabh02

prudhvigodithi commented 1 week ago

Similiar issue related to this topic https://github.com/opensearch-project/opensearch-k8s-operator/issues/812#issuecomment-2181387505.

rkthtrifork commented 1 week ago

From a quick look at the code, it looks like the ism policy object does not require all 4 to be set so I believe it's just in the CRD which should be a quick fix. I might do it on monday