Skip to content

Commit

Permalink
Merge branch 'v1.1-adobe' into v1.1-adobe-merge-slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
lrouquette committed Feb 25, 2020
2 parents 7beb906 + 8e096bb commit c0503c4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
8 changes: 8 additions & 0 deletions ADOBE_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ v{C major}.{C minor}.{C fix}-{A major}.{A minor}.{A fix}-adobe

- set `merge_slashes=true` on HTTP connection manager

## v1.1.0-2.2.3-adobe

- eager load tls secrets only

## v1.1.0-2.2.2-adobe

- throttle logs when waiting for xDS updates

## v1.1.0-2.2.1-adobe

- fix cds sync issue causing the update to potentially wait indefinitely
Expand Down
10 changes: 8 additions & 2 deletions cmd/contour/serve_adobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
clientset "github.com/projectcontour/contour/apis/generated/clientset/versioned"
"github.com/projectcontour/contour/internal/contour"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
)
Expand Down Expand Up @@ -60,7 +61,12 @@ func initCache(client *kubernetes.Clientset, contourClient *clientset.Clientset,
}

// Secrets
secrets, err := client.CoreV1().Secrets("").List(metav1.ListOptions{})
// only eager load tls secrets as they are the most used (if not the only one)
// opaque and other generic secrets will still be discovered via the informer
// see internal/dag/secrets.go:isValidSecret()
secrets, err := client.CoreV1().Secrets("").List(metav1.ListOptions{
FieldSelector: "type=" + string(v1.SecretTypeTLS),
})
if err != nil {
return err
}
Expand All @@ -70,7 +76,7 @@ func initCache(client *kubernetes.Clientset, contourClient *clientset.Clientset,
sCached++
}
}
eh.WithField("count", sCached).WithField("found", len(secrets.Items)).Info("secrets")
eh.WithField("count", sCached).WithField("found", len(secrets.Items)).WithField("type", v1.SecretTypeTLS).Info("secrets")

// Endpoints
endpoints, err := client.CoreV1().Endpoints("").List(metav1.ListOptions{})
Expand Down
25 changes: 20 additions & 5 deletions internal/grpc/xds_adobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const (
// time is stored as nanoseconds: any adjustments to the above consts should
// ensure maxWaitCount fits into 16 bits (e.g. < 32767)
maxWaitCount = int16(maxWaitTime / waitSleepTime)

// log throttling config
logInterval = 1 * time.Second
// divisor is used in the modulo operation
logDivisor = int16(logInterval / waitSleepTime)
)

// "In order for EDS resources to be known or tracked by Envoy, there must exist an applied Cluster definition (e.g. sourced via CDS).
Expand Down Expand Up @@ -63,7 +68,7 @@ func synchronizeXDS(req *envoy_api_v2.DiscoveryRequest, res Resource, log *logru
freeToGo = true
break
}
log.WithField("wait_count", waitCount).WithField("wait_count_max", maxWaitCount).Info("wait_on_cds")
throttledLog(waitCount, log, "wait_on_cds")

case envoy.ListenerType:
// After CDS and EDS
Expand All @@ -75,10 +80,10 @@ func synchronizeXDS(req *envoy_api_v2.DiscoveryRequest, res Resource, log *logru
}
// Split these logs to ease potential troubleshooting
if len(streamCache[streamId{TypeUrl: envoy.ClusterType, NodeId: req.Node.Id}]) > 0 {
log.WithField("wait_count", waitCount).WithField("wait_count_max", maxWaitCount).Info("wait_on_cds")
throttledLog(waitCount, log, "wait_on_cds")
}
if len(streamCache[streamId{TypeUrl: envoy.EndpointType, NodeId: req.Node.Id}]) > 0 {
log.WithField("wait_count", waitCount).WithField("wait_count_max", maxWaitCount).Info("wait_on_eds")
throttledLog(waitCount, log, "wait_on_eds")
}

case envoy.RouteType:
Expand Down Expand Up @@ -110,13 +115,13 @@ func synchronizeXDS(req *envoy_api_v2.DiscoveryRequest, res Resource, log *logru
break
}
unknown := diff(envoy.ClusterType, req.Node.Id, clusters)
log.WithField("unknown", unknown).WithField("wait_count", waitCount).WithField("wait_count_max", maxWaitCount).Info("wait_on_cds")
throttledLogWithFields(waitCount, log, logrus.Fields{"unknown": unknown}, "wait_on_cds")
break

// TODO: also check route.GetVhds()
}
}
log.WithField("wait_count", waitCount).WithField("wait_count_max", maxWaitCount).Info("wait_on_lds")
throttledLog(waitCount, log, "wait_on_lds")

case envoy.SecretType:
// uh? let's do after listener
Expand Down Expand Up @@ -289,3 +294,13 @@ func getResources(r Resource, names []string) (resources []proto.Message) {
}
return resources
}

func throttledLog(wc int16, log *logrus.Entry, msg string) {
throttledLogWithFields(wc, log, logrus.Fields{}, msg)
}

func throttledLogWithFields(wc int16, log *logrus.Entry, fields logrus.Fields, msg string) {
if wc%logDivisor == 0 {
log.WithField("wait_count", wc).WithField("wait_count_max", maxWaitCount).WithFields(fields).Info(msg)
}
}

0 comments on commit c0503c4

Please sign in to comment.