Comments (13)
/sig api-machinery
from kubernetes.
We have schemas at runtime don't we? So even though we don't compile, we should be able to run unstructured through UnstructuredToVal
and get a correctly typed runtime object?
As a short term workaround, duration(object.duration) >= duration(\"2h\")
should work.
from kubernetes.
Not only duration
format but others as well:
kubernetes/staging/src/k8s.io/apiserver/pkg/cel/common/values.go
Lines 132 to 162 in c6b3a2f
In addition to these, there seem to be different types for maplist and setlist, causing subtle differences CEL for how expressions operate on these values:
kubernetes/staging/src/k8s.io/apiserver/pkg/cel/common/values.go
Lines 105 to 129 in c6b3a2f
from kubernetes.
UnstructuredToVal
is primarily for encoding maximum sizes etc for static cost checking, so the few differences seem to be limited to the formats which yield different types:
I meant common.UnstructuredToVal
. I don't see anything in UnstructuredToVal that I wouldn't want applied to ValidationAdmissionPolicy. duration, date, date-time and byte all need to be coerced, but there is also numeric handling that seems appropriate. And yes, the handling of maps, lists and sets for equality is important.
from kubernetes.
Note that changing a field from type string
to type duration
, even for runtime, is a breaking change that is observable with expressions like type(object.duration)
EDIT: There are other ways to observe the breaking change too, this is just one example.
from kubernetes.
/cc
I agree that it would be great to transfer object to CEL value in VAP as what has been done for CRD validation rule. Since VAP is in GA and it would be a breaking change so a feature gate might be needed. Thanks for bringing it up!
from kubernetes.
+1 to the feature gate approach.
from kubernetes.
/triage accepted
from kubernetes.
/cc
from kubernetes.
@liggitt Is this the one you'd be okay with just fixing w/o a feature gate? It is possible to depend on the broken behavior but it's VERY unlikely (depending on a runtime type check, or expecting a duration to be a string, not a CEL duration type)
from kubernetes.
@liggitt Is this the one you'd be okay with just fixing w/o a feature gate?
what's the proposed fix?
from kubernetes.
@liggitt Is this the one you'd be okay with just fixing w/o a feature gate?
what's the proposed fix?
To change all CEL environments (VAP, MatchConditions) which expose a Kubernetes object to CEL to first call UnstructuredToVal
so that the schema is considered in the CEL type.
from kubernetes.
We have schemas at runtime don't we?
I ... didn't think we did for admission of CRDs
from kubernetes.
Related Issues (20)
- [flaky test] : [It] [sig-storage] In-tree Volumes [Driver: local] [LocalVolumeType: dir-link-bindmounted] [Testpattern: Pre-provisioned PV (default fs)] volumes should store data HOT 2
- HPA with container metrics fails when any pod is not in a ready state HOT 6
- Add support for applying fsgroup with ReadWriteOncePod volume type HOT 2
- [FG:InPlacePodVerticalScaling] Emit a events when resize status changes HOT 2
- CEL unit tests - `TestFilter` (`filter_test.go`) + `AuthorizeWithSelector` Subtests Incorrectly Passing @ master due to CEL environment caching HOT 9
- [Failing Test] integration: scheduler_perf HOT 17
- Status of APIServingWithRoutine gate HOT 8
- DRA: Pod termination slow when referencing resource claims HOT 29
- Add a constants.go to podresources HOT 4
- go vet error "non-constant format string" with upcoming go 1.24 release HOT 13
- DRA: draplugin fails silently if vital parameter is missing HOT 1
- topologySpreadConstraints not working as expected HOT 4
- CEL library: a cmp function or a diff func
- [SidecarContainers] improve testing of termination Status of sidecar containers HOT 3
- [Proposal] plugin-granular scheduling cache maintenance mechanism HOT 2
- volume leak when delete a pod with inline csi during node reboot HOT 3
- API emulation versioning seems break Cohabitating Resources overwriting HOT 3
- Headless service end point update problem HOT 14
- Coding for testcase of function in secret HOT 2
- PVC goes into Lost state HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kubernetes.