Skip to content

Commit e9b5722

Browse files
Merge pull request #122369 from cici37/automated-cherry-pick-of-#122193-upstream-release-1.29
Automated cherry pick of #122193: Keep presence cost to 0 to ensure backward compatibility. Kubernetes-commit: 2991f6e2165003c6fe50fb46a95d7215f9e65179
2 parents 037e27f + ae9ed66 commit e9b5722

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/cel/environment/base.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,18 @@ var baseOpts = []VersionedOptions{
6262
library.URLs(),
6363
library.Regex(),
6464
library.Lists(),
65+
66+
// cel-go v0.17.7 change the cost of has() from 0 to 1, but also provided the CostEstimatorOptions option to preserve the old behavior, so we enabled it at the same time we bumped our cel version to v0.17.7.
67+
// Since it is a regression fix, we apply it uniformly to all code use v0.17.7.
68+
cel.CostEstimatorOptions(checker.PresenceTestHasCost(false)),
6569
},
6670
ProgramOptions: []cel.ProgramOption{
6771
cel.EvalOptions(cel.OptOptimize, cel.OptTrackCost),
6872
cel.CostLimit(celconfig.PerCallLimit),
73+
74+
// cel-go v0.17.7 change the cost of has() from 0 to 1, but also provided the CostEstimatorOptions option to preserve the old behavior, so we enabled it at the same time we bumped our cel version to v0.17.7.
75+
// Since it is a regression fix, we apply it uniformly to all code use v0.17.7.
76+
cel.CostTrackerOptions(interpreter.PresenceTestHasCost(false)),
6977
},
7078
},
7179
{
@@ -113,14 +121,6 @@ var baseOpts = []VersionedOptions{
113121
IntroducedVersion: version.MajorMinor(1, 29),
114122
EnvOptions: []cel.EnvOption{
115123
ext.Sets(),
116-
// cel-go v0.17.7 introduced CostEstimatorOptions.
117-
// Previous the presence has a cost of 0 but cel fixed it to 1. We still set to 0 here to avoid breaking changes.
118-
cel.CostEstimatorOptions(checker.PresenceTestHasCost(false)),
119-
},
120-
ProgramOptions: []cel.ProgramOption{
121-
// cel-go v0.17.7 introduced CostTrackerOptions.
122-
// Previous the presence has a cost of 0 but cel fixed it to 1. We still set to 0 here to avoid breaking changes.
123-
cel.CostTrackerOptions(interpreter.PresenceTestHasCost(false)),
124124
},
125125
},
126126
}

0 commit comments

Comments
 (0)