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

validate all xds resources before returning the translation result #5148

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

zhaohuabing
Copy link
Member

@zhaohuabing zhaohuabing commented Jan 25, 2025

This PR enforces validation for all generated xDS resources before sending them to the Envoy fleet.

Related to: #5147
Release Notes: No

2025-01-25T05:07:21.922Z	ERROR	xds-translator	runner/runner.go:85	failed to translate xds ir	{"runner": "xds-translator", "error": "invalid RouteConfiguration.VirtualHosts[0]: embedded message failed validation | caused by: invalid VirtualHost.Routes[0]: embedded message failed validation | caused by: invalid Route.Route: embedded message failed validation | caused by: invalid RouteAction.RetryPolicy: embedded message failed validation | caused by: invalid RetryPolicy.RetryBackOff: embedded message failed validation | caused by: invalid RetryPolicy_RetryBackOff.BaseInterval: value must be greater than 0s"}

@zhaohuabing zhaohuabing requested a review from a team as a code owner January 25, 2025 05:10
@zhaohuabing zhaohuabing marked this pull request as draft January 25, 2025 05:10
@zhaohuabing zhaohuabing force-pushed the fix-5147 branch 2 times, most recently from befa1a4 to 4d53353 Compare January 25, 2025 05:20
Copy link

codecov bot commented Jan 25, 2025

Codecov Report

Attention: Patch coverage is 63.10680% with 38 lines in your changes missing coverage. Please review.

Project coverage is 66.88%. Comparing base (f7a10eb) to head (984b460).

Files with missing lines Patch % Lines
internal/xds/types/resourceversiontable.go 23.07% 10 Missing ⚠️
internal/xds/translator/authorization.go 20.00% 0 Missing and 8 partials ⚠️
internal/utils/proto/proto.go 71.42% 4 Missing and 2 partials ⚠️
internal/xds/translator/translator.go 16.66% 2 Missing and 3 partials ⚠️
internal/xds/translator/custom_response.go 33.33% 0 Missing and 4 partials ⚠️
internal/xds/translator/compressor.go 25.00% 0 Missing and 3 partials ⚠️
internal/xds/translator/basicauth.go 33.33% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5148      +/-   ##
==========================================
+ Coverage   66.85%   66.88%   +0.03%     
==========================================
  Files         210      209       -1     
  Lines       32979    32917      -62     
==========================================
- Hits        22047    22018      -29     
+ Misses       9592     9573      -19     
+ Partials     1340     1326      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhaohuabing zhaohuabing force-pushed the fix-5147 branch 3 times, most recently from 6eb31de to a03807e Compare January 25, 2025 06:18
@@ -131,6 +131,12 @@ func (t *Translator) Translate(xdsIR *ir.Xds) (*types.ResourceVersionTable, erro
}
}

// Validate all the xds resources in the table before returning
// This is necessary to catch any misconfigurations that might have been missed during translation
if err := tCtx.ValidateAll(); err != nil {
Copy link
Member Author

@zhaohuabing zhaohuabing Jan 25, 2025

Choose a reason for hiding this comment

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

This is the key change, the rest are minor refactors around the proto validation.

@@ -82,10 +82,7 @@ func buildHCMBasicAuthFilter(basicAuth *ir.BasicAuth) (*hcmv3.HttpFilter, error)
},
},
}
if err = basicAuthProto.ValidateAll(); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

Validation in individual filer translators are not required anymore, as they'll be validated inside the proto.ToAnyWithValidation function before converting to any.

@zhaohuabing zhaohuabing marked this pull request as ready for review January 25, 2025 06:26
@zhaohuabing zhaohuabing reopened this Jan 27, 2025
@zhaohuabing zhaohuabing marked this pull request as draft January 27, 2025 10:44
@zhaohuabing zhaohuabing force-pushed the fix-5147 branch 3 times, most recently from abd87f7 to 5faed17 Compare January 27, 2025 11:13
@zhaohuabing zhaohuabing marked this pull request as ready for review January 27, 2025 11:17
@arkodg arkodg added this to the Backlog milestone Jan 27, 2025
@guydc
Copy link
Contributor

guydc commented Jan 27, 2025

should we CP to 1.3.0 ?

@arkodg
Copy link
Contributor

arkodg commented Jan 27, 2025

@guydc , Haubing will be away this week, and we won't be able to get this into v1.3.0, we could get it into a patch release.
for now / v1.3.0 #5147 can be fixed with a CEL validation, I'll work on getting it into v1.3.0

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