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

internal/xds: convert xDS resources for the envoy xDS server #3087

Merged
merged 1 commit into from
Nov 3, 2020

Conversation

jpeach
Copy link
Contributor

@jpeach jpeach commented Nov 2, 2020

Add a snapshotter interfact to paper over the go-control-plane API
bifurcation. Use this to populate v3 and v2 resources in the snapshot
cache.

This updates #1898.

Signed-off-by: James Peach [email protected]

@jpeach
Copy link
Contributor Author

jpeach commented Nov 2, 2020

This doesn't work. AFAICT the listeners get populated and send correctly, but perhaps Envoy doesn't like them for some reason. At any rate, the HTTP listener never shows up in the Envoy admin endpoint.

@codecov
Copy link

codecov bot commented Nov 2, 2020

Codecov Report

Merging #3087 into main will decrease coverage by 0.44%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3087      +/-   ##
==========================================
- Coverage   73.58%   73.14%   -0.45%     
==========================================
  Files         101      103       +2     
  Lines        6360     6401      +41     
==========================================
+ Hits         4680     4682       +2     
- Misses       1577     1617      +40     
+ Partials      103      102       -1     
Impacted Files Coverage Δ
cmd/contour/serve.go 0.00% <0.00%> (ø)
internal/protobuf/helpers.go 79.41% <0.00%> (-13.70%) ⬇️
internal/xds/hash.go 0.00% <0.00%> (ø)
internal/xds/v2/snapshotter.go 0.00% <0.00%> (ø)
internal/xds/v3/snapshotter.go 0.00% <0.00%> (ø)
internal/xdscache/snapshot.go 9.52% <0.00%> (-0.48%) ⬇️
internal/dag/cache.go 96.13% <0.00%> (+0.77%) ⬆️

@jpeach
Copy link
Contributor Author

jpeach commented Nov 2, 2020

This doesn't work. AFAICT the listeners get populated and send correctly, but perhaps Envoy doesn't like them for some reason. At any rate, the HTTP listener never shows up in the Envoy admin endpoint.

OK I figured out what is going on. Here's the debug log that gives us the clue:

2020/11/02 19:29:17 returning 2 of 2 rewritten *envoy_api_v2.Listener resources
2020/11/02 19:29:17 getting 1 "type.googleapis.com/envoy.config.listener.v3.Listener" resources

We report adding 2 listeners to the snapshot, but the snapshot only emits 1. I'm calling v3.NewSnapshot() which calls v3.NewResources. NewResources indexes the resources by name, but does it using a type switch on the xDS v3 types. Since we are using the xDS v2 types (on purpose!), they all end up being named "", which is clearly idiotic.

@jpeach jpeach force-pushed the xds-conversion-envoy branch from 135d523 to c7d1553 Compare November 2, 2020 09:15
@jpeach jpeach marked this pull request as ready for review November 2, 2020 09:15
// any instance of Envoy to connect to Contour regardless of the
// service-node flag configured on Envoy.
type ConstantHash string
type ConstantHashV2 struct{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth moving this into internal/xds/v2, and the v3 bits into internal/xds/v3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that I'd rather leave it for now. If I move the 2 implementations I have to either duplicate the "contour" value, or leave the CONSTANT_HASH_VALUE const behind. I don't mind moving them, but I didn't like either of those options very much.

internal/xdscache/snapshot.go Outdated Show resolved Hide resolved
internal/xdscache/snapshot.go Outdated Show resolved Hide resolved
internal/xdscache/snapshot.go Outdated Show resolved Hide resolved
Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple more nits but otherwise LGTM

case config.ContourServerType:
contour_xds_v3.RegisterServer(contour_xds_v3.NewContourServer(log, xdscache.ResourcesOf(resources)...), grpcServer)

// Check an internal feature flag to disable xDS v2 endpoints. This is strictly for testing.
if config.GetenvOr("CONTOUR_INTERNAL_DISABLE_XDSV2", "N") != "N" {
if config.GetenvOr("CONTOUR_INTERNAL_DISABLE_XDSV2", "N") == "N" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, guess we all missed this on the last PR :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:oof:

internal/xdscache/snapshot.go Outdated Show resolved Hide resolved
@@ -101,3 +103,15 @@ func AnyMessageTypeOf(msg proto.Message) string {
a := MustMarshalAny(msg)
return a.TypeUrl
}

/// MustMarshalJSON marshals msg to indented JSON.
func MustMarshalJSON(msg proto.Message) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this being used anywhere, can remove if that's the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up having to rewrite it in various ad-hoc debugging, so even though it's not used I'd like to keep it for future debug logging :)

@jpeach jpeach force-pushed the xds-conversion-envoy branch from 000987e to a6ba9f7 Compare November 2, 2020 21:35
@stevesloka
Copy link
Member

I see lots of log messages for this:

[2020-11-02 21:38:17.769][1][warning][misc] [source/common/protobuf/message_validator_impl.cc:21] Deprecated field: type envoy.type.matcher.v3.RegexMatcher.GoogleRE2 Using deprecated option 'envoy.type.matcher.v3.RegexMatcher.GoogleRE2.max_program_size' from file regex.proto. This configuration will be removed from Envoy soon. Please see https://www.envoyproxy.io/docs/envoy/latest/version_history/version_history for details. If continued use of this field is absolutely necessary, see https://www.envoyproxy.io/docs/envoy/latest/configuration/operations/runtime#using-runtime-overrides-for-deprecated-features for how to apply a temporary and highly discouraged override.

Let me look into what needs to happen to remove that, it's not breaking, just very log spammy.

@jpeach
Copy link
Contributor Author

jpeach commented Nov 2, 2020

I see lots of log messages for this:

[2020-11-02 21:38:17.769][1][warning][misc] [source/common/protobuf/message_validator_impl.cc:21] Deprecated field: type envoy.type.matcher.v3.RegexMatcher.GoogleRE2 Using deprecated option 'envoy.type.matcher.v3.RegexMatcher.GoogleRE2.max_program_size' from file regex.proto. This configuration will be removed from Envoy soon. Please see https://www.envoyproxy.io/docs/envoy/latest/version_history/version_history for details. If continued use of this field is absolutely necessary, see https://www.envoyproxy.io/docs/envoy/latest/configuration/operations/runtime#using-runtime-overrides-for-deprecated-features for how to apply a temporary and highly discouraged override.

Let me look into what needs to happen to remove that, it's not breaking, just very log spammy.

That's interesting ... they must be checking the deprecation attributes after the protobuf migration.

@jpeach jpeach force-pushed the xds-conversion-envoy branch from a6ba9f7 to 1d2e79b Compare November 3, 2020 00:05
Copy link
Member

@stevesloka stevesloka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Add a snapshotter interface to paper over the go-control-plane API
bifurcation. Use this to populate v3 and v2 resources in the snapshot
cache.

This updates projectcontour#1898.

Signed-off-by: James Peach <[email protected]>
@jpeach jpeach force-pushed the xds-conversion-envoy branch from 37d2286 to ac979b0 Compare November 3, 2020 20:10
@jpeach jpeach merged commit abb1462 into projectcontour:main Nov 3, 2020
@jpeach jpeach deleted the xds-conversion-envoy branch November 3, 2020 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants