Skip to content

quantity() cel cost is too high #132370

Open
@liubog2008

Description

@liubog2008

What happened?

resource.Quantity is converted to int-or-string in CRD and cannot limit the maxLength of int-or-string. The cost of quantity(self) is too high and I cannot put it in a small array(maxItems=64)

I add maxLength but not worked.

                            storage:
                              anyOf:
                              - type: integer
                              - type: string
                              description: Storage defines the request size
                              pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
                              x-kubernetes-int-or-string: true
                              maxLength: 100
                              x-kubernetes-validations:
                              - rule: "quantity(self).isGreaterThan(quantity('0'))"
                                message: "test"

What did you expect to happen?

Decrease the cost of quantity() or provide a way to limit the maxLength of resource.Quantity

How can we reproduce it (as minimally and precisely as possible)?

type Spec struct {
    // maxItems=64
    Array []Item 
}

type Item struct {
    // rule="quantity(self).isGreaterThan(quantity('0'))"
    Size resource.Quantity
}

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
1.30

Cloud provider

kind

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, ...) and versions (if applicable)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions