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
Fix nested CallExpr cost estimation #571
Fix nested CallExpr cost estimation #571
Conversation
Please add a link in the description to k8s issue where this was discovered. |
/gcbrun |
@TristonianJones I'd like to backport the fix to Kubernetes 1.24 and 1.23 if possible. Once this is ready, would it be possible to backport to cel-go v0.10 and v0.9? These are the CEL versions those Kubernetes releases depend on (https://github.com/kubernetes/kubernetes/blob/release-1.24/go.mod#L267, https://github.com/kubernetes/kubernetes/blob/release-1.23/go.mod#L272) |
/gcbrun |
@jpbetz I'll cherry pick the squashed commit back into the previous releases with minor version bumps, e.g. v0.11.5, v0.10.2, v0.9.1. Sound good? |
Thank you so much. I realize this is tedious. |
/gcbrun |
/gcbrun |
/gcbrun |
/gcbrun |
LGTM |
/gcbrun |
* Fix nested CallExpr cost estimation. * Add TODO about merging isScalar/ComputedSize. (cherry picked from commit 1aae83a)
* Fix nested CallExpr cost estimation. * Add TODO about merging isScalar/ComputedSize. (cherry picked from commit 1aae83a)
* Fix nested CallExpr cost estimation. * Add TODO about merging isScalar/ComputedSize. (cherry picked from commit 1aae83a)
* Fix nested CallExpr cost estimation. * Add TODO about merging isScalar/ComputedSize.
This PR fixes instances where cost estimation is used on expressions where a
CallExpr
is nested inside of anotherCallExpr
andmath.MaxUint64
is incorrectly returned. The test case included with this PR shows an example of where this can happen;==
is treated as a function call/CallExpr
, and will callsizeEstimate
on its left and right-hand expressions. sizeEstimate will then try to call AstNode.ComputedSize before trying EstimateSize and finally returning math.MaxUint64 for an upper limit.That constant will get returned for operator-based
CallExpr
s insideCallExpr
s whenever the inner one lacks anEstimateSize
, such as withlist.size()
. Instead, this PR checks forCallExpr
insideSizeEstimate
and returns a min/max cost of 1.The original issue was first reported in kubernetes/kubernetes#111769.