[discovery] Update xds ads and webhook (#801)
diff --git a/pkg/config/schema/resource/schema.go b/pkg/config/schema/collection/schema.go
similarity index 99%
rename from pkg/config/schema/resource/schema.go
rename to pkg/config/schema/collection/schema.go
index 5012b66..015ab2a 100644
--- a/pkg/config/schema/resource/schema.go
+++ b/pkg/config/schema/collection/schema.go
@@ -1,4 +1,4 @@
-package resource
+package collection
import (
"errors"
diff --git a/pkg/config/schema/collection/schemas.go b/pkg/config/schema/collection/schemas.go
index d5cadbf..f2eb0a4 100644
--- a/pkg/config/schema/collection/schemas.go
+++ b/pkg/config/schema/collection/schemas.go
@@ -9,18 +9,17 @@
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/apache/dubbo-kubernetes/pkg/config"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
"github.com/apache/dubbo-kubernetes/pkg/util/sets"
)
// Schemas contains metadata about configuration resources.
type Schemas struct {
- byCollection map[config.GroupVersionKind]resource.Schema
- byAddOrder []resource.Schema
+ byCollection map[config.GroupVersionKind]Schema
+ byAddOrder []Schema
}
// SchemasFor is a shortcut for creating Schemas. It uses MustAdd for each element.
-func SchemasFor(schemas ...resource.Schema) Schemas {
+func SchemasFor(schemas ...Schema) Schemas {
b := NewSchemasBuilder()
for _, s := range schemas {
b.MustAdd(s)
@@ -36,7 +35,7 @@
// NewSchemasBuilder returns a new instance of SchemasBuilder.
func NewSchemasBuilder() *SchemasBuilder {
s := Schemas{
- byCollection: make(map[config.GroupVersionKind]resource.Schema),
+ byCollection: make(map[config.GroupVersionKind]Schema),
}
return &SchemasBuilder{
@@ -45,7 +44,7 @@
}
// Add a new collection to the schemas.
-func (b *SchemasBuilder) Add(s resource.Schema) error {
+func (b *SchemasBuilder) Add(s Schema) error {
if _, found := b.schemas.byCollection[s.GroupVersionKind()]; found {
return fmt.Errorf("collection already exists: %v", s.GroupVersionKind())
}
@@ -56,7 +55,7 @@
}
// MustAdd calls Add and panics if it fails.
-func (b *SchemasBuilder) MustAdd(s resource.Schema) *SchemasBuilder {
+func (b *SchemasBuilder) MustAdd(s Schema) *SchemasBuilder {
if err := b.Add(s); err != nil {
panic(fmt.Sprintf("SchemasBuilder.MustAdd: %v", err))
}
@@ -74,7 +73,7 @@
}
// ForEach executes the given function on each contained schema, until the function returns true.
-func (s Schemas) ForEach(handleSchema func(resource.Schema) (done bool)) {
+func (s Schemas) ForEach(handleSchema func(Schema) (done bool)) {
for _, schema := range s.byAddOrder {
if handleSchema(schema) {
return
@@ -113,7 +112,7 @@
}
// FindByGroupVersionKind searches and returns the first schema with the given GVK
-func (s Schemas) FindByGroupVersionKind(gvk config.GroupVersionKind) (resource.Schema, bool) {
+func (s Schemas) FindByGroupVersionKind(gvk config.GroupVersionKind) (Schema, bool) {
for _, rs := range s.byAddOrder {
if rs.GroupVersionKind() == gvk {
return rs, true
@@ -125,7 +124,7 @@
// FindByGroupVersionAliasesKind searches and returns the first schema with the given GVK,
// if not found, it will search for version aliases for the schema to see if there is a match.
-func (s Schemas) FindByGroupVersionAliasesKind(gvk config.GroupVersionKind) (resource.Schema, bool) {
+func (s Schemas) FindByGroupVersionAliasesKind(gvk config.GroupVersionKind) (Schema, bool) {
for _, rs := range s.byAddOrder {
for _, va := range rs.GroupVersionAliasKinds() {
if va == gvk {
@@ -139,7 +138,7 @@
// FindByGroupKind searches and returns the first schema with the given GVK, ignoring versions.
// Generally it's a good idea to use FindByGroupVersionAliasesKind, which validates the version as well.
// FindByGroupKind provides future proofing against versions we don't yet know about; given we don't know them, its risky.
-func (s Schemas) FindByGroupKind(gvk config.GroupVersionKind) (resource.Schema, bool) {
+func (s Schemas) FindByGroupKind(gvk config.GroupVersionKind) (Schema, bool) {
for _, rs := range s.byAddOrder {
if rs.Group() == gvk.Group && rs.Kind() == gvk.Kind {
return rs, true
@@ -149,7 +148,7 @@
}
// FindByGroupVersionResource searches and returns the first schema with the given GVR
-func (s Schemas) FindByGroupVersionResource(gvr schema.GroupVersionResource) (resource.Schema, bool) {
+func (s Schemas) FindByGroupVersionResource(gvr schema.GroupVersionResource) (Schema, bool) {
for _, rs := range s.byAddOrder {
if rs.GroupVersionResource() == gvr {
return rs, true
@@ -160,7 +159,7 @@
}
// All returns all known Schemas
-func (s Schemas) All() []resource.Schema {
+func (s Schemas) All() []Schema {
return slices.Clone(s.byAddOrder)
}
@@ -174,7 +173,7 @@
}
// Add creates a copy of this Schemas with the given schemas added.
-func (s Schemas) Add(toAdd ...resource.Schema) Schemas {
+func (s Schemas) Add(toAdd ...Schema) Schemas {
b := NewSchemasBuilder()
for _, s := range s.byAddOrder {
@@ -189,7 +188,7 @@
}
// Remove creates a copy of this Schemas with the given schemas removed.
-func (s Schemas) Remove(toRemove ...resource.Schema) Schemas {
+func (s Schemas) Remove(toRemove ...Schema) Schemas {
b := NewSchemasBuilder()
for _, s := range s.byAddOrder {
diff --git a/pkg/config/schema/collections/collections.agent.go b/pkg/config/schema/collections/collections.agent.go
index 21bd968..a840452 100644
--- a/pkg/config/schema/collections/collections.agent.go
+++ b/pkg/config/schema/collections/collections.agent.go
@@ -5,7 +5,6 @@
import (
"github.com/apache/dubbo-kubernetes/pkg/config/schema/collection"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
istioioapimetav1alpha1 "istio.io/api/meta/v1alpha1"
istioioapinetworkingv1alpha3 "istio.io/api/networking/v1alpha3"
istioioapisecurityv1beta1 "istio.io/api/security/v1beta1"
@@ -14,7 +13,7 @@
)
var (
- PeerAuthentication = resource.Builder{
+ PeerAuthentication = collection.Builder{
Identifier: "PeerAuthentication",
Group: "security.istio.io",
Kind: "PeerAuthentication",
@@ -30,7 +29,7 @@
Synthetic: false,
Builtin: false,
}.MustBuild()
- RequestAuthentication = resource.Builder{
+ RequestAuthentication = collection.Builder{
Identifier: "RequestAuthentication",
Group: "security.istio.io",
Kind: "RequestAuthentication",
@@ -46,7 +45,7 @@
Synthetic: false,
Builtin: false,
}.MustBuild()
- DestinationRule = resource.Builder{
+ DestinationRule = collection.Builder{
Identifier: "DestinationRule",
Group: "networking.istio.io",
Kind: "DestinationRule",
@@ -63,7 +62,7 @@
Synthetic: false,
Builtin: false,
}.MustBuild()
- VirtualService = resource.Builder{
+ VirtualService = collection.Builder{
Identifier: "VirtualService",
Group: "networking.istio.io",
Kind: "VirtualService",
@@ -80,7 +79,7 @@
Synthetic: false,
Builtin: false,
}.MustBuild()
- ValidatingWebhookConfiguration = resource.Builder{
+ ValidatingWebhookConfiguration = collection.Builder{
Identifier: "ValidatingWebhookConfiguration",
Group: "admissionregistration.k8s.io",
Kind: "ValidatingWebhookConfiguration",
@@ -93,7 +92,7 @@
Synthetic: false,
Builtin: true,
}.MustBuild()
- MutatingWebhookConfiguration = resource.Builder{
+ MutatingWebhookConfiguration = collection.Builder{
Identifier: "MutatingWebhookConfiguration",
Group: "admissionregistration.k8s.io",
Kind: "MutatingWebhookConfiguration",
diff --git a/pkg/config/schema/collections/collections.go b/pkg/config/schema/collections/collections.go
index ace155e..457283a 100644
--- a/pkg/config/schema/collections/collections.go
+++ b/pkg/config/schema/collections/collections.go
@@ -5,7 +5,6 @@
import (
"github.com/apache/dubbo-kubernetes/pkg/config/schema/collection"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
istioioapimetav1alpha1 "istio.io/api/meta/v1alpha1"
istioioapinetworkingv1alpha3 "istio.io/api/networking/v1alpha3"
istioioapisecurityv1beta1 "istio.io/api/security/v1beta1"
@@ -14,9 +13,9 @@
)
var (
- PeerAuthentication = resource.Builder{
+ PeerAuthentication = collection.Builder{
Identifier: "PeerAuthentication",
- Group: "security.istio.io",
+ Group: "security.dubbo.io",
Kind: "PeerAuthentication",
Plural: "peerauthentications",
Version: "v1",
@@ -30,9 +29,9 @@
Synthetic: false,
Builtin: false,
}.MustBuild()
- RequestAuthentication = resource.Builder{
+ RequestAuthentication = collection.Builder{
Identifier: "RequestAuthentication",
- Group: "security.istio.io",
+ Group: "security.dubbo.io",
Kind: "RequestAuthentication",
Plural: "requestauthentications",
Version: "v1",
@@ -46,9 +45,9 @@
Synthetic: false,
Builtin: false,
}.MustBuild()
- DestinationRule = resource.Builder{
+ DestinationRule = collection.Builder{
Identifier: "DestinationRule",
- Group: "networking.istio.io",
+ Group: "networking.dubbo.io",
Kind: "DestinationRule",
Plural: "destinationrules",
Version: "v1",
@@ -63,9 +62,9 @@
Synthetic: false,
Builtin: false,
}.MustBuild()
- VirtualService = resource.Builder{
+ VirtualService = collection.Builder{
Identifier: "VirtualService",
- Group: "networking.istio.io",
+ Group: "networking.dubbo.io",
Kind: "VirtualService",
Plural: "virtualservices",
Version: "v1",
@@ -80,7 +79,7 @@
Synthetic: false,
Builtin: false,
}.MustBuild()
- ValidatingWebhookConfiguration = resource.Builder{
+ ValidatingWebhookConfiguration = collection.Builder{
Identifier: "ValidatingWebhookConfiguration",
Group: "admissionregistration.k8s.io",
Kind: "ValidatingWebhookConfiguration",
@@ -93,7 +92,7 @@
Synthetic: false,
Builtin: true,
}.MustBuild()
- MutatingWebhookConfiguration = resource.Builder{
+ MutatingWebhookConfiguration = collection.Builder{
Identifier: "MutatingWebhookConfiguration",
Group: "admissionregistration.k8s.io",
Kind: "MutatingWebhookConfiguration",
diff --git a/pkg/config/schema/gvk/resources.go b/pkg/config/schema/gvk/resources.go
index 2a4af1f..8fb566d 100644
--- a/pkg/config/schema/gvk/resources.go
+++ b/pkg/config/schema/gvk/resources.go
@@ -37,11 +37,11 @@
Service = config.GroupVersionKind{Group: "", Version: "v1", Kind: "Service"}
ServiceAccount = config.GroupVersionKind{Group: "", Version: "v1", Kind: "ServiceAccount"}
MeshConfig = config.GroupVersionKind{Group: "", Version: "v1alpha1", Kind: "MeshConfig"}
- RequestAuthentication = config.GroupVersionKind{Group: "security.istio.io", Version: "v1", Kind: "RequestAuthentication"}
- PeerAuthentication = config.GroupVersionKind{Group: "security.istio.io", Version: "v1", Kind: "PeerAuthentication"}
- AuthorizationPolicy = config.GroupVersionKind{Group: "security.istio.io", Version: "v1", Kind: "AuthorizationPolicy"}
- DestinationRule = config.GroupVersionKind{Group: "networking.istio.io", Version: "v1", Kind: "DestinationRule"}
- VirtualService = config.GroupVersionKind{Group: "networking.istio.io", Version: "v1", Kind: "VirtualService"}
+ RequestAuthentication = config.GroupVersionKind{Group: "security.dubbo.io", Version: "v1", Kind: "RequestAuthentication"}
+ PeerAuthentication = config.GroupVersionKind{Group: "security.dubbo.io", Version: "v1", Kind: "PeerAuthentication"}
+ AuthorizationPolicy = config.GroupVersionKind{Group: "security.dubbo.io", Version: "v1", Kind: "AuthorizationPolicy"}
+ DestinationRule = config.GroupVersionKind{Group: "networking.dubbo.io", Version: "v1", Kind: "DestinationRule"}
+ VirtualService = config.GroupVersionKind{Group: "networking.dubbo.io", Version: "v1", Kind: "VirtualService"}
)
func ToGVR(g config.GroupVersionKind) (schema.GroupVersionResource, bool) {
@@ -97,10 +97,10 @@
switch g {
case gvr.CustomResourceDefinition:
return CustomResourceDefinition, true
- // case gvr.MutatingWebhookConfiguration:
- // return MutatingWebhookConfiguration, true
- // case gvr.ValidatingWebhookConfiguration:
- // return ValidatingWebhookConfiguration, true
+ case gvr.MutatingWebhookConfiguration:
+ return MutatingWebhookConfiguration, true
+ case gvr.ValidatingWebhookConfiguration:
+ return ValidatingWebhookConfiguration, true
case gvr.Namespace:
return Namespace, true
case gvr.Deployment:
diff --git a/pkg/config/schema/gvr/resources.go b/pkg/config/schema/gvr/resources.go
index dd55ca6..35f8c75 100644
--- a/pkg/config/schema/gvr/resources.go
+++ b/pkg/config/schema/gvr/resources.go
@@ -35,11 +35,11 @@
Service = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "services"}
ServiceAccount = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "serviceaccounts"}
MeshConfig = schema.GroupVersionResource{Group: "", Version: "v1alpha1", Resource: "meshconfigs"}
- RequestAuthentication = schema.GroupVersionResource{Group: "security.istio.io", Version: "v1", Resource: "requestauthentications"}
- PeerAuthentication = schema.GroupVersionResource{Group: "security.istio.io", Version: "v1", Resource: "peerauthentications"}
- AuthorizationPolicy = schema.GroupVersionResource{Group: "security.istio.io", Version: "v1", Resource: "authorizationpolicies"}
- DestinationRule = schema.GroupVersionResource{Group: "networking.istio.io", Version: "v1", Resource: "destinationrules"}
- VirtualService = schema.GroupVersionResource{Group: "networking.istio.io", Version: "v1", Resource: "virtualservices"}
+ RequestAuthentication = schema.GroupVersionResource{Group: "security.dubbo.io", Version: "v1", Resource: "requestauthentications"}
+ PeerAuthentication = schema.GroupVersionResource{Group: "security.dubbo.io", Version: "v1", Resource: "peerauthentications"}
+ AuthorizationPolicy = schema.GroupVersionResource{Group: "security.dubbo.io", Version: "v1", Resource: "authorizationpolicies"}
+ DestinationRule = schema.GroupVersionResource{Group: "networking.dubbo.io", Version: "v1", Resource: "destinationrules"}
+ VirtualService = schema.GroupVersionResource{Group: "networking.dubbo.io", Version: "v1", Resource: "virtualservices"}
)
func IsClusterScoped(g schema.GroupVersionResource) bool {
diff --git a/pkg/config/schema/kind/resources.go b/pkg/config/schema/kind/resources.go
index 09d6606..80ce518 100644
--- a/pkg/config/schema/kind/resources.go
+++ b/pkg/config/schema/kind/resources.go
@@ -11,6 +11,7 @@
Secret
Service
ServiceAccount
+ ServiceEntry
StatefulSet
ValidatingWebhookConfiguration
MutatingWebhookConfiguration
@@ -40,6 +41,8 @@
return "Service"
case ServiceAccount:
return "ServiceAccount"
+ case ServiceEntry:
+ return "ServiceEntry"
case StatefulSet:
return "StatefulSet"
case ValidatingWebhookConfiguration:
diff --git a/pkg/kube/inject/webhook.go b/pkg/kube/inject/webhook.go
index 134074b..d8717c1 100644
--- a/pkg/kube/inject/webhook.go
+++ b/pkg/kube/inject/webhook.go
@@ -290,6 +290,7 @@
if pod.Labels == nil {
pod.Labels = map[string]string{}
}
+
return nil
}
@@ -348,13 +349,14 @@
pod.ManagedFields = nil
- potentialPodName(pod.ObjectMeta)
+ podName := potentialPodName(pod.ObjectMeta)
if pod.ObjectMeta.Namespace == "" {
pod.ObjectMeta.Namespace = req.Namespace
}
-
+ klog.Infof("Namespace: %v podName: %s", pod.Namespace+"/"+podName)
klog.Infof("Process proxyless injection request")
+ wh.mu.RLock()
proxyConfig := wh.env.GetProxyConfigOrDefault(pod.Namespace, pod.Labels, pod.Annotations, wh.meshConfig)
deploy, typeMeta := kube.GetDeployMetaFromPod(&pod)
params := InjectionParameters{
@@ -372,10 +374,14 @@
revision: wh.revision,
}
+ wh.mu.RUnlock()
+
patchBytes, err := injectPod(params)
if err != nil {
+ klog.Errorf("Pod injection failed: %v", err)
return toAdmissionResponse(err)
}
+
reviewResponse := kube.AdmissionResponse{
Allowed: true,
Patch: patchBytes,
diff --git a/pkg/webhooks/server/server.go b/pkg/webhooks/server/server.go
index 9612ec7..d75287f 100644
--- a/pkg/webhooks/server/server.go
+++ b/pkg/webhooks/server/server.go
@@ -7,7 +7,6 @@
"fmt"
"github.com/apache/dubbo-kubernetes/pkg/config/constants"
"github.com/apache/dubbo-kubernetes/pkg/config/schema/collection"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
"github.com/apache/dubbo-kubernetes/pkg/config/validation"
"github.com/apache/dubbo-kubernetes/pkg/kube"
"github.com/apache/dubbo-kubernetes/sail/pkg/config/kube/crd"
@@ -113,7 +112,7 @@
// "Version" is not relevant for Istio types; each version has the same schema. So do a lookup that does not consider
// version. This ensures if a new version comes out and Istiod is not updated, we won't reject it.
- s, exists := wh.schemas.FindByGroupKind(resource.FromKubernetesGVK(&gvk))
+ s, exists := wh.schemas.FindByGroupKind(collection.FromKubernetesGVK(&gvk))
if !exists {
klog.Infof("unrecognized type %v", addDryRunMessageIfNeeded(obj.GroupVersionKind().String()))
return toAdmissionResponse(fmt.Errorf("unrecognized type %v", obj.GroupVersionKind()))
diff --git a/pkg/webhooks/validation/controller/controller.go b/pkg/webhooks/validation/controller/controller.go
index 4745ffc..169f258 100644
--- a/pkg/webhooks/validation/controller/controller.go
+++ b/pkg/webhooks/validation/controller/controller.go
@@ -73,8 +73,7 @@
func (c *Controller) readyForFailClose() bool {
if !c.dryRunOfInvalidConfigRejected {
- klog.Info("Endpoint successfully rejected invalid config. Switching to fail-close.")
- c.dryRunOfInvalidConfigRejected = true
+
// Sync all webhooks; this ensures if we have multiple webhooks all of them are updated
c.syncAll()
}
diff --git a/pkg/webhooks/webhookpatch.go b/pkg/webhooks/webhookpatch.go
index 9a7d552..f8b507a 100644
--- a/pkg/webhooks/webhookpatch.go
+++ b/pkg/webhooks/webhookpatch.go
@@ -87,6 +87,8 @@
if !ok {
return nil
}
+ klog.Infof("This is webhook label: %v", v)
+
if v != w.revision {
return errWrongRevision
}
diff --git a/sail/pkg/bootstrap/configcontroller.go b/sail/pkg/bootstrap/configcontroller.go
index a6d8e35..85c1a04 100644
--- a/sail/pkg/bootstrap/configcontroller.go
+++ b/sail/pkg/bootstrap/configcontroller.go
@@ -134,7 +134,7 @@
Config: adsc.Config{
Namespace: args.Namespace,
Workload: args.PodName,
- Revision: "", // TODO
+ Revision: args.Revision,
Meta: nil,
GrpcOpts: []grpc.DialOption{
args.KeepaliveOptions.ConvertToClientOption(),
diff --git a/sail/pkg/bootstrap/server.go b/sail/pkg/bootstrap/server.go
index 3812cb0..d601fcd 100644
--- a/sail/pkg/bootstrap/server.go
+++ b/sail/pkg/bootstrap/server.go
@@ -672,11 +672,13 @@
// Make sure we have security
klog.Warningf("skipping Kubernetes credential reader; SAIL_ENABLE_XDS_IDENTITY_CHECK must be set to true for this feature.")
} else {
- // s.XDSServer.ConfigUpdate(&model.PushRequest{
- // Full: false,
- // ConfigsUpdated: sets.New(model.ConfigKey{Kind: k, Name: name, Namespace: namespace}),
- // Reason: model.NewReasonStats(model.SecretTrigger),
- // })
+ // TODO ConfigUpdated Multicluster get secret and configmap
+ s.XDSServer.ConfigUpdate(&model.PushRequest{
+ Full: false,
+ ConfigsUpdated: nil,
+ Reason: model.NewReasonStats(model.SecretTrigger),
+ })
+
}
}
@@ -759,7 +761,7 @@
func (s *Server) pushContextReady(expected int64) bool {
committed := s.XDSServer.CommittedUpdates.Load()
if committed < expected {
- klog.Infof("Waiting for pushcontext to process inbound updates, inbound: %v, committed : %v", expected, committed)
+ klog.V(2).Infof("Waiting for pushcontext to process inbound updates, inbound: %v, committed : %v", expected, committed)
return false
}
return true
diff --git a/sail/pkg/config/aggregate/config.go b/sail/pkg/config/aggregate/config.go
index 8a8478a..c5f5608 100644
--- a/sail/pkg/config/aggregate/config.go
+++ b/sail/pkg/config/aggregate/config.go
@@ -3,12 +3,12 @@
import (
"errors"
+ "github.com/apache/dubbo-kubernetes/pkg/config/schema/collection"
"github.com/apache/dubbo-kubernetes/pkg/slices"
"k8s.io/apimachinery/pkg/types"
"github.com/apache/dubbo-kubernetes/pkg/config"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/collection"
"github.com/apache/dubbo-kubernetes/pkg/util/sets"
"github.com/apache/dubbo-kubernetes/sail/pkg/model"
)
diff --git a/sail/pkg/config/kube/crd/conversion.go b/sail/pkg/config/kube/crd/conversion.go
index 8cf499e..90c5366 100644
--- a/sail/pkg/config/kube/crd/conversion.go
+++ b/sail/pkg/config/kube/crd/conversion.go
@@ -5,14 +5,14 @@
"encoding/json"
"fmt"
"github.com/apache/dubbo-kubernetes/pkg/config"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
+ "github.com/apache/dubbo-kubernetes/pkg/config/schema/collection"
"io"
kubeyaml "k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/klog/v2"
"reflect"
)
-type ConversionFunc = func(s resource.Schema, js string) (config.Spec, error)
+type ConversionFunc = func(s collection.Schema, js string) (config.Spec, error)
func parseInputsImpl(inputs string, withValidate bool) ([]config.Config, []DubboKind, error) {
var varr []config.Config
@@ -45,7 +45,7 @@
return parseInputsImpl(inputs, true)
}
-func FromJSON(s resource.Schema, js string) (config.Spec, error) {
+func FromJSON(s collection.Schema, js string) (config.Spec, error) {
c, err := s.NewInstance()
if err != nil {
return nil, err
@@ -56,11 +56,11 @@
return c, nil
}
-func ConvertObject(schema resource.Schema, object DubboObject, domain string) (*config.Config, error) {
+func ConvertObject(schema collection.Schema, object DubboObject, domain string) (*config.Config, error) {
return ConvertObjectInternal(schema, object, domain, FromJSON)
}
-func StatusJSONFromMap(schema resource.Schema, jsonMap *json.RawMessage) (config.Status, error) {
+func StatusJSONFromMap(schema collection.Schema, jsonMap *json.RawMessage) (config.Status, error) {
if jsonMap == nil {
return nil, nil
}
@@ -79,7 +79,7 @@
return status, nil
}
-func ConvertObjectInternal(schema resource.Schema, object DubboObject, domain string, convert ConversionFunc) (*config.Config, error) {
+func ConvertObjectInternal(schema collection.Schema, object DubboObject, domain string, convert ConversionFunc) (*config.Config, error) {
js, err := json.Marshal(object.GetSpec())
if err != nil {
return nil, err
diff --git a/sail/pkg/config/kube/crdclient/client.go b/sail/pkg/config/kube/crdclient/client.go
index da1ebc1..3753723 100644
--- a/sail/pkg/config/kube/crdclient/client.go
+++ b/sail/pkg/config/kube/crdclient/client.go
@@ -5,7 +5,6 @@
"fmt"
"github.com/apache/dubbo-kubernetes/pkg/config"
"github.com/apache/dubbo-kubernetes/pkg/config/schema/collection"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/resource"
"github.com/apache/dubbo-kubernetes/pkg/kube"
"github.com/apache/dubbo-kubernetes/pkg/kube/controllers"
"github.com/apache/dubbo-kubernetes/pkg/kube/kclient"
@@ -30,7 +29,7 @@
kinds map[config.GroupVersionKind]nsStore
kindsMu sync.RWMutex
domainSuffix string
- schemasByCRDName map[string]resource.Schema
+ schemasByCRDName map[string]collection.Schema
schemas collection.Schemas
client kube.Client
filtersByGVK map[config.GroupVersionKind]kubetypes.Filter
@@ -52,7 +51,7 @@
}
func NewForSchemas(client kube.Client, opts Option, schemas collection.Schemas) *Client {
- schemasByCRDName := map[string]resource.Schema{}
+ schemasByCRDName := map[string]collection.Schema{}
for _, s := range schemas.All() {
// From the spec: "Its name MUST be in the format <.spec.name>.<.spec.group>."
name := fmt.Sprintf("%s.%s", s.Plural(), s.Group())
diff --git a/sail/pkg/config/kube/file/controller.go b/sail/pkg/config/kube/file/controller.go
index 0a1ec6c..3783688 100644
--- a/sail/pkg/config/kube/file/controller.go
+++ b/sail/pkg/config/kube/file/controller.go
@@ -2,11 +2,11 @@
import (
"fmt"
+ "github.com/apache/dubbo-kubernetes/pkg/config/schema/collection"
"github.com/apache/dubbo-kubernetes/sail/pkg/config/kube/crd"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/apache/dubbo-kubernetes/pkg/config"
- "github.com/apache/dubbo-kubernetes/pkg/config/schema/collection"
"github.com/apache/dubbo-kubernetes/pkg/config/schema/collections"
"github.com/apache/dubbo-kubernetes/pkg/kube/controllers"
"github.com/apache/dubbo-kubernetes/pkg/kube/krt"
diff --git a/sail/pkg/credentials/kube/secrets.go b/sail/pkg/credentials/kube/secrets.go
index 191d248..fd2ee9d 100644
--- a/sail/pkg/credentials/kube/secrets.go
+++ b/sail/pkg/credentials/kube/secrets.go
@@ -8,25 +8,11 @@
)
const (
- // The ID/name for the certificate chain in kubernetes generic secret.
- GenericScrtCert = "cert"
- // The ID/name for the private key in kubernetes generic secret.
- GenericScrtKey = "key"
- // The ID/name for the CA certificate in kubernetes generic secret.
GenericScrtCaCert = "cacert"
- // The ID/name for the CRL in kubernetes generic secret.
- GenericScrtCRL = "crl"
+ GenericScrtCRL = "crl"
- // The ID/name for the certificate chain in kubernetes tls secret.
- TLSSecretCert = "tls.crt"
- // The ID/name for the k8sKey in kubernetes tls secret.
- TLSSecretKey = "tls.key"
- // The ID/name for the certificate OCSP staple in kubernetes tls secret
- TLSSecretOcspStaple = "tls.ocsp-staple"
- // The ID/name for the CA certificate in kubernetes tls secret
TLSSecretCaCert = "ca.crt"
- // The ID/name for the CRL in kubernetes tls secret.
- TLSSecretCrl = "ca.crl"
+ TLSSecretCrl = "ca.crl"
)
func hasKeys(d map[string][]byte, keys ...string) bool {
diff --git a/sail/pkg/model/push_context.go b/sail/pkg/model/push_context.go
index 8efbe55..a6fde7c 100644
--- a/sail/pkg/model/push_context.go
+++ b/sail/pkg/model/push_context.go
@@ -102,21 +102,7 @@
type ResourceDelta = xds.ResourceDelta
func NewPushContext() *PushContext {
- return &PushContext{
- // ServiceIndex: serviceIndex{},
- // ProxyStatus: map[string]map[string]ProxyPushStatus{},
- // serviceAccounts: map[serviceAccountKey][]string{},
- }
-}
-
-func newServiceIndex() serviceIndex {
- return serviceIndex{
- public: []*Service{},
- privateByNamespace: map[string][]*Service{},
- exportedToNamespace: map[string][]*Service{},
- HostnameAndNamespace: map[host.Name]map[string]*Service{},
- instancesByPort: map[string]map[int][]*DubboEndpoint{},
- }
+ return &PushContext{}
}
type ConfigKey struct {
@@ -252,10 +238,6 @@
return pr
}
-func (r ReasonStats) Has(reason TriggerReason) bool {
- return r[reason] > 0
-}
-
func (pr *PushRequest) IsRequest() bool {
return len(pr.Reason) == 1 && pr.Reason.Has(ProxyRequest)
}
@@ -279,32 +261,6 @@
defer ps.proxyStatusMutex.RUnlock()
}
-func NewReasonStats(reasons ...TriggerReason) ReasonStats {
- ret := make(ReasonStats)
- for _, reason := range reasons {
- ret.Add(reason)
- }
- return ret
-}
-
-func (r ReasonStats) Add(reason TriggerReason) {
- r[reason]++
-}
-
-func (r ReasonStats) Merge(other ReasonStats) {
- for reason, count := range other {
- r[reason] += count
- }
-}
-
-func (r ReasonStats) Count() int {
- var ret int
- for _, count := range r {
- ret += count
- }
- return ret
-}
-
func (ps *PushContext) GetAllServices() []*Service {
return ps.servicesExportedToNamespace(NamespaceAll)
}
@@ -330,3 +286,33 @@
return out
}
+
+func NewReasonStats(reasons ...TriggerReason) ReasonStats {
+ ret := make(ReasonStats)
+ for _, reason := range reasons {
+ ret.Add(reason)
+ }
+ return ret
+}
+
+func (r ReasonStats) Has(reason TriggerReason) bool {
+ return r[reason] > 0
+}
+
+func (r ReasonStats) Add(reason TriggerReason) {
+ r[reason]++
+}
+
+func (r ReasonStats) Merge(other ReasonStats) {
+ for reason, count := range other {
+ r[reason] += count
+ }
+}
+
+func (r ReasonStats) Count() int {
+ var ret int
+ for _, count := range r {
+ ret += count
+ }
+ return ret
+}
diff --git a/sail/pkg/xds/discovery.go b/sail/pkg/xds/discovery.go
index 822bf21..6ca0ea4 100644
--- a/sail/pkg/xds/discovery.go
+++ b/sail/pkg/xds/discovery.go
@@ -111,7 +111,7 @@
func (s *DiscoveryServer) Push(req *model.PushRequest) {
if !req.Full {
req.Push = s.globalPushContext()
- // s.AdsPushAll(req)
+ s.AdsPushAll(req)
return
}
@@ -125,7 +125,7 @@
versionLocal := s.NextVersion()
push := s.initPushContext(req, oldPushContext, versionLocal)
req.Push = push
- // s.AdsPushAll(req)
+ s.AdsPushAll(req)
}
func (s *DiscoveryServer) initPushContext(req *model.PushRequest, oldPushContext *model.PushContext, version string) *model.PushContext {
@@ -157,8 +157,6 @@
}
s.InboundUpdates.Inc()
- klog.Infof("this is req: %v", req)
-
s.pushChannel <- req
}
@@ -222,14 +220,12 @@
freeCh := make(chan struct{}, 1)
push := func(req *model.PushRequest, debouncedEvents int, startDebounce time.Time) {
- klog.Info("This is push func")
pushFn(req)
updateSent.Add(int64(debouncedEvents))
freeCh <- struct{}{}
}
pushWorker := func() {
- klog.Info("This is pushWorker func")
eventDelay := time.Since(startDebounce)
quietTime := time.Since(lastConfigUpdateTime)
// it has been too long or quiet enough
diff --git a/sail/pkg/xds/eds.go b/sail/pkg/xds/eds.go
index 21fe09b..811dacd 100644
--- a/sail/pkg/xds/eds.go
+++ b/sail/pkg/xds/eds.go
@@ -1,9 +1,12 @@
package xds
import (
+ "github.com/apache/dubbo-kubernetes/pkg/config/schema/kind"
+ "github.com/apache/dubbo-kubernetes/pkg/util/sets"
"github.com/apache/dubbo-kubernetes/sail/pkg/model"
)
+// TODO EDS
func (s *DiscoveryServer) EDSUpdate(shard model.ShardKey, serviceName string, namespace string,
dubboEndpoints []*model.DubboEndpoint,
) {
@@ -13,7 +16,7 @@
// Trigger a push
s.ConfigUpdate(&model.PushRequest{
Full: pushType == model.FullPush,
- ConfigsUpdated: nil,
+ ConfigsUpdated: sets.New(model.ConfigKey{Kind: kind.ServiceEntry, Name: serviceName, Namespace: namespace}),
Reason: model.NewReasonStats(model.EndpointUpdate),
})
}