Skip to content

Commit

Permalink
Renames the internal/contour package to internal/xdscache.
Browse files Browse the repository at this point in the history
Fixes projectcontour#2939

Signed-off-by: Steve Sloka <slokas@vmware.com>
  • Loading branch information
stevesloka committed Sep 29, 2020
1 parent 54c0fa5 commit 8c32370
Show file tree
Hide file tree
Showing 23 changed files with 63 additions and 63 deletions.
23 changes: 12 additions & 11 deletions cmd/contour/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
contourv1 "github.com/projectcontour/contour/apis/projectcontour/v1"
"github.com/projectcontour/contour/internal/annotation"
"github.com/projectcontour/contour/internal/contour"
contourv2 "github.com/projectcontour/contour/internal/contour/v2"
"github.com/projectcontour/contour/internal/dag"
"github.com/projectcontour/contour/internal/debug"
"github.com/projectcontour/contour/internal/health"
Expand All @@ -39,6 +38,8 @@ import (
"github.com/projectcontour/contour/internal/timeout"
"github.com/projectcontour/contour/internal/workgroup"
"github.com/projectcontour/contour/internal/xds"
"github.com/projectcontour/contour/internal/xdscache"
xdscache_v2 "github.com/projectcontour/contour/internal/xdscache/v2"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
Expand Down Expand Up @@ -247,7 +248,7 @@ func doServe(log logrus.FieldLogger, ctx *serveContext) error {
return fmt.Errorf("error parsing request timeout: %w", err)
}

listenerConfig := contourv2.ListenerConfig{
listenerConfig := xdscache_v2.ListenerConfig{
UseProxyProto: ctx.useProxyProto,
HTTPAddress: ctx.httpAddr,
HTTPPort: ctx.httpPort,
Expand Down Expand Up @@ -276,13 +277,13 @@ func doServe(log logrus.FieldLogger, ctx *serveContext) error {

// Endpoints updates are handled directly by the EndpointsTranslator
// due to their high update rate and their orthogonal nature.
endpointHandler := contourv2.NewEndpointsTranslator(log.WithField("context", "endpointstranslator"))
endpointHandler := xdscache_v2.NewEndpointsTranslator(log.WithField("context", "endpointstranslator"))

resources := []contour.ResourceCache{
contourv2.NewListenerCache(listenerConfig, ctx.statsAddr, ctx.statsPort),
&contourv2.SecretCache{},
&contourv2.RouteCache{},
&contourv2.ClusterCache{},
resources := []xdscache.ResourceCache{
xdscache_v2.NewListenerCache(listenerConfig, ctx.statsAddr, ctx.statsPort),
&xdscache_v2.SecretCache{},
&xdscache_v2.RouteCache{},
&xdscache_v2.ClusterCache{},
endpointHandler,
}

Expand All @@ -292,7 +293,7 @@ func doServe(log logrus.FieldLogger, ctx *serveContext) error {
log.WithField("context", "xDS"))

// snapshotHandler is used to produce new snapshots when the internal state changes for any xDS resource.
snapshotHandler := contour.NewSnapshotHandler(snapshotCache, resources, log.WithField("context", "snapshotHandler"))
snapshotHandler := xdscache.NewSnapshotHandler(snapshotCache, resources, log.WithField("context", "snapshotHandler"))

// register observer for endpoints updates.
endpointHandler.Observer = contour.ComposeObservers(snapshotHandler)
Expand All @@ -306,7 +307,7 @@ func doServe(log logrus.FieldLogger, ctx *serveContext) error {
eventHandler := &contour.EventHandler{
HoldoffDelay: 100 * time.Millisecond,
HoldoffMaxDelay: 500 * time.Millisecond,
Observer: dag.ComposeObservers(append(contour.ObserversOf(resources), snapshotHandler)...),
Observer: dag.ComposeObservers(append(xdscache.ObserversOf(resources), snapshotHandler)...),
Builder: dag.Builder{
Source: dag.KubernetesCache{
RootNamespaces: ctx.proxyRootNamespaces(),
Expand Down Expand Up @@ -514,7 +515,7 @@ func doServe(log logrus.FieldLogger, ctx *serveContext) error {
switch ctx.XDSServerType {
case "contour":
grpcServer = xds.RegisterServer(
xds.NewContourServer(log, contour.ResourcesOf(resources)...),
xds.NewContourServer(log, xdscache.ResourcesOf(resources)...),
registry,
ctx.grpcOptions(log)...)
case "envoy":
Expand Down
6 changes: 3 additions & 3 deletions cmd/contour/servecontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"strings"
"time"

contourv2 "github.com/projectcontour/contour/internal/contour/v2"
envoyv2 "github.com/projectcontour/contour/internal/envoy/v2"
xdscache_v2 "github.com/projectcontour/contour/internal/xdscache/v2"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down Expand Up @@ -166,8 +166,8 @@ func newServeContext() *serveContext {
healthPort: 8000,
metricsAddr: "0.0.0.0",
metricsPort: 8000,
httpAccessLog: contourv2.DEFAULT_HTTP_ACCESS_LOG,
httpsAccessLog: contourv2.DEFAULT_HTTPS_ACCESS_LOG,
httpAccessLog: xdscache_v2.DEFAULT_HTTP_ACCESS_LOG,
httpsAccessLog: xdscache_v2.DEFAULT_HTTPS_ACCESS_LOG,
httpAddr: "0.0.0.0",
httpsAddr: "0.0.0.0",
httpPort: 8080,
Expand Down
4 changes: 2 additions & 2 deletions cmd/contour/shutdownmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"os"
"time"

contourv2 "github.com/projectcontour/contour/internal/contour/v2"
xdscache_v2 "github.com/projectcontour/contour/internal/xdscache/v2"
"github.com/prometheus/common/expfmt"
"github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
Expand All @@ -40,7 +40,7 @@ const shutdownReadyFile = "/ok"
const shutdownReadyCheckInterval = time.Second * 1

func prometheusLabels() []string {
return []string{contourv2.ENVOY_HTTP_LISTENER, contourv2.ENVOY_HTTPS_LISTENER}
return []string{xdscache_v2.ENVOY_HTTP_LISTENER, xdscache_v2.ENVOY_HTTPS_LISTENER}
}

type shutdownmanagerContext struct {
Expand Down
10 changes: 5 additions & 5 deletions internal/featuretests/envoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import (
"github.com/envoyproxy/go-control-plane/pkg/wellknown"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/any"
contourv2 "github.com/projectcontour/contour/internal/contour/v2"
"github.com/projectcontour/contour/internal/dag"
envoyv2 "github.com/projectcontour/contour/internal/envoy/v2"
"github.com/projectcontour/contour/internal/protobuf"
xdscache_v2 "github.com/projectcontour/contour/internal/xdscache/v2"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -291,8 +291,8 @@ func filterchaintlsfallback(fallbackSecret *v1.Secret, peerValidationContext *da
envoyv2.Filters(
envoyv2.HTTPConnectionManagerBuilder().
DefaultFilters().
RouteConfigName(contourv2.ENVOY_FALLBACK_ROUTECONFIG).
MetricsPrefix(contourv2.ENVOY_HTTPS_LISTENER).
RouteConfigName(xdscache_v2.ENVOY_FALLBACK_ROUTECONFIG).
MetricsPrefix(xdscache_v2.ENVOY_HTTPS_LISTENER).
AccessLoggers(envoyv2.FileAccessLogEnvoy("/dev/stdout")).
Get(),
),
Expand All @@ -304,7 +304,7 @@ func httpsFilterFor(vhost string) *envoy_api_v2_listener.Filter {
AddFilter(envoyv2.FilterMisdirectedRequests(vhost)).
DefaultFilters().
RouteConfigName(path.Join("https", vhost)).
MetricsPrefix(contourv2.ENVOY_HTTPS_LISTENER).
MetricsPrefix(xdscache_v2.ENVOY_HTTPS_LISTENER).
AccessLoggers(envoyv2.FileAccessLogEnvoy("/dev/stdout")).
Get()
}
Expand All @@ -326,7 +326,7 @@ func authzFilterFor(
},
}).
RouteConfigName(path.Join("https", vhost)).
MetricsPrefix(contourv2.ENVOY_HTTPS_LISTENER).
MetricsPrefix(xdscache_v2.ENVOY_HTTPS_LISTENER).
AccessLoggers(envoyv2.FileAccessLogEnvoy("/dev/stdout")).
Get()
}
Expand Down
23 changes: 12 additions & 11 deletions internal/featuretests/featuretests.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/golang/protobuf/ptypes/any"
projcontour "github.com/projectcontour/contour/apis/projectcontour/v1"
"github.com/projectcontour/contour/internal/contour"
contourv2 "github.com/projectcontour/contour/internal/contour/v2"
"github.com/projectcontour/contour/internal/dag"
"github.com/projectcontour/contour/internal/fixture"
"github.com/projectcontour/contour/internal/k8s"
Expand All @@ -38,6 +37,8 @@ import (
"github.com/projectcontour/contour/internal/sorter"
"github.com/projectcontour/contour/internal/workgroup"
"github.com/projectcontour/contour/internal/xds"
"github.com/projectcontour/contour/internal/xdscache"
xdscache_v2 "github.com/projectcontour/contour/internal/xdscache/v2"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
Expand All @@ -63,20 +64,20 @@ func setup(t *testing.T, opts ...interface{}) (cache.ResourceEventHandler, *Cont
log := fixture.NewTestLogger(t)
log.SetLevel(logrus.DebugLevel)

et := contourv2.NewEndpointsTranslator(log)
et := xdscache_v2.NewEndpointsTranslator(log)

conf := contourv2.ListenerConfig{}
conf := xdscache_v2.ListenerConfig{}
for _, opt := range opts {
if opt, ok := opt.(func(*contourv2.ListenerConfig)); ok {
if opt, ok := opt.(func(*xdscache_v2.ListenerConfig)); ok {
opt(&conf)
}
}

resources := []contour.ResourceCache{
contourv2.NewListenerCache(conf, statsAddress, statsPort),
&contourv2.SecretCache{},
&contourv2.RouteCache{},
&contourv2.ClusterCache{},
resources := []xdscache.ResourceCache{
xdscache_v2.NewListenerCache(conf, statsAddress, statsPort),
&xdscache_v2.SecretCache{},
&xdscache_v2.RouteCache{},
&xdscache_v2.ClusterCache{},
et,
}

Expand All @@ -95,7 +96,7 @@ func setup(t *testing.T, opts ...interface{}) (cache.ResourceEventHandler, *Cont
HoldoffMaxDelay: time.Duration(rand.Intn(500)) * time.Millisecond,
Observer: &contour.RebuildMetricsObserver{
Metrics: metrics.NewMetrics(r),
NextObserver: dag.ComposeObservers(contour.ObserversOf(resources)...),
NextObserver: dag.ComposeObservers(xdscache.ObserversOf(resources)...),
},
Builder: dag.Builder{
Source: dag.KubernetesCache{
Expand Down Expand Up @@ -128,7 +129,7 @@ func setup(t *testing.T, opts ...interface{}) (cache.ResourceEventHandler, *Cont
require.NoError(t, err)

srv := xds.RegisterServer(
xds.NewContourServer(log, contour.ResourcesOf(resources)...),
xds.NewContourServer(log, xdscache.ResourcesOf(resources)...),
r /* Prometheus registry */)

var g workgroup.Group
Expand Down
14 changes: 7 additions & 7 deletions internal/featuretests/listeners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
envoy_api_v2_auth "github.com/envoyproxy/go-control-plane/envoy/api/v2/auth"
envoy_api_v2_listener "github.com/envoyproxy/go-control-plane/envoy/api/v2/listener"
projcontour "github.com/projectcontour/contour/apis/projectcontour/v1"
contourv2 "github.com/projectcontour/contour/internal/contour/v2"
"github.com/projectcontour/contour/internal/dag"
envoyv2 "github.com/projectcontour/contour/internal/envoy/v2"
"github.com/projectcontour/contour/internal/fixture"
xdscache_v2 "github.com/projectcontour/contour/internal/xdscache/v2"
v1 "k8s.io/api/core/v1"
"k8s.io/api/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -552,7 +552,7 @@ func TestLDSStreamEmpty(t *testing.T) {
}

func TestLDSIngressHTTPUseProxyProtocol(t *testing.T) {
rh, c, done := setup(t, func(conf *contourv2.ListenerConfig) {
rh, c, done := setup(t, func(conf *xdscache_v2.ListenerConfig) {
conf.UseProxyProto = true
})
defer done()
Expand Down Expand Up @@ -608,7 +608,7 @@ func TestLDSIngressHTTPUseProxyProtocol(t *testing.T) {
}

func TestLDSIngressHTTPSUseProxyProtocol(t *testing.T) {
rh, c, done := setup(t, func(conf *contourv2.ListenerConfig) {
rh, c, done := setup(t, func(conf *xdscache_v2.ListenerConfig) {
conf.UseProxyProto = true
})
defer done()
Expand Down Expand Up @@ -701,7 +701,7 @@ func TestLDSIngressHTTPSUseProxyProtocol(t *testing.T) {
}

func TestLDSCustomAddressAndPort(t *testing.T) {
rh, c, done := setup(t, func(conf *contourv2.ListenerConfig) {
rh, c, done := setup(t, func(conf *xdscache_v2.ListenerConfig) {
conf.HTTPAddress = "127.0.0.100"
conf.HTTPPort = 9100
conf.HTTPSAddress = "127.0.0.200"
Expand Down Expand Up @@ -798,7 +798,7 @@ func TestLDSCustomAddressAndPort(t *testing.T) {
}

func TestLDSCustomAccessLogPaths(t *testing.T) {
rh, c, done := setup(t, func(conf *contourv2.ListenerConfig) {
rh, c, done := setup(t, func(conf *xdscache_v2.ListenerConfig) {
conf.HTTPAccessLog = "/tmp/http_access.log"
conf.HTTPSAccessLog = "/tmp/https_access.log"
})
Expand Down Expand Up @@ -879,7 +879,7 @@ func TestLDSCustomAccessLogPaths(t *testing.T) {
AddFilter(envoyv2.FilterMisdirectedRequests("kuard.example.com")).
DefaultFilters().
RouteConfigName("https/kuard.example.com").
MetricsPrefix(contourv2.ENVOY_HTTPS_LISTENER).
MetricsPrefix(xdscache_v2.ENVOY_HTTPS_LISTENER).
AccessLoggers(envoyv2.FileAccessLogEnvoy("/tmp/https_access.log")).
Get(),
nil, "h2", "http/1.1"),
Expand Down Expand Up @@ -994,7 +994,7 @@ func TestHTTPProxyHTTPS(t *testing.T) {
}

func TestHTTPProxyMinimumTLSVersion(t *testing.T) {
rh, c, done := setup(t, func(conf *contourv2.ListenerConfig) {
rh, c, done := setup(t, func(conf *xdscache_v2.ListenerConfig) {
conf.MinimumTLSVersion = envoy_api_v2_auth.TlsParameters_TLSv1_2
})

Expand Down
24 changes: 12 additions & 12 deletions internal/featuretests/timeouts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (

envoy_api_v2 "github.com/envoyproxy/go-control-plane/envoy/api/v2"
projcontour "github.com/projectcontour/contour/apis/projectcontour/v1"
contourv2 "github.com/projectcontour/contour/internal/contour/v2"
envoyv2 "github.com/projectcontour/contour/internal/envoy/v2"
"github.com/projectcontour/contour/internal/fixture"
"github.com/projectcontour/contour/internal/timeout"
xdscache_v2 "github.com/projectcontour/contour/internal/xdscache/v2"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -56,17 +56,17 @@ func TestTimeoutsNotSpecified(t *testing.T) {
}
rh.OnAdd(hp1)

c.Request(listenerType, contourv2.ENVOY_HTTP_LISTENER).Equals(&envoy_api_v2.DiscoveryResponse{
c.Request(listenerType, xdscache_v2.ENVOY_HTTP_LISTENER).Equals(&envoy_api_v2.DiscoveryResponse{
TypeUrl: listenerType,
Resources: resources(t,
&envoy_api_v2.Listener{
Name: contourv2.ENVOY_HTTP_LISTENER,
Name: xdscache_v2.ENVOY_HTTP_LISTENER,
Address: envoyv2.SocketAddress("0.0.0.0", 8080),
SocketOptions: envoyv2.TCPKeepaliveSocketOptions(),
FilterChains: envoyv2.FilterChains(envoyv2.HTTPConnectionManagerBuilder().
RouteConfigName(contourv2.ENVOY_HTTP_LISTENER).
MetricsPrefix(contourv2.ENVOY_HTTP_LISTENER).
AccessLoggers(envoyv2.FileAccessLogEnvoy(contourv2.DEFAULT_HTTP_ACCESS_LOG)).
RouteConfigName(xdscache_v2.ENVOY_HTTP_LISTENER).
MetricsPrefix(xdscache_v2.ENVOY_HTTP_LISTENER).
AccessLoggers(envoyv2.FileAccessLogEnvoy(xdscache_v2.DEFAULT_HTTP_ACCESS_LOG)).
DefaultFilters().
Get(),
),
Expand All @@ -75,7 +75,7 @@ func TestTimeoutsNotSpecified(t *testing.T) {
}

func TestNonZeroTimeoutsSpecified(t *testing.T) {
withTimeouts := func(conf *contourv2.ListenerConfig) {
withTimeouts := func(conf *xdscache_v2.ListenerConfig) {
conf.ConnectionIdleTimeout = timeout.DurationSetting(7 * time.Second)
conf.StreamIdleTimeout = timeout.DurationSetting(70 * time.Second)
conf.MaxConnectionDuration = timeout.DurationSetting(700 * time.Second)
Expand Down Expand Up @@ -109,17 +109,17 @@ func TestNonZeroTimeoutsSpecified(t *testing.T) {
}
rh.OnAdd(hp1)

c.Request(listenerType, contourv2.ENVOY_HTTP_LISTENER).Equals(&envoy_api_v2.DiscoveryResponse{
c.Request(listenerType, xdscache_v2.ENVOY_HTTP_LISTENER).Equals(&envoy_api_v2.DiscoveryResponse{
TypeUrl: listenerType,
Resources: resources(t,
&envoy_api_v2.Listener{
Name: contourv2.ENVOY_HTTP_LISTENER,
Name: xdscache_v2.ENVOY_HTTP_LISTENER,
Address: envoyv2.SocketAddress("0.0.0.0", 8080),
SocketOptions: envoyv2.TCPKeepaliveSocketOptions(),
FilterChains: envoyv2.FilterChains(envoyv2.HTTPConnectionManagerBuilder().
RouteConfigName(contourv2.ENVOY_HTTP_LISTENER).
MetricsPrefix(contourv2.ENVOY_HTTP_LISTENER).
AccessLoggers(envoyv2.FileAccessLogEnvoy(contourv2.DEFAULT_HTTP_ACCESS_LOG)).
RouteConfigName(xdscache_v2.ENVOY_HTTP_LISTENER).
MetricsPrefix(xdscache_v2.ENVOY_HTTP_LISTENER).
AccessLoggers(envoyv2.FileAccessLogEnvoy(xdscache_v2.DEFAULT_HTTP_ACCESS_LOG)).
DefaultFilters().
ConnectionIdleTimeout(timeout.DurationSetting(7 * time.Second)).
StreamIdleTimeout(timeout.DurationSetting(70 * time.Second)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// Package contour contains the translation business logic that listens
// to Kubernetes ResourceEventHandler events and translates those into
// additions/deletions in caches connected to the Envoy xDS gRPC API server.
package contour
package xdscache

import (
"github.com/projectcontour/contour/internal/dag"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package contour
package xdscache

import (
"math"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package contour
package xdscache

import (
"math"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import (
"sort"
"sync"

"github.com/projectcontour/contour/internal/contour"

envoy_api_v2 "github.com/envoyproxy/go-control-plane/envoy/api/v2"
resource "github.com/envoyproxy/go-control-plane/pkg/resource/v2"
"github.com/golang/protobuf/proto"
"github.com/projectcontour/contour/internal/contour"
"github.com/projectcontour/contour/internal/dag"
"github.com/projectcontour/contour/internal/envoy"
envoyv2 "github.com/projectcontour/contour/internal/envoy/v2"
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 8c32370

Please sign in to comment.