From c19dada793d91a7a9aeee01d7cbfd6d2014a95a0 Mon Sep 17 00:00:00 2001 From: Nilushan Costa Date: Mon, 13 May 2024 17:20:40 +0530 Subject: [PATCH] Add retry for opensearch client creation in ISM Policy reconciler (#805) ### Description Add retry for opensearch client creation in ISM policy reconciler to fix panic Minor change - Remove extra whitespace in developing.md file ### Issues Resolved Resolves https://github.com/opensearch-project/opensearch-k8s-operator/issues/801 ### Check List - [x] Commits are signed per the DCO using --signoff - [ ] Unittest added for the new/changed functionality and all unit tests are successful - [ ] Customer-visible features documented - [x] No linter warnings (`make lint`) If CRDs are changed: - [ ] CRD YAMLs updated (`make manifests`) and also copied into the helm chart - [ ] Changes to CRDs documented Please refer to the [PR guidelines](https://github.com/opensearch-project/opensearch-k8s-operator/blob/main/docs/developing.md#submitting-a-pr) before submitting this pull request. 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](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin). --------- Signed-off-by: Nilushan Costa (cherry picked from commit ea46394e62ea63f7d997f4ab88d5eae5badf1e3b) --- docs/developing.md | 2 +- opensearch-operator/pkg/reconcilers/ismpolicy.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/developing.md b/docs/developing.md index 253aa35e..c1414758 100644 --- a/docs/developing.md +++ b/docs/developing.md @@ -118,7 +118,7 @@ All PRs must conform to the following rules: * If you make changes to the CRD the CRD YAMLs must be updated (via `make manifests`) and also copied into the helm chart: ```bash - cp opensearch-operator/config/crd/bases/opensearch.opster.io_*.yaml charts/opensearch-operator/files/ + cp opensearch-operator/config/crd/bases/opensearch.opster.io_*.yaml charts/opensearch-operator/files/ ``` * Changes to the CRD must be documented in the [CRD reference](./designs/crd.md) diff --git a/opensearch-operator/pkg/reconcilers/ismpolicy.go b/opensearch-operator/pkg/reconcilers/ismpolicy.go index 53e5cea7..a7c34441 100644 --- a/opensearch-operator/pkg/reconcilers/ismpolicy.go +++ b/opensearch-operator/pkg/reconcilers/ismpolicy.go @@ -146,6 +146,12 @@ func (r *IsmPolicyReconciler) Reconcile() (retResult ctrl.Result, retErr error) if err != nil { reason := "error creating opensearch client" r.recorder.Event(r.instance, "Warning", opensearchError, reason) + retResult = ctrl.Result{ + Requeue: true, + RequeueAfter: 30 * time.Second, + } + retErr = err + return } // If PolicyID not provided explicitly, use metadata.name by default