Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LimitError ¶
type LimitError struct {
Field string // "cpu" or "memory"
Value string // the limit string as supplied
Reason string // why it cannot be represented
}
LimitError reports a resource limit string that cannot be turned into a ResourceSpec field. Errors are data: the caller gets the field, the offending value and the reason as fields, and never has to match on a formatted message to tell which limit was bad.
func (*LimitError) Error ¶
func (e *LimitError) Error() string
type ResourceSpec ¶
ResourceSpec defines limits
func ParseResourceSpec ¶
func ParseResourceSpec(cpu, mem string) (ResourceSpec, error)
ParseResourceSpec converts operator-supplied cpu and memory limit strings into a ResourceSpec.
It is the SINGLE source of truth for what a limit string means. core/schema validates manifests by calling this function rather than reimplementing the formats, so "the manifest was accepted" and "the limit can be applied" are one statement instead of two implementations that drift apart. That is structural, not a convention to remember: core/cgroups imports only internal/safeio, so core/schema can depend on it with no cycle.
An empty string means "no limit for this resource": the field stays zero and no error is returned, because a manifest that names no limit is not an error. Every other unrepresentable input returns a *LimitError. What this function must never do - and what GAPI-DIV-049 was - is return a zero field with a nil error for a non-empty limit: Create writes a limit only when the field is positive, so a discarded parse error produced an agent with no containment and no log line to say so.