From 7c513556c546956b0f2f425cf05bcf484978b033 Mon Sep 17 00:00:00 2001 From: yux0 Date: Thu, 15 Jun 2023 14:55:14 -0700 Subject: [PATCH 1/3] Change cluster not found error to unavailable error --- client/clientBean.go | 4 ++-- service/frontend/dcRedirectionPolicy.go | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/clientBean.go b/client/clientBean.go index 329d678402b..857816861c7 100644 --- a/client/clientBean.go +++ b/client/clientBean.go @@ -184,7 +184,7 @@ func (h *clientBeanImpl) GetRemoteAdminClient(cluster string) (adminservice.Admi clusterInfo, clusterFound := h.clusterMetadata.GetAllClusterInfo()[cluster] if !clusterFound { - return nil, &serviceerror.NotFound{ + return nil, &serviceerror.Unavailable{ Message: fmt.Sprintf( "Unknown cluster name: %v with given cluster information map: %v.", cluster, @@ -229,7 +229,7 @@ func (h *clientBeanImpl) GetRemoteFrontendClient(clusterName string) (grpc.Clien clusterInfo, clusterFound := h.clusterMetadata.GetAllClusterInfo()[clusterName] if !clusterFound { - return nil, nil, &serviceerror.NotFound{ + return nil, nil, &serviceerror.Unavailable{ Message: fmt.Sprintf( "Unknown clusterName name: %v with given clusterName information map: %v.", clusterName, diff --git a/service/frontend/dcRedirectionPolicy.go b/service/frontend/dcRedirectionPolicy.go index 8de218e3850..b22cdc1addc 100644 --- a/service/frontend/dcRedirectionPolicy.go +++ b/service/frontend/dcRedirectionPolicy.go @@ -188,8 +188,11 @@ func (policy *SelectedAPIsForwardingRedirectionPolicy) getTargetClusterAndIsName } if len(namespaceEntry.ClusterNames()) == 1 { + //A: ActiveCluster:A ClusterList: [A] + //B: ActiveCluster:A ClusterList: [{A:connected},{B:}] Haifeng + //B: ActiveCluster:A ClusterList: [A] Yu // do not do dc redirection if namespace is only targeting at 1 dc (effectively local namespace) - return policy.currentClusterName, false + return namespaceEntry.ActiveClusterName(), false } if !policy.config.EnableNamespaceNotActiveAutoForwarding(namespaceEntry.Name().String()) { From 6f4f63ac41396ce4d296e112bbd1409f3749d1e7 Mon Sep 17 00:00:00 2001 From: yux0 Date: Thu, 15 Jun 2023 14:56:42 -0700 Subject: [PATCH 2/3] revert change --- service/frontend/dcRedirectionPolicy.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/service/frontend/dcRedirectionPolicy.go b/service/frontend/dcRedirectionPolicy.go index b22cdc1addc..8de218e3850 100644 --- a/service/frontend/dcRedirectionPolicy.go +++ b/service/frontend/dcRedirectionPolicy.go @@ -188,11 +188,8 @@ func (policy *SelectedAPIsForwardingRedirectionPolicy) getTargetClusterAndIsName } if len(namespaceEntry.ClusterNames()) == 1 { - //A: ActiveCluster:A ClusterList: [A] - //B: ActiveCluster:A ClusterList: [{A:connected},{B:}] Haifeng - //B: ActiveCluster:A ClusterList: [A] Yu // do not do dc redirection if namespace is only targeting at 1 dc (effectively local namespace) - return namespaceEntry.ActiveClusterName(), false + return policy.currentClusterName, false } if !policy.config.EnableNamespaceNotActiveAutoForwarding(namespaceEntry.Name().String()) { From 73c88258e9a95a3629dacd1505b72394a1901e75 Mon Sep 17 00:00:00 2001 From: yux0 Date: Fri, 16 Jun 2023 11:15:22 -0700 Subject: [PATCH 3/3] address comments --- client/clientBean.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/client/clientBean.go b/client/clientBean.go index 857816861c7..ccbf0719dd9 100644 --- a/client/clientBean.go +++ b/client/clientBean.go @@ -184,7 +184,11 @@ func (h *clientBeanImpl) GetRemoteAdminClient(cluster string) (adminservice.Admi clusterInfo, clusterFound := h.clusterMetadata.GetAllClusterInfo()[cluster] if !clusterFound { - return nil, &serviceerror.Unavailable{ + // We intentionally return internal error here. + // This error could only happen with internal mis-configuration. + // This can happen when a namespace is config for multiple clusters. But those clusters are not connected. + // We also have logic in task processing to drop tasks when namespace cluster exclude a local cluster. + return nil, &serviceerror.Internal{ Message: fmt.Sprintf( "Unknown cluster name: %v with given cluster information map: %v.", cluster, @@ -229,7 +233,11 @@ func (h *clientBeanImpl) GetRemoteFrontendClient(clusterName string) (grpc.Clien clusterInfo, clusterFound := h.clusterMetadata.GetAllClusterInfo()[clusterName] if !clusterFound { - return nil, nil, &serviceerror.Unavailable{ + // We intentionally return internal error here. + // This error could only happen with internal mis-configuration. + // This can happen when a namespace is config for multiple clusters. But those clusters are not connected. + // We also have logic in task processing to drop tasks when namespace cluster exclude a local cluster. + return nil, nil, &serviceerror.Internal{ Message: fmt.Sprintf( "Unknown clusterName name: %v with given clusterName information map: %v.", clusterName,