This is an automated email from the ASF dual-hosted git repository.

mark4z pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go-pixiu.git


The following commit(s) were added to refs/heads/develop by this push:
     new 610c2d68 Fix Control Panel: Feat/service metadata (#570)
610c2d68 is described below

commit 610c2d68bf873a2039206b3bc5b62265b8757339
Author: Mark4z <[email protected]>
AuthorDate: Thu Oct 19 14:17:52 2023 +0800

    Fix Control Panel: Feat/service metadata (#570)
    
    * revert gatewayCmd to Run dubbo go pixiu
    
    * Feat/service metadata fix
    
    * Feat/service metadata fix
    
    * Feat/service metadata fix
    
    * fix snp query panic
    
    * fix buildSnp with namespace
    
    * fix metadata server not start
    
    * Fix ServiceMetadataServer Start
    
    * fix removeOutdatedCRD can not stop
---
 bin/update_crds.sh                                 |  8 +--
 licenses/github.com/MakeNowJust/heredoc/LICENSE    |  2 +-
 .../heredoc => blang/semver/v4}/LICENSE            |  5 +-
 licenses/github.com/shirou/gopsutil/LICENSE        | 61 ---------------------
 licenses/github.com/shirou/gopsutil/v3/LICENSE     |  2 +-
 licenses/github.com/tklauser/numcpus/LICENSE       |  6 +--
 manifests/charts/base/crds/crd-all.gen.yaml        | 60 ---------------------
 manifests/charts/base/files/gen-istio-cluster.yaml | 62 +---------------------
 .../istio-discovery/files/gen-istio.yaml           |  9 ++++
 .../istio-discovery/templates/clusterrole.yaml     |  4 ++
 .../istiod-remote/templates/clusterrole.yaml       |  9 ++++
 .../istiod-remote/templates/crd-all.gen.yaml       | 60 ---------------------
 pilot/pkg/bootstrap/server.go                      | 11 +++-
 .../dubbo/v1alpha1/servicemetadataserver.go        | 27 +++-------
 .../pkg/networking/dubbogen/servicenamemapping.go  | 28 ++++++----
 .../schema/collections/collections.agent.gen.go    |  2 +-
 16 files changed, 71 insertions(+), 285 deletions(-)

diff --git a/bin/update_crds.sh b/bin/update_crds.sh
index e329ab6b..10d98d84 100755
--- a/bin/update_crds.sh
+++ b/bin/update_crds.sh
@@ -29,14 +29,14 @@ SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd 
)"
 ROOTDIR=$(dirname "${SCRIPTPATH}")
 cd "${ROOTDIR}"
 
-REPO="github.com/MasterKenway/operator-api"
+REPO="github.com/istio/api"
 # using the pseudo version we have in go.mod file. e.g. 
v.0.0.0-<timestamp>-<SHA>
 # first check if there's a replace: e.g. replace istio.io/api => 
github.com/USER/istioapi v0.0.0-<timestamp>-<SHA>
-SHA=$(grep "MasterKenway/operator-api" go.mod | grep "^replace" | awk -F "-" 
'{print $NF}')
+SHA=$(grep "istio.io/api" go.mod | grep "^replace" | awk -F "-" '{print $NF}')
 if [ -n "${SHA}" ]; then
-  REPO=$(grep "MasterKenway/operator-api" go.mod | grep "^replace" | awk 
'{print $4}')
+  REPO=$(grep "istio.io/api" go.mod | grep "^replace" | awk '{print $4}')
 else
-  SHA=$(grep "MasterKenway/operator-api" go.mod | head -n1 | awk -F "-" 
'{print $NF}')
+  SHA=$(grep "istio.io/api" go.mod | head -n1 | awk -F "-" '{print $NF}')
 fi
 
 if [ -z "${SHA}" ]; then
diff --git a/licenses/github.com/MakeNowJust/heredoc/LICENSE 
b/licenses/github.com/MakeNowJust/heredoc/LICENSE
index 8a58c222..6d0eb9d5 100644
--- a/licenses/github.com/MakeNowJust/heredoc/LICENSE
+++ b/licenses/github.com/MakeNowJust/heredoc/LICENSE
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright (c) 2014-2017 TSUYUSATO Kitsune
+Copyright (c) 2014-2019 TSUYUSATO Kitsune
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/licenses/github.com/MakeNowJust/heredoc/LICENSE 
b/licenses/github.com/blang/semver/v4/LICENSE
similarity index 92%
copy from licenses/github.com/MakeNowJust/heredoc/LICENSE
copy to licenses/github.com/blang/semver/v4/LICENSE
index 8a58c222..5ba5c86f 100644
--- a/licenses/github.com/MakeNowJust/heredoc/LICENSE
+++ b/licenses/github.com/blang/semver/v4/LICENSE
@@ -1,6 +1,6 @@
-The MIT License (MIT)
+The MIT License
 
-Copyright (c) 2014-2017 TSUYUSATO Kitsune
+Copyright (c) 2014 Benedikt Lang <github at benediktlang.de>
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES 
OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
+
diff --git a/licenses/github.com/shirou/gopsutil/LICENSE 
b/licenses/github.com/shirou/gopsutil/LICENSE
deleted file mode 100644
index da71a5e7..00000000
--- a/licenses/github.com/shirou/gopsutil/LICENSE
+++ /dev/null
@@ -1,61 +0,0 @@
-gopsutil is distributed under BSD license reproduced below.
-
-Copyright (c) 2014, WAKAYAMA Shirou
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without 
modification,
-are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
-   list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
- * Neither the name of the gopsutil authors nor the names of its contributors
-   may be used to endorse or promote products derived from this software 
without
-   specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
--------
-internal/common/binary.go in the gopsutil is copied and modifid from 
golang/encoding/binary.go.
-
-
-
-Copyright (c) 2009 The Go Authors. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-   * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-   * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
-   * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/licenses/github.com/shirou/gopsutil/v3/LICENSE 
b/licenses/github.com/shirou/gopsutil/v3/LICENSE
index da71a5e7..6f06adcb 100644
--- a/licenses/github.com/shirou/gopsutil/v3/LICENSE
+++ b/licenses/github.com/shirou/gopsutil/v3/LICENSE
@@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 -------
-internal/common/binary.go in the gopsutil is copied and modifid from 
golang/encoding/binary.go.
+internal/common/binary.go in the gopsutil is copied and modified from 
golang/encoding/binary.go.
 
 
 
diff --git a/licenses/github.com/tklauser/numcpus/LICENSE 
b/licenses/github.com/tklauser/numcpus/LICENSE
index a2e486a8..d6456956 100644
--- a/licenses/github.com/tklauser/numcpus/LICENSE
+++ b/licenses/github.com/tklauser/numcpus/LICENSE
@@ -1,3 +1,4 @@
+
                                  Apache License
                            Version 2.0, January 2004
                         http://www.apache.org/licenses/
@@ -178,7 +179,7 @@
    APPENDIX: How to apply the Apache License to your work.
 
       To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "{}"
+      boilerplate notice, with the fields enclosed by brackets "[]"
       replaced with your own identifying information. (Don't include
       the brackets!)  The text should be enclosed in the appropriate
       comment syntax for the file format. We also recommend that a
@@ -186,7 +187,7 @@
       same "printed page" as the copyright notice for easier
       identification within third-party archives.
 
-   Copyright {yyyy} Authors of Cilium
+   Copyright [yyyy] [name of copyright owner]
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
@@ -199,4 +200,3 @@
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-
diff --git a/manifests/charts/base/crds/crd-all.gen.yaml 
b/manifests/charts/base/crds/crd-all.gen.yaml
index 31a291a0..cde5582b 100644
--- a/manifests/charts/base/crds/crd-all.gen.yaml
+++ b/manifests/charts/base/crds/crd-all.gen.yaml
@@ -116,66 +116,6 @@ spec:
     subresources:
       status: {}
 
----
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
-metadata:
-  annotations:
-    "helm.sh/resource-policy": keep
-  labels:
-    app: istio-pilot
-    chart: istio
-    heritage: Tiller
-    release: istio
-  name: servicenamemappings.extensions.istio.io
-spec:
-  group: extensions.istio.io
-  names:
-    categories:
-    - istio-io
-    - extensions-istio-io
-    kind: ServiceNameMapping
-    listKind: ServiceNameMappingList
-    plural: servicenamemappings
-    shortNames:
-    - snp
-    singular: servicenamemapping
-  scope: Namespaced
-  versions:
-  - additionalPrinterColumns:
-    - description: 'CreationTimestamp is a timestamp representing the server 
time
-        when this object was created. It is not guaranteed to be set in 
happens-before
-        order across separate operations. Clients may not set this value. It 
is represented
-        in RFC3339 form and is in UTC. Populated by the system. Read-only. 
Null for
-        lists. More info: 
https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata'
-      jsonPath: .metadata.creationTimestamp
-      name: Age
-      type: date
-    name: v1alpha1
-    schema:
-      openAPIV3Schema:
-        properties:
-          spec:
-            description: 'it''s the spec of Service Name Mapping, which is 
used to
-              map the interface name See more details at:'
-            properties:
-              applicationNames:
-                items:
-                  type: string
-                type: array
-              interfaceName:
-                description: InterfaceName.
-                type: string
-            type: object
-          status:
-            type: object
-            x-kubernetes-preserve-unknown-fields: true
-        type: object
-    served: true
-    storage: true
-    subresources:
-      status: {}
-
 ---
 apiVersion: apiextensions.k8s.io/v1
 kind: CustomResourceDefinition
diff --git a/manifests/charts/base/files/gen-istio-cluster.yaml 
b/manifests/charts/base/files/gen-istio-cluster.yaml
index dd40510a..33ae88a1 100644
--- a/manifests/charts/base/files/gen-istio-cluster.yaml
+++ b/manifests/charts/base/files/gen-istio-cluster.yaml
@@ -118,66 +118,6 @@ spec:
     subresources:
       status: {}
 
----
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
-metadata:
-  annotations:
-    "helm.sh/resource-policy": keep
-  labels:
-    app: istio-pilot
-    chart: istio
-    heritage: Tiller
-    release: istio
-  name: servicenamemappings.extensions.istio.io
-spec:
-  group: extensions.istio.io
-  names:
-    categories:
-    - istio-io
-    - extensions-istio-io
-    kind: ServiceNameMapping
-    listKind: ServiceNameMappingList
-    plural: servicenamemappings
-    shortNames:
-    - snp
-    singular: servicenamemapping
-  scope: Namespaced
-  versions:
-  - additionalPrinterColumns:
-    - description: 'CreationTimestamp is a timestamp representing the server 
time
-        when this object was created. It is not guaranteed to be set in 
happens-before
-        order across separate operations. Clients may not set this value. It 
is represented
-        in RFC3339 form and is in UTC. Populated by the system. Read-only. 
Null for
-        lists. More info: 
https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata'
-      jsonPath: .metadata.creationTimestamp
-      name: Age
-      type: date
-    name: v1alpha1
-    schema:
-      openAPIV3Schema:
-        properties:
-          spec:
-            description: 'it''s the spec of Service Name Mapping, which is 
used to
-              map the interface name See more details at:'
-            properties:
-              applicationNames:
-                items:
-                  type: string
-                type: array
-              interfaceName:
-                description: InterfaceName.
-                type: string
-            type: object
-          status:
-            type: object
-            x-kubernetes-preserve-unknown-fields: true
-        type: object
-    served: true
-    storage: true
-    subresources:
-      status: {}
-
 ---
 apiVersion: apiextensions.k8s.io/v1
 kind: CustomResourceDefinition
@@ -6960,7 +6900,7 @@ subjects:
 ---
 # Source: base/templates/default.yaml
 apiVersion: admissionregistration.k8s.io/v1
-kind: Val:wqidatingWebhookConfiguration
+kind: ValidatingWebhookConfiguration
 metadata:
   name: istiod-default-validator
   labels:
diff --git 
a/manifests/charts/istio-control/istio-discovery/files/gen-istio.yaml 
b/manifests/charts/istio-control/istio-discovery/files/gen-istio.yaml
index aef1c70d..5eefd387 100644
--- a/manifests/charts/istio-control/istio-discovery/files/gen-istio.yaml
+++ b/manifests/charts/istio-control/istio-discovery/files/gen-istio.yaml
@@ -1510,6 +1510,15 @@ rules:
   - apiGroups: ["multicluster.x-k8s.io"]
     resources: ["serviceimports"]
     verbs: ["get", "watch", "list"]
+
+  # Used for Service Name Mapping
+  - apiGroups: ["extensions.istio.io"]
+    resources: ["servicenamemappings"]
+    verbs: [ "get", "watch", "list", "update", "patch", "create", "delete" ]
+  # Used for Service Metadata
+  - apiGroups: ["extensions.istio.io"]
+    resources: ["servicemetadatas"]
+    verbs: [ "get", "watch", "list", "update", "patch", "create", "delete" ]
 ---
 # Source: istiod/templates/clusterrole.yaml
 apiVersion: rbac.authorization.k8s.io/v1
diff --git 
a/manifests/charts/istio-control/istio-discovery/templates/clusterrole.yaml 
b/manifests/charts/istio-control/istio-discovery/templates/clusterrole.yaml
index ad408ed2..1671f9dc 100644
--- a/manifests/charts/istio-control/istio-discovery/templates/clusterrole.yaml
+++ b/manifests/charts/istio-control/istio-discovery/templates/clusterrole.yaml
@@ -124,6 +124,10 @@ rules:
   - apiGroups: ["extensions.istio.io"]
     resources: ["servicenamemappings"]
     verbs: [ "get", "watch", "list", "update", "patch", "create", "delete" ]
+  # Used for Service Metadata
+  - apiGroups: ["extensions.istio.io"]
+    resources: ["servicemetadatas"]
+    verbs: [ "get", "watch", "list", "update", "patch", "create", "delete" ]
 ---
 {{- if not (eq (toString 
.Values.pilot.env.PILOT_ENABLE_GATEWAY_API_DEPLOYMENT_CONTROLLER) "false") }}
 apiVersion: rbac.authorization.k8s.io/v1
diff --git a/manifests/charts/istiod-remote/templates/clusterrole.yaml 
b/manifests/charts/istiod-remote/templates/clusterrole.yaml
index 53bfe808..daacd2a9 100644
--- a/manifests/charts/istiod-remote/templates/clusterrole.yaml
+++ b/manifests/charts/istiod-remote/templates/clusterrole.yaml
@@ -120,6 +120,15 @@ rules:
   - apiGroups: ["{{ $mcsAPIGroup }}"]
     resources: ["serviceimports"]
     verbs: ["get", "watch", "list"]
+
+  # Used for Service Name Mapping
+  - apiGroups: ["extensions.istio.io"]
+    resources: ["servicenamemappings"]
+    verbs: [ "get", "watch", "list", "update", "patch", "create", "delete" ]
+  # Used for Service Metadata
+  - apiGroups: ["extensions.istio.io"]
+    resources: ["servicemetadatas"]
+    verbs: [ "get", "watch", "list", "update", "patch", "create", "delete" ]
 ---
 {{- if not (eq (toString 
.Values.pilot.env.PILOT_ENABLE_GATEWAY_API_DEPLOYMENT_CONTROLLER) "false") }}
 apiVersion: rbac.authorization.k8s.io/v1
diff --git a/manifests/charts/istiod-remote/templates/crd-all.gen.yaml 
b/manifests/charts/istiod-remote/templates/crd-all.gen.yaml
index 5c623cf6..6cd20ba3 100644
--- a/manifests/charts/istiod-remote/templates/crd-all.gen.yaml
+++ b/manifests/charts/istiod-remote/templates/crd-all.gen.yaml
@@ -117,66 +117,6 @@ spec:
     subresources:
       status: {}
 
----
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
-metadata:
-  annotations:
-    "helm.sh/resource-policy": keep
-  labels:
-    app: istio-pilot
-    chart: istio
-    heritage: Tiller
-    release: istio
-  name: servicenamemappings.extensions.istio.io
-spec:
-  group: extensions.istio.io
-  names:
-    categories:
-    - istio-io
-    - extensions-istio-io
-    kind: ServiceNameMapping
-    listKind: ServiceNameMappingList
-    plural: servicenamemappings
-    shortNames:
-    - snp
-    singular: servicenamemapping
-  scope: Namespaced
-  versions:
-  - additionalPrinterColumns:
-    - description: 'CreationTimestamp is a timestamp representing the server 
time
-        when this object was created. It is not guaranteed to be set in 
happens-before
-        order across separate operations. Clients may not set this value. It 
is represented
-        in RFC3339 form and is in UTC. Populated by the system. Read-only. 
Null for
-        lists. More info: 
https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata'
-      jsonPath: .metadata.creationTimestamp
-      name: Age
-      type: date
-    name: v1alpha1
-    schema:
-      openAPIV3Schema:
-        properties:
-          spec:
-            description: 'it''s the spec of Service Name Mapping, which is 
used to
-              map the interface name See more details at:'
-            properties:
-              applicationNames:
-                items:
-                  type: string
-                type: array
-              interfaceName:
-                description: InterfaceName.
-                type: string
-            type: object
-          status:
-            type: object
-            x-kubernetes-preserve-unknown-fields: true
-        type: object
-    served: true
-    storage: true
-    subresources:
-      status: {}
-
 ---
 apiVersion: apiextensions.k8s.io/v1
 kind: CustomResourceDefinition
diff --git a/pilot/pkg/bootstrap/server.go b/pilot/pkg/bootstrap/server.go
index 59305712..cc1cec1c 100644
--- a/pilot/pkg/bootstrap/server.go
+++ b/pilot/pkg/bootstrap/server.go
@@ -281,7 +281,7 @@ func NewServer(args *PilotArgs, initFuncs ...func(*Server)) 
(*Server, error) {
        }
 
        if s.kubeClient != nil {
-               s.metadataServer = 
dubbov1alpha1.NewServiceMetadataServer(s.environment, s.kubeClient)
+               s.metadataServer = 
dubbov1alpha1.NewServiceMetadataServer(s.kubeClient)
        }
 
        // Create Service Name mapping server
@@ -665,11 +665,18 @@ func (s *Server) initDiscoveryService(args *PilotArgs) {
 
        // Implement ServiceNameMapping grace shutdown
        s.addStartFunc(func(stop <-chan struct{}) error {
-               log.Infof("Starting ADS server")
+               log.Infof("Starting SNP server")
                s.snpServer.Start(stop)
                return nil
        })
 
+       // Implement ServiceNameMapping grace shutdown
+       s.addStartFunc(func(stop <-chan struct{}) error {
+               log.Infof("Starting MetaData server")
+               s.metadataServer.Start(stop)
+               return nil
+       })
+
        s.initGrpcServer(args.KeepaliveOptions)
 
        if args.ServerOptions.GRPCAddr != "" {
diff --git a/pilot/pkg/networking/dubbo/v1alpha1/servicemetadataserver.go 
b/pilot/pkg/networking/dubbo/v1alpha1/servicemetadataserver.go
index 4907035e..27061a93 100644
--- a/pilot/pkg/networking/dubbo/v1alpha1/servicemetadataserver.go
+++ b/pilot/pkg/networking/dubbo/v1alpha1/servicemetadataserver.go
@@ -101,7 +101,7 @@ func (pr *pushRequest) Merge(other *pushRequest) 
*pushRequest {
        return pr
 }
 
-func NewServiceMetadataServer(env *model.Environment, client kube.Client) 
*ServiceMetadataServer {
+func NewServiceMetadataServer(client kube.Client) *ServiceMetadataServer {
        return &ServiceMetadataServer{
                CommittedUpdates: atomic.NewInt64(0),
                KubeClient:       client,
@@ -115,6 +115,10 @@ func NewServiceMetadataServer(env *model.Environment, 
client kube.Client) *Servi
 }
 
 func (s *ServiceMetadataServer) Start(stopCh <-chan struct{}) {
+       if s == nil {
+               log.Warn("ServiceMetadataServer is not init, skip start")
+               return
+       }
        go s.handleUpdate(stopCh)
        go s.removeOutdatedCRD(stopCh)
 }
@@ -125,14 +129,6 @@ func (s *ServiceMetadataServer) Register(rpcs 
*grpc.Server) {
 }
 
 func (s *ServiceMetadataServer) Publish(ctx context.Context, request 
*dubbov1alpha1.PublishServiceMetadataRequest) 
(*dubbov1alpha1.PublishServiceMetadataResponse, error) {
-       if exists, err := s.isNamespaceExists(ctx, request.GetNamespace()); err 
!= nil {
-               if !exists {
-                       return nil, status.Errorf(codes.Aborted, "Namespace Not 
Exists")
-               }
-       } else {
-               return nil, status.Errorf(codes.Aborted, err.Error())
-       }
-
        pushReq := &pushRequest{ConfigsUpdated: 
map[model.ConfigKey]metadataConfig{}}
 
        key := model.ConfigKey{
@@ -166,16 +162,6 @@ func (s *ServiceMetadataServer) Get(ctx context.Context, 
request *dubbov1alpha1.
        return &dubbov1alpha1.GetServiceMetadataResponse{MetadataInfo: 
metadata.Spec.GetMetadataInfo()}, nil
 }
 
-func (s *ServiceMetadataServer) isNamespaceExists(ctx context.Context, 
namespace string) (bool, error) {
-       _, err := s.KubeClient.Kube().CoreV1().Namespaces().Get(ctx, namespace, 
v1.GetOptions{})
-       if err != nil {
-               if !apierror.IsNotFound(err) {
-                       return false, err
-               }
-       }
-       return true, nil
-}
-
 func (s *ServiceMetadataServer) handleUpdate(stopCh <-chan struct{}) {
        s.debounce(stopCh)
 }
@@ -261,7 +247,8 @@ func (s *ServiceMetadataServer) removeOutdatedCRD(stopChan 
<-chan struct{}) {
                select {
                case <-stopChan:
                        cancel()
-                       break
+                       ticker.Stop()
+                       return
                case <-ticker.C:
                        namespaces, err := 
s.KubeClient.Kube().CoreV1().Namespaces().List(ctx, v1.ListOptions{})
                        if err != nil {
diff --git a/pilot/pkg/networking/dubbogen/servicenamemapping.go 
b/pilot/pkg/networking/dubbogen/servicenamemapping.go
index 62509f47..714038dc 100644
--- a/pilot/pkg/networking/dubbogen/servicenamemapping.go
+++ b/pilot/pkg/networking/dubbogen/servicenamemapping.go
@@ -82,19 +82,17 @@ func buildSnp(node *model.Proxy, req *model.PushRequest, 
watchedResourceNames []
        defaultNs := node.ConfigNamespace
        res := make([]*istioioapidubbov1alpha1.ServiceMappingXdsResponse, 0, 
len(watchedResourceNames))
 
-       watchedResourceNamesMap := map[string]interface{}{}
-       for _, name := range watchedResourceNames {
-               watchedResourceNamesMap[name] = struct{}{}
-       }
        updatedMap := map[string]interface{}{}
        for update, _ := range req.ConfigsUpdated {
-               updatedMap[update.Name] = struct{}{}
+               watchedResourceName := buildNameAndNameSpace(update.Name, 
update.Namespace)
+               updatedMap[watchedResourceName] = struct{}{}
        }
        // if req.ConfigsUpdated is empty, it means that all watched resources 
need to be pushed
        for _, w := range watchedResourceNames {
+               watchedResourceName := buildNameAndNameSpace(w, defaultNs)
                // if configsUpdated empty, meaning a full push of watched snp 
resources.
-               if _, exists := updatedMap[w]; exists || 
len(req.ConfigsUpdated) == 0 {
-                       namespace, snpName := extractNameAndNameSpace(w, 
defaultNs)
+               if _, exists := updatedMap[watchedResourceName]; exists || 
len(req.ConfigsUpdated) == 0 {
+                       snpName, namespace := 
extractNameAndNameSpace(watchedResourceName, defaultNs)
                        if snp := 
req.Push.ServiceNameMappingsByNameSpaceAndInterfaceName(namespace, snpName); 
snp != nil {
                                mapping := 
snp.Spec.(*istioioapiextensionsv1alpha1.ServiceNameMapping)
                                res = append(res, 
&istioioapidubbov1alpha1.ServiceMappingXdsResponse{
@@ -108,10 +106,22 @@ func buildSnp(node *model.Proxy, req *model.PushRequest, 
watchedResourceNames []
        return res
 }
 
+// extractNameAndNameSpace watchedResource should like 
'[a.b.interface]|[namespace]', if namespace is nil,
+// defaultNamespace will be used.
 func extractNameAndNameSpace(watchedResource, defaultNamespace string) 
(string, string) {
        split := strings.Split(watchedResource, "|")
        if len(split) == 1 || split[1] == "" {
-               return defaultNamespace, split[1]
+               return split[0], defaultNamespace
+       }
+       return split[0], split[1]
+}
+
+// buildNameAndNameSpace watchedResource should like 
'[a.b.interface]|[namespace]', if namespace is nil,
+// defaultNamespace will be used.
+func buildNameAndNameSpace(watchedResource, defaultNamespace string) string {
+       split := strings.Split(watchedResource, "|")
+       if len(split) == 1 || split[1] == "" {
+               return strings.Join([]string{split[0], defaultNamespace}, "|")
        }
-       return split[1], split[0]
+       return watchedResource
 }
diff --git a/pkg/config/schema/collections/collections.agent.gen.go 
b/pkg/config/schema/collections/collections.agent.gen.go
index 4b0ac04d..371e4c7a 100755
--- a/pkg/config/schema/collections/collections.agent.gen.go
+++ b/pkg/config/schema/collections/collections.agent.gen.go
@@ -376,8 +376,8 @@ var (
 
        // Istio contains only Istio collections.
        Istio = collection.NewSchemasBuilder().
-               MustAdd(IstioExtensionsV1Alpha1Servicenamemappings).
                MustAdd(IstioExtensionsV1Alpha1Servicemetadatas).
+               MustAdd(IstioExtensionsV1Alpha1Servicenamemappings).
                MustAdd(IstioExtensionsV1Alpha1Wasmplugins).
                MustAdd(IstioMeshV1Alpha1MeshConfig).
                MustAdd(IstioMeshV1Alpha1MeshNetworks).

Reply via email to