Open verdverm opened 2 years ago
Interesting. Not very high priority, it seems, but may be worth considering.
Funny, but not funny, just this week several of us spent a while trying to interpret a pod container's memory request value that the Kubernetes API server had converted to 'm' units—1/1,000 of a byte—but that we were mistakenly reading as megabytes.
@verdverm: can you support to the specific schema and documentation that supports this feature?
FTR: to me 1m
reads as a duration value, meaning 1 minute.
@verdverm is this any generally-accepted precedent outside of Kubernetes?
hmm, both m
and kubernetes seem to have their quirks.
I guess the higher level question is how does one apply bound type constraints to values which look like strings?
For example, as an operator, I may want to limit devs by having the following in a definition they must unify against.
timeout: <= 30m
// how to compare durations? We don't have a type for datetimecpu: <= 2
// how to compare when a dev (validly) writes 100m
This sounds a bit like the discussion in #1368
Perhaps the answer is in the stdlib?
Another thing that could be helpful is something like
cpu: <= 2 @error(type=string,msg="cpu must be a numerical value and cannot be of the form '100m")
<- making this up
Indeed m
also reads to me as either minutes or meters, depending on context. Milliseconds is typically ms
, per the actual standard unit.
Will try to keep this in mind when looking at Kubernetes resources.
@niemeyer I think the k8s unit of measurement is non-standard for 1/1000 of a CPU core. In my example I'm using m
for a duration and this magic k8s unit.
I think there are a couple of issues being discussed from that, so probably best if I break out the new ones.
More generally here, there are some fields which accept these modified numbers, but which don't translate into numeric numbers, and thus it is a difficult exercise for the reader to create constraints for such values. Port values from k8s would be another thorny one.
This hasn't been noted yet, but consider that CUE currently supports some SI multipliers, but not any SI divisors, of which m
is 10^-3.^1
This hasn't been noted yet, but consider that CUE currently supports some SI multipliers, but not any SI divisors, of which m is 10^-3.1
I'm just a bystander here, but I would support neither of these as a rule. These are prefixes rather than units, and most are meaningless to Cue's audience.
Yes, but as mentioned, some symbols are already supported for multipliers, as per the spec: ^1
multiplier = ( "K" | "M" | "G" | "T" | "P" ) [ "i" ]
Is your feature request related to a problem? Please describe.
Kubernetes supports setting cpu lim/req with millis such as
100m
. Creating schemas and constraints for these numeric values does not seem possible.Describe the solution you'd like
Support
m
as a numeric suffix. It's value is1m == 0.001
or1000m == 1
.Maybe there are more suffixes for other numerical values
<1
that would follow naturally?Describe alternatives you've considered
string parsing and computations via a struct