Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(mads/hds): remove custom cache implementation #11590

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 7 additions & 9 deletions pkg/hds/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,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 +133,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 +167,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
7 changes: 4 additions & 3 deletions pkg/hds/tracker/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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"
"github.com/go-logr/logr"
"github.com/pkg/errors"

Expand Down Expand Up @@ -47,9 +48,9 @@ func NewCallbacks(
log logr.Logger,
resourceManager manager.ResourceManager,
readOnlyResourceManager manager.ReadOnlyResourceManager,
cache util_xds_v3.SnapshotCache,
cache envoy_cache.SnapshotCache,
config *dp_server.HdsConfig,
hasher util_xds_v3.NodeHash,
hasher envoy_cache.NodeHash,
metrics *hds_metrics.Metrics,
defaultAdminPort uint32,
) hds_callbacks.Callbacks {
Expand Down Expand Up @@ -143,7 +144,7 @@ func (t *tracker) newWatchdog(node *envoy_core.Node) util_xds_v3.Watchdog {
t.log.Error(err, "OnTick() failed")
},
OnStop: func() {
if err := t.reconciler.Clear(node); err != nil {
if err := t.reconciler.Clear(context.Background(), node); err != nil {
t.log.Error(err, "OnTick() failed")
}
},
Expand Down
Loading
Loading