This is an automated email from the ASF dual-hosted git repository.
github-actions[bot] pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new e0ff0ed5 Fixed known issues with the control plane (#975)
e0ff0ed5 is described below
commit e0ff0ed555dd25f1277e576110abc4962c5f1ca1
Author: mfordjody <[email protected]>
AuthorDate: Tue Jul 21 22:21:02 2026 +0800
Fixed known issues with the control plane (#975)
* Fix CI startup policy and require quality gate
* Fix blocking lint and license checks
* Fixed known issues with the control plane
---
.asf.yaml | 2 +-
cni/pkg/nodeagent/config.go | 3 +-
cni/pkg/nodeagent/config_test.go | 4 +-
cni/pkg/nodeagent/install.go | 2 +-
cni/pkg/nodeagent/plugin.go | 2 +-
dubboctl/pkg/sdk/tpl/filesystem.go | 201 ---------------------
.../cmd/app/{testproto => testdata}/xds_test.pb.go | 2 +-
.../cmd/app/{testproto => testdata}/xds_test.proto | 0
.../{testproto => testdata}/xds_test_grpc.pb.go | 2 +-
dubbod/discovery/cmd/app/xds_test_grpc.go | 2 +-
.../discovery/pkg/bootstrap/config_controller.go | 10 -
dubbod/discovery/pkg/bootstrap/options.go | 7 -
dubbod/discovery/pkg/bootstrap/server.go | 9 +-
.../config/kube/gateway/deployment_controller.go | 45 -----
.../leaderelection/k8sleaderelection/metrics.go | 12 --
dubbod/discovery/pkg/model/destinationrule.go | 90 ---------
dubbod/discovery/pkg/model/push_context.go | 109 -----------
dubbod/discovery/pkg/model/service.go | 18 --
.../discovery/pkg/networking/grpcgen/mtls_test.go | 17 --
dubbod/discovery/pkg/networking/grpcgen/rds.go | 8 -
.../serviceregistry/kube/controller/controller.go | 21 +--
.../kube/controller/endpoint_builder.go | 1 -
.../kube/controller/endpointslice.go | 15 --
manifests/charts/dubbod/templates/clusterrole.yaml | 4 +
operator/cmd/cluster/uninstall.go | 2 -
pkg/adsc/adsc.go | 2 -
pkg/bootstrap/config.go | 4 +-
pkg/config/schema/resource/schema.go | 7 +-
pkg/kube/controllers/queue.go | 2 -
pkg/kube/inject/webhook.go | 1 -
samples/moviereview/README.md | 20 +-
.../{src/reviews-v2/app.py => build.sh} | 66 +++----
samples/moviereview/src/moviepage/app.py | 18 +-
samples/moviereview/src/reviews-v2/app.py | 7 +-
34 files changed, 81 insertions(+), 634 deletions(-)
diff --git a/.asf.yaml b/.asf.yaml
index 9368bdf1..26b9a477 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -47,4 +47,4 @@ github:
- context: CI Required
app_id: 15368
- context: Maintainer Approval Gate
- app_id: 15368
+ app_id: 15368
\ No newline at end of file
diff --git a/cni/pkg/nodeagent/config.go b/cni/pkg/nodeagent/config.go
index 35e7f415..2ec6dc50 100644
--- a/cni/pkg/nodeagent/config.go
+++ b/cni/pkg/nodeagent/config.go
@@ -26,7 +26,6 @@ import (
)
const (
- defaultCNIVersion = "1.0.0" // 无用版本
defaultStateDir = "/var/run/dubbo-cni"
defaultIPTablesPath = "iptables"
defaultIPSetPath = "ipset"
@@ -61,7 +60,7 @@ func ParseNetConf(data []byte) (NetConf, error) {
}
}
if conf.CNIVersion == "" {
- conf.CNIVersion = defaultCNIVersion
+ conf.CNIVersion = "1.0.0"
}
if conf.ManagedLabel == "" {
conf.ManagedLabel = inject.ProxylessManagedLabel
diff --git a/cni/pkg/nodeagent/config_test.go b/cni/pkg/nodeagent/config_test.go
index b2287cd2..37a04fda 100644
--- a/cni/pkg/nodeagent/config_test.go
+++ b/cni/pkg/nodeagent/config_test.go
@@ -27,8 +27,8 @@ func TestParseNetConfDefaults(t *testing.T) {
if err != nil {
t.Fatalf("ParseNetConf() failed: %v", err)
}
- if conf.CNIVersion != defaultCNIVersion {
- t.Fatalf("cniVersion = %q, want %q", conf.CNIVersion,
defaultCNIVersion)
+ if conf.CNIVersion != "1.0.0" {
+ t.Fatalf("cniVersion = %q, want %q", conf.CNIVersion, "1.0.0")
}
if conf.ManagedLabel != inject.ProxylessManagedLabel ||
conf.ManagedLabelValue != inject.ProxylessManagedLabelValue {
t.Fatalf("managed label = %s/%s, want %s/%s",
conf.ManagedLabel, conf.ManagedLabelValue,
diff --git a/cni/pkg/nodeagent/install.go b/cni/pkg/nodeagent/install.go
index 9b1fd28e..72645e0b 100644
--- a/cni/pkg/nodeagent/install.go
+++ b/cni/pkg/nodeagent/install.go
@@ -377,7 +377,7 @@ func convertConfToConflist(path string, plugin
map[string]any) error {
return fmt.Errorf("stat %s: %w", backupPath, err)
}
conflist := map[string]any{
- "cniVersion": stringValue(cfg["cniVersion"], defaultCNIVersion),
+ "cniVersion": stringValue(cfg["cniVersion"], "1.0.0"),
"name": stringValue(cfg["name"],
strings.TrimSuffix(filepath.Base(path), filepath.Ext(path))),
"plugins": []any{cfg, plugin},
}
diff --git a/cni/pkg/nodeagent/plugin.go b/cni/pkg/nodeagent/plugin.go
index 42f6e706..4251fbdf 100644
--- a/cni/pkg/nodeagent/plugin.go
+++ b/cni/pkg/nodeagent/plugin.go
@@ -145,7 +145,7 @@ func firstPodIP(conf NetConf, pod PodInfo) string {
func versionOutput(cniVersion string) []byte {
if cniVersion == "" {
- cniVersion = defaultCNIVersion
+ cniVersion = "1.0.0"
}
out, _ := json.Marshal(map[string]any{
"cniVersion": cniVersion,
diff --git a/dubboctl/pkg/sdk/tpl/filesystem.go
b/dubboctl/pkg/sdk/tpl/filesystem.go
deleted file mode 100644
index 6208ee87..00000000
--- a/dubboctl/pkg/sdk/tpl/filesystem.go
+++ /dev/null
@@ -1,201 +0,0 @@
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// 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.
-
-package tpl
-
-import (
- "archive/zip"
- "bufio"
- "fmt"
- "io"
- "io/fs"
- "log"
- "os"
- "path/filepath"
-)
-
-const (
- templatesPath = "cli/pkg/sdk/tpl/default"
- generatePath = "cli/pkg/sdk/tpl/zz_filesystem_generated.go"
-)
-
-func main() {
- f, err := os.OpenFile(generatePath, os.O_TRUNC|os.O_CREATE|os.O_WRONLY,
0o644)
- if err != nil {
- log.Fatal(err)
- }
- defer f.Close()
-
- srcOut := bufio.NewWriter(f)
- defer srcOut.Flush()
-
- _, err = fmt.Fprintln(srcOut, `/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * 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.
- */`)
- if err != nil {
- log.Fatal(err)
- }
- _, err = fmt.Fprintln(srcOut, "// Code generated by go generate; DO NOT
EDIT.\npackage generate\n\nvar TemplatesZip = []byte{")
- if err != nil {
- log.Fatal(err)
- }
-
- zipWriter := zip.NewWriter(newGoByteArrayWriter(srcOut))
- buff := make([]byte, 4*1024)
- err = filepath.Walk(templatesPath, func(path string, info fs.FileInfo,
err error) error {
- if err != nil {
- return err
- }
-
- name, err := filepath.Rel(templatesPath, path)
- if err != nil {
- return err
- }
- if name == "." {
- return nil
- }
- name = filepath.ToSlash(name)
- if info.IsDir() {
- name = name + "/"
- }
-
- header := &zip.FileHeader{
- Name: name,
- Method: zip.Deflate,
- }
-
- // Coercing permission to 755 for directories/executables and
to 644 for non-executable files.
- // This is needed to ensure reproducible builds on machines
with different values of `umask`.
- var mode fs.FileMode
- switch {
- case info.Mode()&fs.ModeSymlink != 0:
- mode = 0o777 | fs.ModeSymlink
- case info.IsDir() || (info.Mode().Perm()&0o111) != 0: // dir or
executable
- mode = 0o755
- case info.Mode()&fs.ModeType == 0: // regular file
- mode = 0o644
- default:
- return fmt.Errorf("unsupported file type: %s",
info.Mode().String())
- }
- header.SetMode(mode)
-
- w, err := zipWriter.CreateHeader(header)
- if err != nil {
- return err
- }
-
- switch {
- case info.Mode()&fs.ModeSymlink != 0:
- symlinkTarget, err := os.Readlink(path)
- if err != nil {
- return err
- }
- _, err =
w.Write([]byte(filepath.ToSlash(symlinkTarget)))
- return err
- case info.Mode()&fs.ModeType == 0: // regular file
- f, err := os.Open(path)
- if err != nil {
- return err
- }
- defer f.Close()
-
- _, err = io.CopyBuffer(w, f, buff)
- return err
- default:
- return nil
- }
- })
- _ = zipWriter.Close()
- if err != nil {
- log.Fatal(err)
- }
-
- _, err = fmt.Fprint(srcOut, "\n}\n")
- if err != nil {
- log.Fatal(err)
- }
-}
-
-// goByteArrayWriter dumps bytes as a Go integer hex literals separated by
commas into underlying Writer.
-// Each line of the output will be indented by a tab and each line will
contain at most 32 integer literals.
-// This is useful when generating Go array literals.
-type goByteArrayWriter struct {
- i uint32
- w io.Writer
- hexDigitWithComma []byte
-}
-
-func newGoByteArrayWriter(w io.Writer) *goByteArrayWriter {
- return &goByteArrayWriter{
- i: 0,
- w: w,
- hexDigitWithComma: []byte("0x00,"),
- }
-}
-
-var (
- hexs = []byte("0123456789abcdef")
- space = []byte(" ")
- newLineAndTab = []byte("\n\t")
-)
-
-const bytesInLine = 32
-
-func (g *goByteArrayWriter) Write(bs []byte) (written int, err error) {
- for _, b := range bs {
- if g.i == 0 {
- _, err = g.w.Write(newLineAndTab)
- if err != nil {
- return
- }
- } else {
- _, err = g.w.Write(space)
- if err != nil {
- return
- }
- }
-
- g.hexDigitWithComma[2] = hexs[b>>4]
- g.hexDigitWithComma[3] = hexs[b&0x0f]
- _, err = g.w.Write(g.hexDigitWithComma)
- if err != nil {
- return
- }
-
- if g.i == bytesInLine-1 {
- g.i = 0
- } else {
- g.i++
- }
-
- written += 1
- }
-
- return
-}
diff --git a/dubbod/discovery/cmd/app/testproto/xds_test.pb.go
b/dubbod/discovery/cmd/app/testdata/xds_test.pb.go
similarity index 99%
rename from dubbod/discovery/cmd/app/testproto/xds_test.pb.go
rename to dubbod/discovery/cmd/app/testdata/xds_test.pb.go
index 98f96d4e..8bdf68f0 100644
--- a/dubbod/discovery/cmd/app/testproto/xds_test.pb.go
+++ b/dubbod/discovery/cmd/app/testdata/xds_test.pb.go
@@ -4,7 +4,7 @@
// protoc v6.33.0
// source: dubbod/discovery/cmd/app/testproto/xds_test.proto
-package testproto
+package testdata
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
diff --git a/dubbod/discovery/cmd/app/testproto/xds_test.proto
b/dubbod/discovery/cmd/app/testdata/xds_test.proto
similarity index 100%
rename from dubbod/discovery/cmd/app/testproto/xds_test.proto
rename to dubbod/discovery/cmd/app/testdata/xds_test.proto
diff --git a/dubbod/discovery/cmd/app/testproto/xds_test_grpc.pb.go
b/dubbod/discovery/cmd/app/testdata/xds_test_grpc.pb.go
similarity index 99%
rename from dubbod/discovery/cmd/app/testproto/xds_test_grpc.pb.go
rename to dubbod/discovery/cmd/app/testdata/xds_test_grpc.pb.go
index 22881a7a..77f29acf 100644
--- a/dubbod/discovery/cmd/app/testproto/xds_test_grpc.pb.go
+++ b/dubbod/discovery/cmd/app/testdata/xds_test_grpc.pb.go
@@ -4,7 +4,7 @@
// - protoc v6.33.0
// source: dubbod/discovery/cmd/app/testproto/xds_test.proto
-package testproto
+package testdata
import (
context "context"
diff --git a/dubbod/discovery/cmd/app/xds_test_grpc.go
b/dubbod/discovery/cmd/app/xds_test_grpc.go
index 3c0aa9b3..45bd6358 100644
--- a/dubbod/discovery/cmd/app/xds_test_grpc.go
+++ b/dubbod/discovery/cmd/app/xds_test_grpc.go
@@ -26,7 +26,7 @@ import (
"strings"
"time"
- testproto
"github.com/apache/dubbo-kubernetes/dubbod/discovery/cmd/app/testproto"
+ testproto
"github.com/apache/dubbo-kubernetes/dubbod/discovery/cmd/app/testdata"
"github.com/apache/dubbo-kubernetes/pkg/config/constants"
"github.com/apache/dubbo-kubernetes/pkg/log"
"google.golang.org/grpc"
diff --git a/dubbod/discovery/pkg/bootstrap/config_controller.go
b/dubbod/discovery/pkg/bootstrap/config_controller.go
index dbf2b96f..5c839137 100644
--- a/dubbod/discovery/pkg/bootstrap/config_controller.go
+++ b/dubbod/discovery/pkg/bootstrap/config_controller.go
@@ -27,8 +27,6 @@ import (
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/config/kube/file"
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/config/kube/gateway"
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/config/memory"
- dubboCredentials
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/credentials"
-
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/credentials/kube"
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/features"
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/leaderelection"
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/leaderelection/k8sleaderelection/k8sresourcelock"
@@ -250,14 +248,6 @@ func (s *Server) initConfigController(args *DubboArgs)
error {
return nil
}
-func (s *Server) getRootCertFromSecret(name, namespace string)
(*dubboCredentials.CertInfo, error) {
- secret, err :=
s.kubeClient.Kube().CoreV1().Secrets(namespace).Get(context.Background(), name,
v1.GetOptions{})
- if err != nil {
- return nil, fmt.Errorf("failed to get credential with name %v:
%v", name, err)
- }
- return kube.ExtractRoot(secret.Data)
-}
-
func (s *Server) checkAndRunNonRevisionLeaderElectionIfRequired(args
*DubboArgs, activateCh chan struct{}) {
cm, err :=
s.kubeClient.Kube().CoreV1().ConfigMaps(args.Namespace).Get(context.Background(),
leaderelection.GatewayStatusController, v1.GetOptions{})
diff --git a/dubbod/discovery/pkg/bootstrap/options.go
b/dubbod/discovery/pkg/bootstrap/options.go
index 27943394..c6140ebe 100644
--- a/dubbod/discovery/pkg/bootstrap/options.go
+++ b/dubbod/discovery/pkg/bootstrap/options.go
@@ -22,17 +22,10 @@ import (
kubecontroller
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/serviceregistry/kube/controller"
"github.com/apache/dubbo-kubernetes/pkg/config/constants"
"github.com/apache/dubbo-kubernetes/pkg/ctrlz"
- "github.com/apache/dubbo-kubernetes/pkg/env"
"github.com/apache/dubbo-kubernetes/pkg/keepalive"
"github.com/apache/dubbo-kubernetes/pkg/kube/krt"
)
-var (
- PodNamespace = env.Register("POD_NAMESPACE",
constants.DubboSystemNamespace, "").Get()
- PodName = env.Register("POD_NAME", "", "").Get()
- Revision = env.Register("REVISION", "", "").Get()
-)
-
type RegistryOptions struct {
FileDir string
Registries []string
diff --git a/dubbod/discovery/pkg/bootstrap/server.go
b/dubbod/discovery/pkg/bootstrap/server.go
index 6aeb521b..f5ac8bd0 100644
--- a/dubbod/discovery/pkg/bootstrap/server.go
+++ b/dubbod/discovery/pkg/bootstrap/server.go
@@ -54,7 +54,6 @@ import (
kubelib "github.com/apache/dubbo-kubernetes/pkg/kube"
"github.com/apache/dubbo-kubernetes/pkg/kube/inject"
"github.com/apache/dubbo-kubernetes/pkg/kube/kclient"
- "github.com/apache/dubbo-kubernetes/pkg/kube/krt"
"github.com/apache/dubbo-kubernetes/pkg/kube/multicluster"
"github.com/apache/dubbo-kubernetes/pkg/kube/namespace"
"github.com/apache/dubbo-kubernetes/pkg/log"
@@ -97,8 +96,7 @@ type Server struct {
guiMux *http.ServeMux
httpsMux *http.ServeMux // webhooks
- monitoringMux *http.ServeMux
- metricsExporter http.Handler
+ monitoringMux *http.ServeMux
ConfigStores []model.ConfigStoreController
configController model.ConfigStoreController
@@ -122,16 +120,13 @@ type Server struct {
dnsNames []string
- certMu sync.RWMutex
- internalDebugMux *http.ServeMux
+ certMu sync.RWMutex
readinessProbes map[string]readinessProbe
readinessFlags *readinessFlags
webhookInfo *webhookInfo
- krtDebugger *krt.DebugHandler
-
RWConfigStore model.ConfigStoreController
proxylessGRPCWorkloadController *proxylessGRPCWorkloadController
proxylessGRPCRemoteControllers
*multicluster.Component[*proxylessGRPCClusterController]
diff --git a/dubbod/discovery/pkg/config/kube/gateway/deployment_controller.go
b/dubbod/discovery/pkg/config/kube/gateway/deployment_controller.go
index da8a04e6..e8bc0bba 100644
--- a/dubbod/discovery/pkg/config/kube/gateway/deployment_controller.go
+++ b/dubbod/discovery/pkg/config/kube/gateway/deployment_controller.go
@@ -44,7 +44,6 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/cluster"
"github.com/apache/dubbo-kubernetes/pkg/config"
"github.com/apache/dubbo-kubernetes/pkg/config/constants"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/gvk"
"github.com/apache/dubbo-kubernetes/pkg/config/schema/gvr"
telemetryconfig
"github.com/apache/dubbo-kubernetes/pkg/config/telemetry"
"github.com/apache/dubbo-kubernetes/pkg/kube"
@@ -701,50 +700,6 @@ func formatGatewayServicePorts(ports []corev1.ServicePort)
string {
return strings.Join(out, ",")
}
-func (d *DeploymentController) buildDxgateRuntimeConfig(gw gateway.Gateway)
(string, string, error) {
- routes := d.httpRoutes.List(metav1.NamespaceAll, klabels.Everything())
- services := d.services.List(metav1.NamespaceAll, klabels.Everything())
- backendTLS := d.backendTLSPolicies()
- return buildDxgateRuntimeConfig(gw, routes, services, backendTLS,
d.circuitBreakerPolicyConfigs(), d.domainSuffix())
-}
-
-func (d *DeploymentController) circuitBreakerPolicyConfigs() []config.Config {
- if d.circuitBreakers != nil {
- policies := d.circuitBreakers.List(metav1.NamespaceAll,
klabels.Everything())
- out := make([]config.Config, 0, len(policies))
- for _, policy := range policies {
- out = append(out, config.Config{
- Meta: config.Meta{
- GroupVersionKind:
gvk.CircuitBreakerPolicy,
- Name: policy.Name,
- Namespace: policy.Namespace,
- Labels: policy.Labels,
- Annotations: policy.Annotations,
- ResourceVersion:
policy.ResourceVersion,
- CreationTimestamp:
policy.CreationTimestamp.Time,
- OwnerReferences:
policy.OwnerReferences,
- UID: string(policy.UID),
- Generation: policy.Generation,
- },
- Spec: policy.Spec.DeepCopy(),
- Status: policy.Status.DeepCopy(),
- })
- }
- return out
- }
- if d.env != nil {
- return d.env.List(gvk.CircuitBreakerPolicy, model.NamespaceAll)
- }
- return nil
-}
-
-func (d *DeploymentController) backendTLSPolicies()
[]*gateway.BackendTLSPolicy {
- if d.backendTLS != nil {
- return d.backendTLS.List(metav1.NamespaceAll,
klabels.Everything())
- }
- return nil
-}
-
func buildDxgateRuntimeConfig(gw gateway.Gateway, routes []*gateway.HTTPRoute,
services []*corev1.Service, backendTLSPolicies []*gateway.BackendTLSPolicy,
policies []config.Config, domainSuffix string) (string, string, error) {
if domainSuffix == "" {
domainSuffix = constants.DefaultClusterLocalDomain
diff --git a/dubbod/discovery/pkg/leaderelection/k8sleaderelection/metrics.go
b/dubbod/discovery/pkg/leaderelection/k8sleaderelection/metrics.go
index 5a96507c..8f9a2f07 100644
--- a/dubbod/discovery/pkg/leaderelection/k8sleaderelection/metrics.go
+++ b/dubbod/discovery/pkg/leaderelection/k8sleaderelection/metrics.go
@@ -16,10 +16,6 @@
package k8sleaderelection
-import (
- "sync"
-)
-
// This file provides abstractions for setting the provider (e.g., prometheus)
// of metrics.
@@ -82,14 +78,6 @@ var globalMetricsFactory = leaderMetricsFactory{
type leaderMetricsFactory struct {
metricsProvider MetricsProvider
-
- onlyOnce sync.Once
-}
-
-func (f *leaderMetricsFactory) setProvider(mp MetricsProvider) {
- f.onlyOnce.Do(func() {
- f.metricsProvider = mp
- })
}
func (f *leaderMetricsFactory) newLeaderMetrics() leaderMetricsAdapter {
diff --git a/dubbod/discovery/pkg/model/destinationrule.go
b/dubbod/discovery/pkg/model/destinationrule.go
index 2713f030..81dec258 100644
--- a/dubbod/discovery/pkg/model/destinationrule.go
+++ b/dubbod/discovery/pkg/model/destinationrule.go
@@ -17,102 +17,12 @@
package model
import (
- "github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/features"
"github.com/apache/dubbo-kubernetes/pkg/config"
- "github.com/apache/dubbo-kubernetes/pkg/config/host"
"github.com/apache/dubbo-kubernetes/pkg/config/visibility"
"github.com/apache/dubbo-kubernetes/pkg/util/sets"
- networking "github.com/kdubbo/api/networking/v1alpha3"
"k8s.io/apimachinery/pkg/types"
)
-func (ps *PushContext) mergeDestinationRule(p *consolidatedSubRules,
subRuleConfig config.Config, exportToSet sets.Set[visibility.Instance]) {
- rule := subRuleConfig.Spec.(*networking.DestinationRule)
- resolvedHost := host.Name(rule.Host)
-
- var subRules map[host.Name][]*ConsolidatedSubRule
-
- if resolvedHost.IsWildCarded() {
- subRules = p.wildcardSubRules
- } else {
- subRules = p.specificSubRules
- }
-
- if mdrList, exists := subRules[resolvedHost]; exists {
- log.Infof("found existing rules for host %s (count: %d)",
resolvedHost, len(mdrList))
- // `appendSeparately` determines if the incoming destination
rule would become a new unique entry in the processedDestRules list.
- appendSeparately := true
- for _, mdr := range mdrList {
- if features.EnableEnhancedDestinationRuleMerge {
- // Merge when exportTo matches or the new
exportTo is a superset of the
- // existing one; otherwise append as a
standalone entry.
- canMerge := exportToSet.Equals(mdr.exportTo) ||
- (len(mdr.exportTo) > 0 &&
exportToSet.SupersetOf(mdr.exportTo))
- if !canMerge {
- appendSeparately = true
- continue
- }
- }
-
- // Merge destination rules for the same host
- appendSeparately = false
- log.Debugf("will merge rules for host %s", resolvedHost)
-
- // Deep copy destination rule, to prevent mutate it
later when merge with a new one.
- // This can happen when there are more than one
destination rule of same host in one namespace.
- copied := mdr.rule.DeepCopy()
- mdr.rule = &copied
- mdr.from = append(mdr.from,
subRuleConfig.NamespacedName())
- mergedRule := copied.Spec.(*networking.DestinationRule)
-
- existingSubset := sets.String{}
- for _, subset := range mergedRule.Subsets {
- existingSubset.Insert(subset.Name)
- }
- // we have another destination rule for same host.
- // concatenate both of them -- essentially add subsets
from one to other.
- // Note: we only add the subsets and do not overwrite
anything else like exportTo or top level
- // traffic policies if they already exist
- for _, subset := range rule.Subsets {
- if !existingSubset.Contains(subset.Name) {
- // if not duplicated, append
- mergedRule.Subsets =
append(mergedRule.Subsets, subset)
- }
- }
-
- // Merge top-level traffic policy. Historically we only
copied the first non-nil policy,
- // which meant a later DestinationRule that supplied
TLS settings was ignored once a prior
- // rule (e.g. subsets only) existed. To match Dubbo's
behavior and ensure Proxyless gRPC
- // can enable mTLS after subsets are defined, allow the
incoming rule to override the TLS
- // portion even when a Common TrafficPolicy already
exists.
- if rule.TrafficPolicy != nil {
- if mergedRule.TrafficPolicy == nil {
- // First rule with TrafficPolicy, copy
it entirely
- mergedRule.TrafficPolicy =
rule.TrafficPolicy
- log.Infof("copied TrafficPolicy from
new rule to merged rule for host %s (has TLS: %v)",
- resolvedHost,
rule.TrafficPolicy.Tls != nil)
- } else {
- // Merge TrafficPolicy fields, with TLS
settings from the latest rule taking precedence
- if rule.TrafficPolicy.Tls != nil {
- // TLS settings from the latest
rule always win (DUBBO_MUTUAL)
- mergedRule.TrafficPolicy.Tls =
rule.TrafficPolicy.Tls
- log.Infof("updated TLS settings
in merged TrafficPolicy for host %s (mode: %v)",
- resolvedHost,
rule.TrafficPolicy.Tls.Mode)
- }
- // Merge other TrafficPolicy fields if
needed (loadBalancer, connectionPool, etc.)
- // For now, we only merge TLS as it's
the critical setting for mTLS
- }
- }
- }
- if appendSeparately {
- subRules[resolvedHost] = append(subRules[resolvedHost],
ConvertConsolidatedDestRule(&subRuleConfig, exportToSet))
- }
- return
- }
- // DestinationRule does not exist for the resolved host so add it
- subRules[resolvedHost] = append(subRules[resolvedHost],
ConvertConsolidatedDestRule(&subRuleConfig, exportToSet))
-}
-
func ConvertConsolidatedDestRule(cfg *config.Config, exportToSet
sets.Set[visibility.Instance]) *ConsolidatedSubRule {
return &ConsolidatedSubRule{
exportTo: exportToSet,
diff --git a/dubbod/discovery/pkg/model/push_context.go
b/dubbod/discovery/pkg/model/push_context.go
index 88725024..99d3affe 100644
--- a/dubbod/discovery/pkg/model/push_context.go
+++ b/dubbod/discovery/pkg/model/push_context.go
@@ -19,7 +19,6 @@ package model
import (
"cmp"
"encoding/json"
- "sort"
"strings"
"sync"
"time"
@@ -172,7 +171,6 @@ type destinationRuleIndex struct {
type consolidatedSubRules struct {
specificSubRules map[host.Name][]*ConsolidatedSubRule
- wildcardSubRules map[host.Name][]*ConsolidatedSubRule
}
func NewPushContext() *PushContext {
@@ -211,13 +209,6 @@ func newDestinationRuleIndex() destinationRuleIndex {
}
}
-func newConsolidatedDestRules() *consolidatedSubRules {
- return &consolidatedSubRules{
- specificSubRules: map[host.Name][]*ConsolidatedSubRule{},
- wildcardSubRules: map[host.Name][]*ConsolidatedSubRule{},
- }
-}
-
func NewReasonStats(reasons ...TriggerReason) ReasonStats {
ret := make(ReasonStats)
for _, reason := range reasons {
@@ -932,106 +923,6 @@ func backendTLSPolicyServiceKey(namespace, name string)
string {
return namespace + "/" + name
}
-// sortConfigBySelectorAndCreationTime sorts the list of config objects based
on creation time.
-func sortConfigBySelectorAndCreationTime(configs []config.Config)
[]config.Config {
- sort.Slice(configs, func(i, j int) bool {
- // Sort by creation time ordering
- if r :=
configs[i].CreationTimestamp.Compare(configs[j].CreationTimestamp); r != 0 {
- return r == -1 // -1 means i is less than j, so return
true.
- }
- if r := cmp.Compare(configs[i].Name, configs[j].Name); r != 0 {
- return r == -1
- }
- return cmp.Compare(configs[i].Namespace, configs[j].Namespace)
== -1
- })
- return configs
-}
-
-func (ps *PushContext) setDestinationRules(configs []config.Config) {
- sortConfigBySelectorAndCreationTime(configs)
-
- namespaceLocalSubRules := make(map[string]*consolidatedSubRules)
- exportedDestRulesByNamespace := make(map[string]*consolidatedSubRules)
- rootNamespaceLocalDestRules := newConsolidatedDestRules()
-
- for i := range configs {
- rule := configs[i].Spec.(*networking.DestinationRule)
-
- rule.Host = string(ResolveShortnameToFQDN(rule.Host,
configs[i].Meta))
- exportToSet :=
sets.NewWithLength[visibility.Instance](len(rule.ExportTo))
- for _, e := range rule.ExportTo {
- exportToSet.Insert(visibility.Instance(e))
- }
-
- // add only if the dest rule is exported with . or * or
explicit exportTo containing this namespace
- // The global exportTo doesn't matter here (its either . or * -
both of which are applicable here)
- if exportToSet.IsEmpty() ||
exportToSet.Contains(visibility.Public) ||
exportToSet.Contains(visibility.Private) ||
-
exportToSet.Contains(visibility.Instance(configs[i].Namespace)) {
- // Store in an index for the config's namespace
- // a proxy from this namespace will first look here for
the destination rule for a given service
- // This pool consists of both public/private
destination rules.
- if _, exist :=
namespaceLocalSubRules[configs[i].Namespace]; !exist {
- namespaceLocalSubRules[configs[i].Namespace] =
newConsolidatedDestRules()
- }
- // Merge this destination rule with any public/private
dest rules for same host in the same namespace
- // If there are no duplicates, the dest rule will be
added to the list
-
ps.mergeDestinationRule(namespaceLocalSubRules[configs[i].Namespace],
configs[i], exportToSet)
- }
-
- isPrivateOnly := false
- // No exportTo in destinationRule. Use the global default
- // We only honor . and *
- if exportToSet.IsEmpty() &&
ps.exportToDefaults.destinationRule.Contains(visibility.Private) {
- isPrivateOnly = true
- } else if exportToSet.Len() == 1 &&
(exportToSet.Contains(visibility.Private) ||
exportToSet.Contains(visibility.Instance(configs[i].Namespace))) {
- isPrivateOnly = true
- }
-
- if !isPrivateOnly {
- if _, exist :=
exportedDestRulesByNamespace[configs[i].Namespace]; !exist {
-
exportedDestRulesByNamespace[configs[i].Namespace] = newConsolidatedDestRules()
- }
-
ps.mergeDestinationRule(exportedDestRulesByNamespace[configs[i].Namespace],
configs[i], exportToSet)
- } else if configs[i].Namespace == ps.Mesh.RootNamespace {
- ps.mergeDestinationRule(rootNamespaceLocalDestRules,
configs[i], exportToSet)
- }
- }
-
- ps.destinationRuleIndex.namespaceLocal = namespaceLocalSubRules
- ps.destinationRuleIndex.exportedByNamespace =
exportedDestRulesByNamespace
- ps.destinationRuleIndex.rootNamespaceLocal = rootNamespaceLocalDestRules
-
- // Log indexing results
- log.Debugf("indexed %d namespaces with local rules",
len(namespaceLocalSubRules))
- for ns, rules := range namespaceLocalSubRules {
- totalRules := 0
- for hostname, ruleList := range rules.specificSubRules {
- totalRules += len(ruleList)
- // Log TLS configuration for each merged DestinationRule
- for _, rule := range ruleList {
- if dr, ok :=
rule.rule.Spec.(*networking.DestinationRule); ok {
- hasTLS := dr.TrafficPolicy != nil &&
dr.TrafficPolicy.Tls != nil
- tlsMode := "none"
- if hasTLS {
- tlsMode =
dr.TrafficPolicy.Tls.Mode.String()
- }
- log.Debugf("namespace %s, hostname %s:
DestinationRule has %d subsets, TLS mode: %s",
- ns, hostname, len(dr.Subsets),
tlsMode)
- }
- }
- }
- log.Debugf("namespace %s has %d DestinationRules with %d
specific hostnames", ns, totalRules, len(rules.specificSubRules))
- }
- log.Debugf("indexed %d namespaces with exported rules",
len(exportedDestRulesByNamespace))
- if rootNamespaceLocalDestRules != nil {
- totalRootRules := 0
- for _, ruleList := range
rootNamespaceLocalDestRules.specificSubRules {
- totalRootRules += len(ruleList)
- }
- log.Debugf("root namespace has %d DestinationRules with %d
specific hostnames", totalRootRules,
len(rootNamespaceLocalDestRules.specificSubRules))
- }
-}
-
// ServiceAccounts returns the SPIFFE identities associated with the workloads
// backing the given service hostname in the given namespace. The returned list
// is sorted and already expanded with trust domain aliases.
diff --git a/dubbod/discovery/pkg/model/service.go
b/dubbod/discovery/pkg/model/service.go
index df5a49f7..2914ccfe 100644
--- a/dubbod/discovery/pkg/model/service.go
+++ b/dubbod/discovery/pkg/model/service.go
@@ -31,7 +31,6 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/maps"
"github.com/apache/dubbo-kubernetes/pkg/slices"
"github.com/apache/dubbo-kubernetes/pkg/util/sets"
- "github.com/google/go-cmp/cmp"
)
type Resolution int
@@ -174,23 +173,6 @@ type DubboEndpoint struct {
NodeName string
}
-type endpointDiscoverabilityPolicyImpl struct {
- name string
- f func(*DubboEndpoint, *Proxy) bool
-}
-
-func (p *endpointDiscoverabilityPolicyImpl) String() string {
- return p.name
-}
-
-var endpointDiscoverabilityPolicyImplCmpOpt = cmp.Comparer(func(x, y
endpointDiscoverabilityPolicyImpl) bool {
- return x.String() == y.String()
-})
-
-func (p *endpointDiscoverabilityPolicyImpl) CmpOpts() []cmp.Option {
- return []cmp.Option{endpointDiscoverabilityPolicyImplCmpOpt}
-}
-
func (ep *DubboEndpoint) FirstAddressOrNil() string {
if ep == nil || len(ep.Addresses) == 0 {
return ""
diff --git a/dubbod/discovery/pkg/networking/grpcgen/mtls_test.go
b/dubbod/discovery/pkg/networking/grpcgen/mtls_test.go
index f6338f20..dfa0eef5 100644
--- a/dubbod/discovery/pkg/networking/grpcgen/mtls_test.go
+++ b/dubbod/discovery/pkg/networking/grpcgen/mtls_test.go
@@ -23,7 +23,6 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/config/schema/gvk"
"github.com/apache/dubbo-kubernetes/pkg/grpcxds"
security "github.com/kdubbo/api/security/v1alpha3"
- cluster "github.com/kdubbo/xds-api/cluster/v1"
tlsv1 "github.com/kdubbo/xds-api/extensions/transport_sockets/tls/v1"
listener "github.com/kdubbo/xds-api/listener/v1"
)
@@ -162,22 +161,6 @@ func newPeerAuthenticationConfig(name, namespace string,
mode security.PeerAuthe
}
}
-func findCluster(t *testing.T, resources model.Resources, name string)
*cluster.Cluster {
- t.Helper()
- for _, resource := range resources {
- if resource.Name != name {
- continue
- }
- c := &cluster.Cluster{}
- if err := resource.Resource.UnmarshalTo(c); err != nil {
- t.Fatalf("unmarshal cluster %s: %v", name, err)
- }
- return c
- }
- t.Fatalf("cluster %s not found in %d resources", name, len(resources))
- return nil
-}
-
func findListener(t *testing.T, resources model.Resources, name string)
*listener.Listener {
t.Helper()
for _, resource := range resources {
diff --git a/dubbod/discovery/pkg/networking/grpcgen/rds.go
b/dubbod/discovery/pkg/networking/grpcgen/rds.go
index 796137c7..42d6f5bf 100644
--- a/dubbod/discovery/pkg/networking/grpcgen/rds.go
+++ b/dubbod/discovery/pkg/networking/grpcgen/rds.go
@@ -330,14 +330,6 @@ func defaultSingleClusterRoute(clusterName string)
*route.Route {
}
}
-func defaultRouteMatch() *route.RouteMatch {
- return &route.RouteMatch{
- PathSpecifier: &route.RouteMatch_Prefix{
- Prefix: "/",
- },
- }
-}
-
// buildRoutesFromGatewayHTTPRoute converts Gateway API HTTPRoute resources to
XDS Route configurations
func buildRoutesFromGatewayHTTPRoute(httpRoutes []config.Config, hostName
host.Name, defaultPort int) []*route.Route {
if len(httpRoutes) == 0 {
diff --git a/dubbod/discovery/pkg/serviceregistry/kube/controller/controller.go
b/dubbod/discovery/pkg/serviceregistry/kube/controller/controller.go
index 1db2150b..13152782 100644
--- a/dubbod/discovery/pkg/serviceregistry/kube/controller/controller.go
+++ b/dubbod/discovery/pkg/serviceregistry/kube/controller/controller.go
@@ -17,12 +17,13 @@
package controller
import (
- "github.com/apache/dubbo-kubernetes/pkg/util/ptr"
"sort"
"strings"
"sync"
"time"
+ "github.com/apache/dubbo-kubernetes/pkg/util/ptr"
+
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/model"
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/serviceregistry"
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/serviceregistry/aggregate"
@@ -40,10 +41,8 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/kube/krt"
"github.com/apache/dubbo-kubernetes/pkg/queue"
"github.com/apache/dubbo-kubernetes/pkg/slices"
- "github.com/hashicorp/go-multierror"
"go.uber.org/atomic"
v1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
klabels "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
@@ -126,15 +125,6 @@ func (c *Controller) onSystemNamespaceEvent(_, ns
*v1.Namespace, ev model.Event)
return nil
}
-func (c *Controller) syncPods() error {
- var err *multierror.Error
- pods := c.podsClient.List(metav1.NamespaceAll, klabels.Everything())
- for _, s := range pods {
- err = multierror.Append(err, c.pods.onEvent(nil, s,
model.EventAdd))
- }
- return err.ErrorOrNil()
-}
-
type Options struct {
KubernetesAPIQPS float32
KubernetesAPIBurst int
@@ -513,10 +503,3 @@ func registerHandlers[T controllers.ComparableObject](c
*Controller,
},
})
}
-
-func (c *Controller) servicesForNamespacedName(name types.NamespacedName)
[]*model.Service {
- if svc := c.GetService(kube.ServiceHostname(name.Name, name.Namespace,
c.opts.DomainSuffix)); svc != nil {
- return []*model.Service{svc}
- }
- return nil
-}
diff --git
a/dubbod/discovery/pkg/serviceregistry/kube/controller/endpoint_builder.go
b/dubbod/discovery/pkg/serviceregistry/kube/controller/endpoint_builder.go
index 8366a1b5..c30dff97 100644
--- a/dubbod/discovery/pkg/serviceregistry/kube/controller/endpoint_builder.go
+++ b/dubbod/discovery/pkg/serviceregistry/kube/controller/endpoint_builder.go
@@ -26,7 +26,6 @@ import (
type EndpointBuilder struct {
labels labels.Instance
serviceAccount string
- workloadName string
namespace string
hostname string
subDomain string
diff --git
a/dubbod/discovery/pkg/serviceregistry/kube/controller/endpointslice.go
b/dubbod/discovery/pkg/serviceregistry/kube/controller/endpointslice.go
index 17e8fa35..5077e28b 100644
--- a/dubbod/discovery/pkg/serviceregistry/kube/controller/endpointslice.go
+++ b/dubbod/discovery/pkg/serviceregistry/kube/controller/endpointslice.go
@@ -26,7 +26,6 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/config/schema/kind"
"github.com/apache/dubbo-kubernetes/pkg/kube/kclient"
"github.com/apache/dubbo-kubernetes/pkg/util/sets"
- "github.com/hashicorp/go-multierror"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/discovery/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -164,20 +163,6 @@ func (esc *endpointSliceController)
updateEndpointSlice(slice *v1.EndpointSlice)
}
}
-func (esc *endpointSliceController) initializeNamespace(ns string, filtered
bool) error {
- var err *multierror.Error
- var endpoints []*v1.EndpointSlice
- if filtered {
- endpoints = esc.slices.List(ns, klabels.Everything())
- } else {
- endpoints = esc.slices.ListUnfiltered(ns, klabels.Everything())
- }
- for _, s := range endpoints {
- err = multierror.Append(err, esc.onEvent(nil, s,
model.EventAdd))
- }
- return err.ErrorOrNil()
-}
-
func (esc *endpointSliceController) updateEndpointCacheForSlice(hostName
host.Name, epSlice *v1.EndpointSlice) {
var endpoints []*model.DubboEndpoint
if epSlice.AddressType == v1.AddressTypeFQDN {
diff --git a/manifests/charts/dubbod/templates/clusterrole.yaml
b/manifests/charts/dubbod/templates/clusterrole.yaml
index 4f0afd13..7e012f17 100644
--- a/manifests/charts/dubbod/templates/clusterrole.yaml
+++ b/manifests/charts/dubbod/templates/clusterrole.yaml
@@ -24,6 +24,9 @@ rules:
- apiGroups: [ "networking.dubbo.apache.org" ]
verbs: [ "get", "watch", "list" ]
resources: [ "*" ]
+ - apiGroups: [ "telemetry.dubbo.apache.org" ]
+ verbs: [ "get", "watch", "list" ]
+ resources: [ "*" ]
- apiGroups: ["admissionregistration.k8s.io"]
resources: ["mutatingwebhookconfigurations"]
verbs: ["get", "list", "watch", "update", "patch"]
@@ -63,6 +66,7 @@ rules:
- gatewayclasses
- httproutes
- backendtlspolicies
+ - referencegrants
verbs:
- get
- list
diff --git a/operator/cmd/cluster/uninstall.go
b/operator/cmd/cluster/uninstall.go
index fe009821..d8934cfa 100644
--- a/operator/cmd/cluster/uninstall.go
+++ b/operator/cmd/cluster/uninstall.go
@@ -35,8 +35,6 @@ type uninstallArgs struct {
// filenames string
// sets is a string with the format "path=value".
sets []string
- // manifestPath is a path to a charts and profiles directory in the
local filesystem with a release tgz.
- manifestPath string
// purge results in deletion of all Dubbo resources.
purge bool
// skipConfirmation determines whether the user is prompted for
confirmation.
diff --git a/pkg/adsc/adsc.go b/pkg/adsc/adsc.go
index 63e9e4c4..19492577 100644
--- a/pkg/adsc/adsc.go
+++ b/pkg/adsc/adsc.go
@@ -118,8 +118,6 @@ type ADSC struct {
initialLds bool
// httpListeners contains received listeners with a
http_connection_manager filter.
httpListeners map[string]*listener.Listener
- // tcpListeners contains all listeners of type TCP (not-HTTP)
- tcpListeners map[string]*listener.Listener
// All received clusters of type eds, keyed by name
edsClusters map[string]*cluster.Cluster
// All received clusters of no-eds type, keyed by name
diff --git a/pkg/bootstrap/config.go b/pkg/bootstrap/config.go
index 8ed542e2..deef5718 100644
--- a/pkg/bootstrap/config.go
+++ b/pkg/bootstrap/config.go
@@ -19,11 +19,12 @@ package bootstrap
import (
"encoding/json"
"fmt"
- "github.com/apache/dubbo-kubernetes/pkg/util/ptr"
"os"
"strconv"
"strings"
+ "github.com/apache/dubbo-kubernetes/pkg/util/ptr"
+
"github.com/apache/dubbo-kubernetes/pkg/config/constants"
"github.com/apache/dubbo-kubernetes/pkg/model"
"github.com/apache/dubbo-kubernetes/pkg/security"
@@ -50,7 +51,6 @@ type MetadataOptions struct {
DubboSubjectAltName []string
CredentialSocketExists bool
XDSRootCert string
- annotationFilePath string
MetadataDiscovery *bool
Envs []string
}
diff --git a/pkg/config/schema/resource/schema.go
b/pkg/config/schema/resource/schema.go
index d2cdc86d..11fc57ca 100644
--- a/pkg/config/schema/resource/schema.go
+++ b/pkg/config/schema/resource/schema.go
@@ -19,6 +19,8 @@ package resource
import (
"errors"
"fmt"
+ "reflect"
+
"github.com/apache/dubbo-kubernetes/pkg/config"
"github.com/apache/dubbo-kubernetes/pkg/config/labels"
"github.com/apache/dubbo-kubernetes/pkg/config/validation"
@@ -26,7 +28,6 @@ import (
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
"k8s.io/apimachinery/pkg/runtime/schema"
- "reflect"
)
var protoMessageType = protoregistry.GlobalTypes.FindMessageByName
@@ -166,10 +167,6 @@ type schemaImpl struct {
statusPackage string
identifier string
synthetic bool
-
- variableName string
- resource Schema
- name config.GroupVersionKind
}
// Build a Schema instance.
diff --git a/pkg/kube/controllers/queue.go b/pkg/kube/controllers/queue.go
index 8c4a683d..6dda796f 100644
--- a/pkg/kube/controllers/queue.go
+++ b/pkg/kube/controllers/queue.go
@@ -18,7 +18,6 @@ package controllers
import (
"github.com/apache/dubbo-kubernetes/pkg/config"
- dubbolog "github.com/apache/dubbo-kubernetes/pkg/log"
"go.uber.org/atomic"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/util/workqueue"
@@ -37,7 +36,6 @@ type Queue struct {
maxAttempts int
workFn func(key any) error
closed chan struct{}
- log *dubbolog.Scope
}
func NewQueue(name string, options ...func(*Queue)) Queue {
diff --git a/pkg/kube/inject/webhook.go b/pkg/kube/inject/webhook.go
index 540c20e2..f9629327 100644
--- a/pkg/kube/inject/webhook.go
+++ b/pkg/kube/inject/webhook.go
@@ -93,7 +93,6 @@ type ValuesConfig struct {
type InjectionParameters struct {
pod *corev1.Pod
deployMeta types.NamespacedName
- namespace *corev1.Namespace
typeMeta metav1.TypeMeta
templates map[string]*template.Template
defaultTemplate []string
diff --git a/samples/moviereview/README.md b/samples/moviereview/README.md
index ee875203..803e7743 100644
--- a/samples/moviereview/README.md
+++ b/samples/moviereview/README.md
@@ -1,9 +1,27 @@
## moviereview example
+moviepage / details / reviews(v1,v2,v3) / ratings 六个服务,应用代码本身是裸 HTTP、监听
9080,不依赖任何 Dubbo SDK。
+
+**这个示例必须在开启注入的 namespace 里运行。** 注入后 CNI 会拦截 pod 入站流量,
+9080 对 kubelet 不可达,健康检查只能走 sidecar 的 15080 端口 —— `deployment.yaml`
+里的探针端口就是按这个前提写的。不打注入标签,Pod 会因为探针失败而反复重启。
+
+### 构建镜像
+
+```bash
+samples/moviereview/build.sh # 构建到本地
+HUB=kdubbo TAG=latest PUSH=true samples/moviereview/build.sh # 构建并推送
+PLATFORM=linux/amd64 samples/moviereview/build.sh # 集群节点架构与本机不一致时
+```
+
+### 部署
+
```bash
kubectl create ns moviereview
+kubectl label ns moviereview dubbo-injection=enabled # 必需
kubectl apply -f samples/moviereview/deployment.yaml
+kubectl -n moviereview rollout status deploy/moviepage
kubectl -n moviereview get svc frontend
```
-访问 `http://<NodeIP>:30080`。
+访问 `http://<NodeIP>:30980`。
diff --git a/samples/moviereview/src/reviews-v2/app.py
b/samples/moviereview/build.sh
old mode 100644
new mode 100755
similarity index 50%
copy from samples/moviereview/src/reviews-v2/app.py
copy to samples/moviereview/build.sh
index ede89f5f..3a45f945
--- a/samples/moviereview/src/reviews-v2/app.py
+++ b/samples/moviereview/build.sh
@@ -1,3 +1,4 @@
+#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
@@ -13,45 +14,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import os
-
-import requests
-from flask import Flask, jsonify
-
-
-app = Flask(__name__)
-RATINGS_URL = os.getenv("RATINGS_URL", "http://ratings:9080/ratings")
-
-
-def rating():
- response = requests.get(RATINGS_URL, params={"movieId": "movie-1"},
timeout=2)
- response.raise_for_status()
- return response.json()
-
-
[email protected]("/healthz")
-def healthz():
- return "ok\n"
-
-
[email protected]("/")
-def root():
- return "reviews v2\n"
-
-
[email protected]("/reviews")
-def reviews():
- return jsonify(
- {
- "version": "v2",
- "items": [
- "人物关系更清晰。",
- "这个版本会调用 ratings 服务。"
- ],
- "rating": rating(),
- }
- )
-
-
-if __name__ == "__main__":
- app.run(host="0.0.0.0", port=9080)
+set -euo pipefail
+
+HUB="${HUB:-kdubbo}"
+TAG="${TAG:-latest}"
+PUSH="${PUSH:-false}"
+# 目标节点架构,与集群节点不一致时必须显式指定,例如 PLATFORM=linux/amd64。
+PLATFORM="${PLATFORM:-}"
+
+cd "$(dirname "${BASH_SOURCE[0]}")/src"
+
+build_args=()
+if [[ -n "${PLATFORM}" ]]; then
+ build_args+=(--platform "${PLATFORM}")
+fi
+
+for svc in moviepage details ratings reviews-v1 reviews-v2 reviews-v3; do
+ image="${HUB}/moviereview-${svc}:${TAG}"
+ echo "==> building ${image}"
+ docker build "${build_args[@]}" -t "${image}" "${svc}"
+ if [[ "${PUSH}" == "true" ]]; then
+ docker push "${image}"
+ fi
+done
diff --git a/samples/moviereview/src/moviepage/app.py
b/samples/moviereview/src/moviepage/app.py
index eb8f05eb..c2120779 100644
--- a/samples/moviereview/src/moviepage/app.py
+++ b/samples/moviereview/src/moviepage/app.py
@@ -35,15 +35,17 @@ def forward_headers():
return headers
+# Returns (data, ok). The caller must propagate ok into the HTTP status so that
+# an upstream failure stays visible to probes, load generators and the mesh.
def get_json(url, fallback, headers=None):
try:
response = requests.get(url, headers=headers or {}, timeout=2)
response.raise_for_status()
- return response.json()
+ return response.json(), True
except (requests.RequestException, ValueError) as exc:
data = fallback.copy()
data["error"] = str(exc)
- return data
+ return data, False
@app.get("/healthz")
@@ -70,7 +72,7 @@ def logout():
def index():
headers = forward_headers()
user = session.get("user", "")
- details = get_json(
+ details, details_ok = get_json(
DETAILS_URL,
{
"title": "Unknown",
@@ -84,11 +86,13 @@ def index():
},
headers,
)
- reviews = get_json(REVIEWS_URL, {"version": "unavailable", "items": [],
"rating": None}, headers)
- page_status = 200
+ reviews, reviews_ok = get_json(
+ REVIEWS_URL, {"version": "unavailable", "items": [], "rating": None},
headers
+ )
+ page_status = 200 if details_ok and reviews_ok else 503
title = escape(str(details.get("title", "Unknown")))
year = escape(str(details.get("year", "-")))
- pages = escape(str(page_status))
+ upstream = escape(str(page_status))
director = escape(str(details.get("director", "-")))
genres = " / ".join(escape(str(genre)) for genre in details.get("genres",
[]))
runtime = escape(str(details.get("runtime", "147 min")))
@@ -103,7 +107,7 @@ def index():
f"<div
class='metric'><span>{label}</span><strong>{value}</strong></div>"
for label, value in [
("Release", year),
- ("Pages", pages),
+ ("Upstream", upstream),
("Director", director),
("Genre", genres),
("Runtime", runtime),
diff --git a/samples/moviereview/src/reviews-v2/app.py
b/samples/moviereview/src/reviews-v2/app.py
index ede89f5f..5b6e49d5 100644
--- a/samples/moviereview/src/reviews-v2/app.py
+++ b/samples/moviereview/src/reviews-v2/app.py
@@ -41,6 +41,11 @@ def root():
@app.get("/reviews")
def reviews():
+ # ratings 不可用时返回 502,与 reviews-v3 保持一致。
+ try:
+ score = rating()
+ except (requests.RequestException, ValueError) as exc:
+ return jsonify({"version": "v2", "items": [], "error": str(exc)}), 502
return jsonify(
{
"version": "v2",
@@ -48,7 +53,7 @@ def reviews():
"人物关系更清晰。",
"这个版本会调用 ratings 服务。"
],
- "rating": rating(),
+ "rating": score,
}
)