opensearch-project / opensearch-k8s-operator

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

[BUG] ISM policy "allocation" not working through CRD #812

Closed fbegyn closed 1 week ago

fbegyn commented 1 month ago

What is the bug?

This might very well be user error or missing documentation, but I can't figure out how to get the ISM allocation action to work within the CRD. For example the "hot/cold" strategy implementation would be a good thing to fully document and show how it works.

operator-controller-manager {"level":"error","ts":"2024-05-14T09:23:42.939Z","msg":"Reconciler error","controller":"opensearchismpolicy","controllerGroup":"opensearch.opster.io","controllerKind":"OpenSearchISMPolicy","OpenSearchISMPolicy":{"name":"all-logs-allocation","namespace":"logging"},"namespace":"logging","name":"all-logs-allocation","reconcileID":"cf9c0524-34af-4c98-b6dd-432592ed8eea","error":"failed to create ism policy: [400 Bad Request] {\"error\":{\"root_cause\":[{\"type\":\"parsing_exception\",\"reason\":\"Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]\",\"line\":1,\"col\":190}],\"type\":\"parsing_exception\",\"reason\":\"Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]\",\"line\":1,\"col\":190},\"status\":400}","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:324\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:265\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:226"}

I have a feeling this is the porting from the allocation docs where the type is string and the had validation in the operator to expect a string, instead of a map[string]string (which would offer support for the YAML tree structure in the docs).

How can one reproduce the bug?

Attempt to create an OpenSearchISMPolicy with the allocation action:

      actions:
        - allocation:
            require:
              "temp": "hot"
            include: ""
            exclude: ""
            waitFor: "false"

What is the expected behavior?

The ISM policy definitions behave like expected with the Opensearch API as documented https://opensearch.org/docs/latest/im-plugin/ism/policies/#allocation .

What is your host/environment?

Kubernetes 1.27

prudhvigodithi commented 1 week ago

[Triage] Hey @fbegyn thanks for creating the issue, there is already an open issue related to this topic https://github.com/opensearch-project/opensearch-k8s-operator/issues/829, closing this and please feel-free to reopen if required. Thank you @swoehrl-mw @getsaurabh02