Skip to content

Commit

Permalink
chore(mads/hds): remove custom cache implementation
Browse files Browse the repository at this point in the history
In mads and hds we were using a custom implementation of a cache.
This was unfortunate as go-control-plane has a perfectly working one.

The only feature on this cache was the ability to long poll.
This was only required in mads and we've changed the handler of mads
to make this handling outside of the cache.

Signed-off-by: Charly Molter <[email protected]>
  • Loading branch information
lahabana committed Sep 27, 2024
1 parent 27614ed commit d528d46
Show file tree
Hide file tree
Showing 28 changed files with 491 additions and 1,370 deletions.
15 changes: 15 additions & 0 deletions api/observability/v1/mads_helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package v1

import "fmt"

// GetName returns a name including the mesh which is used for ResourceName in MADS snapshot cache
func (x *MonitoringAssignment) GetName() string {
if x != nil {
dpName := ""
if len(x.Targets) > 0 {
dpName = x.Targets[0].GetName()
}
return fmt.Sprintf("/meshes/%s/dataplanes/%s", x.GetMesh(), dpName)
}
return ""
}
11 changes: 0 additions & 11 deletions pkg/hds/cache/cache_suite_test.go

This file was deleted.

71 changes: 0 additions & 71 deletions pkg/hds/cache/snapshot.go

This file was deleted.

197 changes: 0 additions & 197 deletions pkg/hds/cache/snapshot_test.go

This file was deleted.

6 changes: 3 additions & 3 deletions pkg/hds/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

envoy_core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
envoy_service_health "github.com/envoyproxy/go-control-plane/envoy/service/health/v3"
envoy_cache "github.com/envoyproxy/go-control-plane/pkg/cache/v3"

config_core "github.com/kumahq/kuma/pkg/config/core"
"github.com/kumahq/kuma/pkg/core"
Expand All @@ -17,7 +18,6 @@ import (
hds_server "github.com/kumahq/kuma/pkg/hds/server"
"github.com/kumahq/kuma/pkg/hds/tracker"
util_xds "github.com/kumahq/kuma/pkg/util/xds"
util_xds_v3 "github.com/kumahq/kuma/pkg/util/xds/v3"
)

var hdsServerLog = core.Log.WithName("hds-server")
Expand All @@ -30,7 +30,7 @@ func Setup(rt core_runtime.Runtime) error {
return nil
}

snapshotCache := util_xds_v3.NewSnapshotCache(false, hasher{}, util_xds.NewLogger(hdsServerLog))
snapshotCache := envoy_cache.NewSnapshotCache(false, hasher{}, util_xds.NewLogger(hdsServerLog))

callbacks, err := DefaultCallbacks(rt, snapshotCache)
if err != nil {
Expand All @@ -44,7 +44,7 @@ func Setup(rt core_runtime.Runtime) error {
return nil
}

func DefaultCallbacks(rt core_runtime.Runtime, cache util_xds_v3.SnapshotCache) (hds_callbacks.Callbacks, error) {
func DefaultCallbacks(rt core_runtime.Runtime, cache envoy_cache.SnapshotCache) (hds_callbacks.Callbacks, error) {
metrics, err := hds_metrics.NewMetrics(rt.Metrics())
if err != nil {
return nil, err
Expand Down
17 changes: 7 additions & 10 deletions pkg/hds/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package server
import (
"context"
"sync/atomic"

envoy_core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
envoy_service_health "github.com/envoyproxy/go-control-plane/envoy/service/health/v3"
envoy_cache "github.com/envoyproxy/go-control-plane/pkg/cache/v3"
Expand All @@ -14,8 +13,8 @@ import (
"google.golang.org/grpc/status"

mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
hds_cache "github.com/kumahq/kuma/pkg/hds/cache"
hds_callbacks "github.com/kumahq/kuma/pkg/hds/callbacks"
v3 "github.com/kumahq/kuma/pkg/hds/v3"
util_proto "github.com/kumahq/kuma/pkg/util/proto"
)

Expand Down Expand Up @@ -133,10 +132,9 @@ func (s *server) process(stream Stream, reqOrRespCh chan *envoy_service_health.H
watchCancellation()
}
watchCancellation = s.cache.CreateWatch(&envoy_cache.Request{
Node: node,
TypeUrl: hds_cache.HealthCheckSpecifierType,
ResourceNames: []string{"hcs"},
VersionInfo: lastVersion,
Node: node,
TypeUrl: v3.HealthCheckSpecifierType,
VersionInfo: lastVersion,
}, envoy_stream.NewStreamState(false, nil), responseChan)
case reqOrResp, more := <-reqOrRespCh:
if !more {
Expand Down Expand Up @@ -168,10 +166,9 @@ func (s *server) process(stream Stream, reqOrRespCh chan *envoy_service_health.H
watchCancellation()
}
watchCancellation = s.cache.CreateWatch(&envoy_cache.Request{
Node: node,
TypeUrl: hds_cache.HealthCheckSpecifierType,
ResourceNames: []string{"hcs"},
VersionInfo: lastVersion,
Node: node,
TypeUrl: v3.HealthCheckSpecifierType,
VersionInfo: lastVersion,
}, envoy_stream.NewStreamState(false, nil), responseChan)
}
}
Expand Down
Loading

0 comments on commit d528d46

Please sign in to comment.