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/envoy: Regex "MaxProgramSize" too small #2043

Closed
stevesloka opened this issue Dec 12, 2019 · 7 comments · Fixed by #2047
Closed

internal/envoy: Regex "MaxProgramSize" too small #2043

stevesloka opened this issue Dec 12, 2019 · 7 comments · Fixed by #2047
Assignees
Labels
priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Milestone

Comments

@stevesloka
Copy link
Member

When deploying HTTPProxy resources which use Contains header matcher conditions, there's an error getting thrown by Envoy:

ERRO[0291] regex '.*Chrome.*' RE2 program size of 38 > max program size of 10. Increase configured max program size if necessary. 

I didn't think much of this error, but working on a different feature for Contour I found that at times all my routes would disappear from Envoy's config and I wasn't able to get them back. I found that removing the "header contains" Conditions from my Proxies, Envoy started working well again.

Other symptoms I've seen are a lack of xDS updates between Contour<>Envoy. At times, I was able to check Contour's RDS (e.g. contour cli rds) and I would see the proper config, however, it was not mirrored in Envoy's admin config.

At the moment, I've taken out the MaxProgramSize from being configured (https://github.com/projectcontour/contour/blob/master/internal/envoy/regex.go#L27) and am using Envoy's default of 100.

@jpeach
Copy link
Contributor

jpeach commented Dec 12, 2019

see also envoyproxy/envoy#9174

@jpeach jpeach added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Dec 12, 2019
@jpeach jpeach added this to the 1.1.0 milestone Dec 12, 2019
@jpeach jpeach self-assigned this Dec 12, 2019
@jpeach
Copy link
Contributor

jpeach commented Dec 12, 2019

RE2 program sizes:

regex size
.*foo.*' 35
foo.*[abcd]+ooo.* 43
x-envoy-(a|b|c) 15
x-envoy-(a|b|c)-[grep]{3} 28
a.*b.*c.*d.*e.*f.*g.* 109

So there's no clear relationship between regex length and program size other than that .* cost about 15.

@davecheney
Copy link
Contributor

Can we use the re2 library to compute the cost of the regex so we can program the correct value in Envoy?

@jpeach
Copy link
Contributor

jpeach commented Dec 12, 2019

re2 is a C++ library, so that's probably tricky. If the goal is to accept whatever the user gives us, then I'd say we should just send a very high value.

@davecheney
Copy link
Contributor

I'm sorry I wasn't clear. I thought there was a version of re2 available in go, but I think I was mistaken -- go's regex library is based on re2, or something, anyway, I wasn't thinking straight.

@jpeach
Copy link
Contributor

jpeach commented Dec 12, 2019

The xDS error handling behaviour is #1176

jpeach added a commit to jpeach/contour that referenced this issue Dec 12, 2019
There's no obvious way to know what a reasonable regex program
size is (and that's not really what the RE2 program size number
means).  However, Envoy makes us send something here and if it's
too low, it will NACK the update and Contour will not handle that
gracefully. So, we send a large number that should be enough for
all reasonable regex cases.

This fixes projectcontour#2043.

Signed-off-by: James Peach <jpeach@vmware.com>
@jpeach
Copy link
Contributor

jpeach commented Dec 12, 2019 via email

jpeach added a commit to jpeach/contour that referenced this issue Dec 12, 2019
There's no obvious way to know what a reasonable regex program
size is (and that's not really what the RE2 program size number
means).  However, Envoy makes us send something here and if it's
too low, it will NACK the update and Contour will not handle that
gracefully. So, we send a large number that should be enough for
all reasonable regex cases.

This fixes projectcontour#2043.

Signed-off-by: James Peach <jpeach@vmware.com>
jpeach added a commit to jpeach/contour that referenced this issue Dec 12, 2019
There's no obvious way to know what a reasonable regex program
size is (and that's not really what the RE2 program size number
means).  However, Envoy makes us send something here and if it's
too low, it will NACK the update and Contour will not handle that
gracefully. So, we send a large number that should be enough for
all reasonable regex cases.

This fixes projectcontour#2043.

Signed-off-by: James Peach <jpeach@vmware.com>
jpeach added a commit that referenced this issue Dec 12, 2019
There's no obvious way to know what a reasonable regex program
size is (and that's not really what the RE2 program size number
means).  However, Envoy makes us send something here and if it's
too low, it will NACK the update and Contour will not handle that
gracefully. So, we send a large number that should be enough for
all reasonable regex cases.

This fixes #2043.

Signed-off-by: James Peach <jpeach@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants