From 5b9c71a16d5d10e712943425e06814336360eb9c Mon Sep 17 00:00:00 2001 From: Tharsanan1 Date: Thu, 10 Oct 2024 09:36:10 +0530 Subject: [PATCH] Fix tenant flow for ai subscription ratelimit policy --- apim-apk-agent/internal/k8sClient/k8s_client.go | 3 ++- apim-apk-agent/internal/messaging/notification_listener.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apim-apk-agent/internal/k8sClient/k8s_client.go b/apim-apk-agent/internal/k8sClient/k8s_client.go index 61fa86f1..d23c39b2 100644 --- a/apim-apk-agent/internal/k8sClient/k8s_client.go +++ b/apim-apk-agent/internal/k8sClient/k8s_client.go @@ -22,6 +22,7 @@ import ( "context" "crypto/sha1" "encoding/hex" + "fmt" "strings" dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" @@ -519,7 +520,7 @@ func DeployAIRateLimitPolicyFromCPPolicy(policy eventhubTypes.SubscriptionPolicy crRateLimitPolicies := dpv1alpha3.AIRateLimitPolicy{ ObjectMeta: metav1.ObjectMeta{ - Name: getSha1Value(policy.Name), + Name: getSha1Value(fmt.Sprintf("%s-%s",policy.Name, policy.TenantDomain)), Namespace: conf.DataPlane.Namespace, }, Spec: dpv1alpha3.AIRateLimitPolicySpec{ diff --git a/apim-apk-agent/internal/messaging/notification_listener.go b/apim-apk-agent/internal/messaging/notification_listener.go index 3f00c2c1..e64be632 100644 --- a/apim-apk-agent/internal/messaging/notification_listener.go +++ b/apim-apk-agent/internal/messaging/notification_listener.go @@ -491,7 +491,7 @@ func handlePolicyEvents(data []byte, eventType string, c client.Client) { logger.LoggerMessaging.Infof("Policy: %s for policy type: %s", policyEvent.PolicyName, policyEvent.PolicyType) managementserver.DeleteSubscriptionPolicy(policyEvent.PolicyName, policyEvent.TenantDomain) k8sclient.UnDeploySubscriptionRateLimitPolicyCR(policyEvent.PolicyName, c) - k8sclient.UndeploySubscriptionAIRateLimitPolicyCR(policyEvent.PolicyName, c) + k8sclient.UndeploySubscriptionAIRateLimitPolicyCR(fmt.Sprintf("%s-%s",policyEvent.PolicyName, policyEvent.TenantDomain), c) ratelimitPolicies := managementserver.GetAllRateLimitPolicies() logger.LoggerMessaging.Infof("Rate Limit Policies Internal Map: %v", ratelimitPolicies) }