diff --git a/service/frontend/operator_handler.go b/service/frontend/operator_handler.go index b9ea1879ba8..5d9ddee1a53 100644 --- a/service/frontend/operator_handler.go +++ b/service/frontend/operator_handler.go @@ -630,6 +630,7 @@ func (h *OperatorHandlerImpl) DeleteNamespace( ConcurrentDeleteExecutionsActivities: h.config.DeleteNamespaceConcurrentDeleteExecutionsActivities(), }, NamespaceDeleteDelay: namespaceDeleteDelay, + CurrentClusterName: h.clusterMetadata.GetCurrentClusterName(), } sdkClient := h.sdkClientFactory.GetSystemClient() diff --git a/service/worker/deletenamespace/workflow.go b/service/worker/deletenamespace/workflow.go index 001c6078231..7e76650bd81 100644 --- a/service/worker/deletenamespace/workflow.go +++ b/service/worker/deletenamespace/workflow.go @@ -26,6 +26,7 @@ package deletenamespace import ( "fmt" + "slices" "strings" "time" @@ -56,6 +57,8 @@ type ( // Default is 0, means, namespace will be deleted immediately. NamespaceDeleteDelay time.Duration + CurrentClusterName string + DeleteExecutionsConfig deleteexecutions.DeleteExecutionsConfig } @@ -104,7 +107,13 @@ func validateParams(params *DeleteNamespaceWorkflowParams) error { return nil } -func validateNamespace(ctx workflow.Context, nsID namespace.ID, nsName namespace.Name, nsClusters []string) error { +func validateNamespace( + ctx workflow.Context, + nsID namespace.ID, + nsName namespace.Name, + currentClusterName string, + nsClusters []string, +) error { if nsName == primitives.SystemLocalNamespace || nsID == primitives.SystemNamespaceID { return errors.NewFailedPrecondition("unable to delete system namespace", nil) @@ -116,7 +125,7 @@ func validateNamespace(ctx workflow.Context, nsID namespace.ID, nsName namespace // - If namespace is active in the current cluster, then it technically can be deleted (and // in this case it will be deleted from this cluster only because delete operation is not replicated), // but this is confusing for the users, as they might expect that namespace is deleted from all clusters. - if len(nsClusters) > 1 { + if len(nsClusters) > 1 && slices.Contains(nsClusters, currentClusterName) { return errors.NewFailedPrecondition(fmt.Sprintf("namespace %s is replicated in several clusters [%s]: remove all other cluster and retry", nsName, strings.Join(nsClusters, ",")), nil) } @@ -170,7 +179,7 @@ func DeleteNamespaceWorkflow(ctx workflow.Context, params DeleteNamespaceWorkflo params.NamespaceID = namespaceInfo.NamespaceID // Step 1.1. Validate namespace. - if err = validateNamespace(ctx, params.NamespaceID, params.Namespace, namespaceInfo.Clusters); err != nil { + if err = validateNamespace(ctx, params.NamespaceID, params.Namespace, params.CurrentClusterName, namespaceInfo.Clusters); err != nil { return result, err }