Skip to content

Commit

Permalink
upgrade go-control-plane to support envoy 1.22
Browse files Browse the repository at this point in the history
This commit upgrades to the latest tagged go-control-plane version of v0.10.1. When using the commit provided by `make guess-envoy-go-control-plane-commit` it introduced behavior that was causing a test failure in `pkg/gateway/dispatch.go`. In the future, we will need to investigate that error and update accordingly then.

Due to the go-control-plane dropping support for the v2 api's, the gateway, ambex and entrypoint packages needed to be update to remove the v2 xDS api's and only support v3 xDS.

Signed-off-by: Lance Austin <[email protected]>
  • Loading branch information
Lance Austin committed Jun 22, 2022
1 parent c2933af commit 401c178
Show file tree
Hide file tree
Showing 89 changed files with 4,350 additions and 7,375 deletions.
2 changes: 1 addition & 1 deletion _cxx/envoy.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ RSYNC_EXTRAS ?=
# which commits are ancestors, I added `make guess-envoy-go-control-plane-commit` to do that in an
# automated way! Still look at the commit yourself to make sure it seems sane; blindly trusting
# machines is bad, mmkay?
ENVOY_GO_CONTROL_PLANE_COMMIT = f1f47757da33f7507078cf7e9e60915418c7bd10
ENVOY_GO_CONTROL_PLANE_COMMIT = v0.10.1

# Set ENVOY_DOCKER_REPO to the list of mirrors that we should
# sanity-check that things get pushed to.
Expand Down
6 changes: 3 additions & 3 deletions cmd/entrypoint/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/emissary-ingress/emissary/v3/pkg/acp"
"github.com/emissary-ingress/emissary/v3/pkg/ambex"
"github.com/emissary-ingress/emissary/v3/pkg/debug"
ecp_v2_cache "github.com/emissary-ingress/emissary/v3/pkg/envoy-control-plane/cache/v2"
ecp_v3_cache "github.com/emissary-ingress/emissary/v3/pkg/envoy-control-plane/cache/v3"
"github.com/emissary-ingress/emissary/v3/pkg/gateway"
"github.com/emissary-ingress/emissary/v3/pkg/kates"
"github.com/emissary-ingress/emissary/v3/pkg/snapshot/v1"
Expand Down Expand Up @@ -376,7 +376,7 @@ func (sh *SnapshotHolder) K8sUpdate(
endpointsChanged := false
dispatcherChanged := false
var endpoints *ambex.Endpoints
var dispSnapshot *ecp_v2_cache.Snapshot
var dispSnapshot *ecp_v3_cache.Snapshot
changed, err := func() (bool, error) {
dlog.Debugf(ctx, "[WATCHER]: processing cluster changes detected by the kubernetes watcher")
sh.mutex.Lock()
Expand Down Expand Up @@ -531,7 +531,7 @@ func (sh *SnapshotHolder) K8sUpdate(

func (sh *SnapshotHolder) ConsulUpdate(ctx context.Context, consulWatcher *consulWatcher, fastpathProcessor FastpathProcessor) bool {
var endpoints *ambex.Endpoints
var dispSnapshot *ecp_v2_cache.Snapshot
var dispSnapshot *ecp_v3_cache.Snapshot
func() {
sh.mutex.Lock()
defer sh.mutex.Unlock()
Expand Down
51 changes: 4 additions & 47 deletions pkg/ambex/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import (
"sort"
"strings"

v2 "github.com/emissary-ingress/emissary/v3/pkg/api/envoy/api/v2"
v2core "github.com/emissary-ingress/emissary/v3/pkg/api/envoy/api/v2/core"
v2endpoint "github.com/emissary-ingress/emissary/v3/pkg/api/envoy/api/v2/endpoint"
v3core "github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/core/v3"
v3endpoint "github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/endpoint/v3"
v3endpointconfig "github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/endpoint/v3"
)

// The Endpoints struct is how Endpoint data gets communicated to ambex. This is a bit simpler than
Expand All @@ -35,34 +31,17 @@ func (e *Endpoints) RoutesString() string {
return strings.Join(routes, "\n")
}

// ToMap_v2 produces a map with the envoy v2 friendly forms of all the endpoint data.
func (e *Endpoints) ToMap_v2() map[string]*v2.ClusterLoadAssignment {
result := map[string]*v2.ClusterLoadAssignment{}
for name, eps := range e.Entries {
var endpoints []*v2endpoint.LbEndpoint
for _, ep := range eps {
endpoints = append(endpoints, ep.ToLbEndpoint_v2())
}
loadAssignment := &v2.ClusterLoadAssignment{
ClusterName: name,
Endpoints: []*v2endpoint.LocalityLbEndpoints{{LbEndpoints: endpoints}},
}
result[name] = loadAssignment
}
return result
}

// ToMap_v3 produces a map with the envoy v3 friendly forms of all the endpoint data.
func (e *Endpoints) ToMap_v3() map[string]*v3endpointconfig.ClusterLoadAssignment {
result := map[string]*v3endpointconfig.ClusterLoadAssignment{}
func (e *Endpoints) ToMap_v3() map[string]*v3endpoint.ClusterLoadAssignment {
result := map[string]*v3endpoint.ClusterLoadAssignment{}
for name, eps := range e.Entries {
var endpoints []*v3endpoint.LbEndpoint
for _, ep := range eps {
endpoints = append(endpoints, ep.ToLbEndpoint_v3())
}
loadAssignment := &v3endpointconfig.ClusterLoadAssignment{
loadAssignment := &v3endpoint.ClusterLoadAssignment{
ClusterName: name,
Endpoints: []*v3endpointconfig.LocalityLbEndpoints{{LbEndpoints: endpoints}},
Endpoints: []*v3endpoint.LocalityLbEndpoints{{LbEndpoints: endpoints}},
}
result[name] = loadAssignment
}
Expand All @@ -77,28 +56,6 @@ type Endpoint struct {
Protocol string
}

// ToLBEndpoint_v2 translates to envoy v2 frinedly form of the Endpoint data.
func (e *Endpoint) ToLbEndpoint_v2() *v2endpoint.LbEndpoint {
return &v2endpoint.LbEndpoint{
HostIdentifier: &v2endpoint.LbEndpoint_Endpoint{
Endpoint: &v2endpoint.Endpoint{
Address: &v2core.Address{
Address: &v2core.Address_SocketAddress{
SocketAddress: &v2core.SocketAddress{
Protocol: v2core.SocketAddress_Protocol(v2core.SocketAddress_Protocol_value[e.Protocol]),
Address: e.Ip,
PortSpecifier: &v2core.SocketAddress_PortValue{
PortValue: e.Port,
},
Ipv4Compat: true,
},
},
},
},
},
}
}

// ToLBEndpoint_v3 translates to envoy v3 frinedly form of the Endpoint data.
func (e *Endpoint) ToLbEndpoint_v3() *v3endpoint.LbEndpoint {
return &v3endpoint.LbEndpoint{
Expand Down
4 changes: 2 additions & 2 deletions pkg/ambex/fastpath.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package ambex

import (
ecp_v2_cache "github.com/emissary-ingress/emissary/v3/pkg/envoy-control-plane/cache/v2"
ecp_v3_cache "github.com/emissary-ingress/emissary/v3/pkg/envoy-control-plane/cache/v3"
)

// FastpathSnapshot holds envoy configuration that bypasses python.
type FastpathSnapshot struct {
Snapshot *ecp_v2_cache.Snapshot
Snapshot *ecp_v3_cache.Snapshot
Endpoints *Endpoints
}
Loading

0 comments on commit 401c178

Please sign in to comment.