From 4d8473beda1689a4836f42c499709ab1cc429c2c Mon Sep 17 00:00:00 2001 From: "mykyta.oleksiienko" Date: Wed, 8 Nov 2023 14:12:39 +0200 Subject: [PATCH] issue-545, remove self composing id for the opensearch egress rules --- .../clusterresources/opensearchegressrules_controller.go | 4 ---- pkg/instaclustr/client.go | 4 ++-- pkg/instaclustr/interfaces.go | 2 +- pkg/instaclustr/mock/client.go | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/controllers/clusterresources/opensearchegressrules_controller.go b/controllers/clusterresources/opensearchegressrules_controller.go index fc27e8a6c..7d340c8b5 100644 --- a/controllers/clusterresources/opensearchegressrules_controller.go +++ b/controllers/clusterresources/opensearchegressrules_controller.go @@ -161,10 +161,6 @@ func (r *OpenSearchEgressRulesReconciler) handleCreate(ctx context.Context, l lo } func (r *OpenSearchEgressRulesReconciler) handleDelete(ctx context.Context, logger logr.Logger, rule *clusterresourcesv1beta1.OpenSearchEgressRules) error { - if rule.Status.ID == "" { - rule.Status.ID = fmt.Sprintf("%s~%s~%s", rule.Spec.ClusterID, rule.Spec.Source, rule.Spec.OpenSearchBindingID) - } - _, err := r.API.GetOpenSearchEgressRule(rule.Status.ID) if !errors.Is(err, instaclustr.NotFound) && err != nil { logger.Error(err, "failed to get OpenSearch Egress Rule resource from Instaclustr") diff --git a/pkg/instaclustr/client.go b/pkg/instaclustr/client.go index 5a634d964..a26654881 100644 --- a/pkg/instaclustr/client.go +++ b/pkg/instaclustr/client.go @@ -2356,8 +2356,8 @@ func (c *Client) CreateOpenSearchEgressRules(rule *clusterresourcesv1beta1.OpenS return nil } -func (c *Client) GetOpenSearchEgressRule(id string) (*clusterresourcesv1beta1.OpenSearchEgressRules, error) { - rule := clusterresourcesv1beta1.OpenSearchEgressRules{} +func (c *Client) GetOpenSearchEgressRule(id string) (*clusterresourcesv1beta1.OpenSearchEgressRulesStatus, error) { + rule := clusterresourcesv1beta1.OpenSearchEgressRulesStatus{} url := c.serverHostname + OpenSearchEgressRulesEndpoint + "/" + id resp, err := c.DoRequest(url, http.MethodGet, nil) diff --git a/pkg/instaclustr/interfaces.go b/pkg/instaclustr/interfaces.go index 47a3080c4..d252ef5ef 100644 --- a/pkg/instaclustr/interfaces.go +++ b/pkg/instaclustr/interfaces.go @@ -102,7 +102,7 @@ type API interface { UpdateClusterSettings(clusterID string, settings *models.ClusterSettings) error GetAWSEndpointServicePrincipal(id string) (*models.AWSEndpointServicePrincipal, error) CreateOpenSearchEgressRules(rule *clusterresourcesv1beta1.OpenSearchEgressRules) error - GetOpenSearchEgressRule(id string) (*clusterresourcesv1beta1.OpenSearchEgressRules, error) + GetOpenSearchEgressRule(id string) (*clusterresourcesv1beta1.OpenSearchEgressRulesStatus, error) DeleteOpenSearchEgressRule(id string) error CreateAWSEndpointServicePrincipal(spec any) ([]byte, error) DeleteAWSEndpointServicePrincipal(principalID string) error diff --git a/pkg/instaclustr/mock/client.go b/pkg/instaclustr/mock/client.go index c487a2e24..8e6b15db3 100644 --- a/pkg/instaclustr/mock/client.go +++ b/pkg/instaclustr/mock/client.go @@ -418,7 +418,7 @@ func (c *mockClient) CreateOpenSearchEgressRules(rule *clusterresourcesv1beta1.O panic("CreateOpenSearchEgressRules: is not implemented") } -func (c *mockClient) GetOpenSearchEgressRule(id string) (*clusterresourcesv1beta1.OpenSearchEgressRules, error) { +func (c *mockClient) GetOpenSearchEgressRule(id string) (*clusterresourcesv1beta1.OpenSearchEgressRulesStatus, error) { panic("GetOpenSearchEgressRule: is not implemented") }