mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 10:53:34 +00:00
rebase: update kubernetes to 1.30
updating kubernetes to 1.30 release Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
62ddcf715b
commit
e727bd351e
150
vendor/k8s.io/apiserver/pkg/cel/library/cost.go
generated
vendored
150
vendor/k8s.io/apiserver/pkg/cel/library/cost.go
generated
vendored
@ -79,6 +79,82 @@ func (l *CostEstimator) CallCost(function, overloadId string, args []ref.Val, re
|
||||
cost := strCost * regexCost
|
||||
return &cost
|
||||
}
|
||||
case "cidr", "isIP", "isCIDR":
|
||||
// IP and CIDR parsing is a string traversal.
|
||||
if len(args) >= 1 {
|
||||
cost := uint64(math.Ceil(float64(actualSize(args[0])) * common.StringTraversalCostFactor))
|
||||
return &cost
|
||||
}
|
||||
case "ip":
|
||||
// IP and CIDR parsing is a string traversal.
|
||||
if len(args) >= 1 {
|
||||
if overloadId == "cidr_ip" {
|
||||
// The IP member of the CIDR object is just accessing a field.
|
||||
// Nominal cost.
|
||||
cost := uint64(1)
|
||||
return &cost
|
||||
}
|
||||
|
||||
cost := uint64(math.Ceil(float64(actualSize(args[0])) * common.StringTraversalCostFactor))
|
||||
return &cost
|
||||
}
|
||||
case "ip.isCanonical":
|
||||
if len(args) >= 1 {
|
||||
// We have to parse the string and then compare the parsed string to the original string.
|
||||
// So we double the cost of parsing the string.
|
||||
cost := uint64(math.Ceil(float64(actualSize(args[0])) * 2 * common.StringTraversalCostFactor))
|
||||
return &cost
|
||||
}
|
||||
case "masked", "prefixLength", "family", "isUnspecified", "isLoopback", "isLinkLocalMulticast", "isLinkLocalUnicast":
|
||||
// IP and CIDR accessors are nominal cost.
|
||||
cost := uint64(1)
|
||||
return &cost
|
||||
case "containsIP":
|
||||
if len(args) >= 2 {
|
||||
cidrSize := actualSize(args[0])
|
||||
otherSize := actualSize(args[1])
|
||||
|
||||
// This is the base cost of comparing two byte lists.
|
||||
// We will compare only up to the length of the CIDR prefix in bytes, so use the cidrSize twice.
|
||||
cost := uint64(math.Ceil(float64(cidrSize+cidrSize) * common.StringTraversalCostFactor))
|
||||
|
||||
if overloadId == "cidr_contains_ip_string" {
|
||||
// If we are comparing a string, we must parse the string to into the right type, so add the cost of traversing the string again.
|
||||
cost += uint64(math.Ceil(float64(otherSize) * common.StringTraversalCostFactor))
|
||||
|
||||
}
|
||||
|
||||
return &cost
|
||||
}
|
||||
case "containsCIDR":
|
||||
if len(args) >= 2 {
|
||||
cidrSize := actualSize(args[0])
|
||||
otherSize := actualSize(args[1])
|
||||
|
||||
// This is the base cost of comparing two byte lists.
|
||||
// We will compare only up to the length of the CIDR prefix in bytes, so use the cidrSize twice.
|
||||
cost := uint64(math.Ceil(float64(cidrSize+cidrSize) * common.StringTraversalCostFactor))
|
||||
|
||||
// As we are comparing if a CIDR is within another CIDR, we first mask the base CIDR and
|
||||
// also compare the CIDR bits.
|
||||
// This has an additional cost of the length of the IP being traversed again, plus 1.
|
||||
cost += uint64(math.Ceil(float64(cidrSize)*common.StringTraversalCostFactor)) + 1
|
||||
|
||||
if overloadId == "cidr_contains_cidr_string" {
|
||||
// If we are comparing a string, we must parse the string to into the right type, so add the cost of traversing the string again.
|
||||
cost += uint64(math.Ceil(float64(otherSize) * common.StringTraversalCostFactor))
|
||||
}
|
||||
|
||||
return &cost
|
||||
}
|
||||
case "quantity", "isQuantity":
|
||||
if len(args) >= 1 {
|
||||
cost := uint64(math.Ceil(float64(actualSize(args[0])) * common.StringTraversalCostFactor))
|
||||
return &cost
|
||||
}
|
||||
case "sign", "asInteger", "isInteger", "asApproximateFloat", "isGreaterThan", "isLessThan", "compareTo", "add", "sub":
|
||||
cost := uint64(1)
|
||||
return &cost
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -225,6 +301,80 @@ func (l *CostEstimator) EstimateCallCost(function, overloadId string, target *ch
|
||||
// worst case size of result is that every char is returned as separate find result.
|
||||
return &checker.CallEstimate{CostEstimate: strCost.Multiply(regexCost), ResultSize: &checker.SizeEstimate{Min: 0, Max: sz.Max}}
|
||||
}
|
||||
case "cidr", "isIP", "isCIDR":
|
||||
if target != nil {
|
||||
sz := l.sizeEstimate(args[0])
|
||||
return &checker.CallEstimate{CostEstimate: sz.MultiplyByCostFactor(common.StringTraversalCostFactor)}
|
||||
}
|
||||
case "ip":
|
||||
if target != nil && len(args) >= 1 {
|
||||
if overloadId == "cidr_ip" {
|
||||
// The IP member of the CIDR object is just accessing a field.
|
||||
// Nominal cost.
|
||||
return &checker.CallEstimate{CostEstimate: checker.CostEstimate{Min: 1, Max: 1}}
|
||||
}
|
||||
|
||||
sz := l.sizeEstimate(args[0])
|
||||
return &checker.CallEstimate{CostEstimate: sz.MultiplyByCostFactor(common.StringTraversalCostFactor)}
|
||||
} else if target != nil {
|
||||
// The IP member of a CIDR is a just accessing a field, nominal cost.
|
||||
return &checker.CallEstimate{CostEstimate: checker.CostEstimate{Min: 1, Max: 1}}
|
||||
}
|
||||
case "ip.isCanonical":
|
||||
if target != nil && len(args) >= 1 {
|
||||
sz := l.sizeEstimate(args[0])
|
||||
// We have to parse the string and then compare the parsed string to the original string.
|
||||
// So we double the cost of parsing the string.
|
||||
return &checker.CallEstimate{CostEstimate: sz.MultiplyByCostFactor(2 * common.StringTraversalCostFactor)}
|
||||
}
|
||||
case "masked", "prefixLength", "family", "isUnspecified", "isLoopback", "isLinkLocalMulticast", "isLinkLocalUnicast":
|
||||
// IP and CIDR accessors are nominal cost.
|
||||
return &checker.CallEstimate{CostEstimate: checker.CostEstimate{Min: 1, Max: 1}}
|
||||
case "containsIP":
|
||||
if target != nil && len(args) >= 1 {
|
||||
// The base cost of the function is the cost of comparing two byte lists.
|
||||
// The byte lists will be either ipv4 or ipv6 so will have a length of 4, or 16 bytes.
|
||||
sz := checker.SizeEstimate{Min: 4, Max: 16}
|
||||
|
||||
// We have to compare the two strings to determine if the CIDR/IP is in the other CIDR.
|
||||
ipCompCost := sz.Add(sz).MultiplyByCostFactor(common.StringTraversalCostFactor)
|
||||
|
||||
if overloadId == "cidr_contains_ip_string" {
|
||||
// If we are comparing a string, we must parse the string to into the right type, so add the cost of traversing the string again.
|
||||
ipCompCost = ipCompCost.Add(checker.CostEstimate(l.sizeEstimate(args[0])).MultiplyByCostFactor(common.StringTraversalCostFactor))
|
||||
}
|
||||
|
||||
return &checker.CallEstimate{CostEstimate: ipCompCost}
|
||||
}
|
||||
case "containsCIDR":
|
||||
if target != nil && len(args) >= 1 {
|
||||
// The base cost of the function is the cost of comparing two byte lists.
|
||||
// The byte lists will be either ipv4 or ipv6 so will have a length of 4, or 16 bytes.
|
||||
sz := checker.SizeEstimate{Min: 4, Max: 16}
|
||||
|
||||
// We have to compare the two strings to determine if the CIDR/IP is in the other CIDR.
|
||||
ipCompCost := sz.Add(sz).MultiplyByCostFactor(common.StringTraversalCostFactor)
|
||||
|
||||
// As we are comparing if a CIDR is within another CIDR, we first mask the base CIDR and
|
||||
// also compare the CIDR bits.
|
||||
// This has an additional cost of the length of the IP being traversed again, plus 1.
|
||||
ipCompCost = ipCompCost.Add(sz.MultiplyByCostFactor(common.StringTraversalCostFactor))
|
||||
ipCompCost = ipCompCost.Add(checker.CostEstimate{Min: 1, Max: 1})
|
||||
|
||||
if overloadId == "cidr_contains_cidr_string" {
|
||||
// If we are comparing a string, we must parse the string to into the right type, so add the cost of traversing the string again.
|
||||
ipCompCost = ipCompCost.Add(checker.CostEstimate(l.sizeEstimate(args[0])).MultiplyByCostFactor(common.StringTraversalCostFactor))
|
||||
}
|
||||
|
||||
return &checker.CallEstimate{CostEstimate: ipCompCost}
|
||||
}
|
||||
case "quantity", "isQuantity":
|
||||
if target != nil {
|
||||
sz := l.sizeEstimate(args[0])
|
||||
return &checker.CallEstimate{CostEstimate: sz.MultiplyByCostFactor(common.StringTraversalCostFactor)}
|
||||
}
|
||||
case "sign", "asInteger", "isInteger", "asApproximateFloat", "isGreaterThan", "isLessThan", "compareTo", "add", "sub":
|
||||
return &checker.CallEstimate{CostEstimate: checker.CostEstimate{Min: 1, Max: 1}}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user