mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-06 19:52:42 +00:00
Modified LimitRangeItem.Kind to LimitRangeItem.Type, added example files
This commit is contained in:
@@ -131,21 +131,21 @@ func PodLimitFunc(limitRange *api.LimitRange, kind string, obj runtime.Object) e
|
||||
switch k {
|
||||
case api.ResourceMemory:
|
||||
enforced = v.Value()
|
||||
switch limit.Kind {
|
||||
case "pods":
|
||||
switch limit.Type {
|
||||
case api.LimitTypePod:
|
||||
observed = podMem
|
||||
err = fmt.Errorf("Maximum memory usage per pod is %s", v.String())
|
||||
case "containers":
|
||||
case api.LimitTypeContainer:
|
||||
observed = maxContainerMem
|
||||
err = fmt.Errorf("Maximum memory usage per container is %s", v.String())
|
||||
}
|
||||
case api.ResourceCPU:
|
||||
enforced = v.MilliValue()
|
||||
switch limit.Kind {
|
||||
case "pods":
|
||||
switch limit.Type {
|
||||
case api.LimitTypePod:
|
||||
observed = podCPU
|
||||
err = fmt.Errorf("Maximum CPU usage per pod is %s, but requested %s", v.String(), resource.NewMilliQuantity(observed, resource.DecimalSI))
|
||||
case "containers":
|
||||
case api.LimitTypeContainer:
|
||||
observed = maxContainerCPU
|
||||
err = fmt.Errorf("Maximum CPU usage per container is %s", v.String())
|
||||
}
|
||||
@@ -161,21 +161,21 @@ func PodLimitFunc(limitRange *api.LimitRange, kind string, obj runtime.Object) e
|
||||
switch k {
|
||||
case api.ResourceMemory:
|
||||
enforced = v.Value()
|
||||
switch limit.Kind {
|
||||
case "pods":
|
||||
switch limit.Type {
|
||||
case api.LimitTypePod:
|
||||
observed = podMem
|
||||
err = fmt.Errorf("Minimum memory usage per pod is %s", v.String())
|
||||
case "containers":
|
||||
case api.LimitTypeContainer:
|
||||
observed = maxContainerMem
|
||||
err = fmt.Errorf("Minimum memory usage per container is %s", v.String())
|
||||
}
|
||||
case api.ResourceCPU:
|
||||
enforced = v.MilliValue()
|
||||
switch limit.Kind {
|
||||
case "pods":
|
||||
switch limit.Type {
|
||||
case api.LimitTypePod:
|
||||
observed = podCPU
|
||||
err = fmt.Errorf("Minimum CPU usage per pod is %s", v.String())
|
||||
case "containers":
|
||||
case api.LimitTypeContainer:
|
||||
observed = maxContainerCPU
|
||||
err = fmt.Errorf("Minimum CPU usage per container is %s", v.String())
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ func TestPodLimitFunc(t *testing.T) {
|
||||
Spec: api.LimitRangeSpec{
|
||||
Limits: []api.LimitRangeItem{
|
||||
{
|
||||
Kind: "pods",
|
||||
Type: api.LimitTypePod,
|
||||
Max: api.ResourceList{
|
||||
api.ResourceCPU: resource.MustParse("200m"),
|
||||
api.ResourceMemory: resource.MustParse("4Gi"),
|
||||
@@ -42,7 +42,7 @@ func TestPodLimitFunc(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
Kind: "containers",
|
||||
Type: api.LimitTypeContainer,
|
||||
Max: api.ResourceList{
|
||||
api.ResourceCPU: resource.MustParse("100m"),
|
||||
api.ResourceMemory: resource.MustParse("2Gi"),
|
||||
|
Reference in New Issue
Block a user