Skip to content

Commit e92d5c5

Browse files
Merge pull request #16918 from juanvallejo/jvallejo/add-limit-limitratio-describe-project
Automatic merge from submit-queue. add Limit & Limit/Request columns Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1278683 Adds the "Limit" and "Limit/Request" columns seen when describing a LimitRange to the "describe" output of projects. **Before** ``` $ oc describe project myproject ... Resource limits: Name: limits Type Resource Min Max Default ---- -------- --- --- --- Pod cpu 200m 2 - Pod memory 6Mi 1Gi - Container cpu 100m 2 300m Container memory 4Mi 1Gi 200Mi ``` **After** ``` $ oc describe project myproject ... Resource limits: Name: limits Type Resource Min Max Default Limit Limit/Request ---- -------- --- --- --- ----- ------------- Pod cpu 200m 2 - - - Pod memory 6Mi 1Gi - - - Container cpu 100m 2 300m 300m 10 Container memory 4Mi 1Gi 200Mi 200Mi - ``` cc @openshift/cli-review
2 parents d3924ff + e27fc1b commit e92d5c5

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

pkg/oc/cli/describe/describer.go

+24-4
Original file line numberDiff line numberDiff line change
@@ -1017,13 +1017,15 @@ func (d *ProjectDescriber) Describe(namespace, name string, settings kprinters.D
10171017
for i := range limitRangeList.Items {
10181018
limitRange := &limitRangeList.Items[i]
10191019
fmt.Fprintf(out, "\tName:\t%s\n", limitRange.Name)
1020-
fmt.Fprintf(out, "\tType\tResource\tMin\tMax\tDefault\n")
1021-
fmt.Fprintf(out, "\t----\t--------\t---\t---\t---\n")
1020+
fmt.Fprintf(out, "\tType\tResource\tMin\tMax\tDefault\tLimit\tLimit/Request\n")
1021+
fmt.Fprintf(out, "\t----\t--------\t---\t---\t---\t-----\t-------------\n")
10221022
for i := range limitRange.Spec.Limits {
10231023
item := limitRange.Spec.Limits[i]
10241024
maxResources := item.Max
10251025
minResources := item.Min
10261026
defaultResources := item.Default
1027+
defaultRequestResources := item.DefaultRequest
1028+
ratio := item.MaxLimitRequestRatio
10271029

10281030
set := map[kapi.ResourceName]bool{}
10291031
for k := range maxResources {
@@ -1035,12 +1037,20 @@ func (d *ProjectDescriber) Describe(namespace, name string, settings kprinters.D
10351037
for k := range defaultResources {
10361038
set[k] = true
10371039
}
1040+
for k := range defaultRequestResources {
1041+
set[k] = true
1042+
}
1043+
for k := range ratio {
1044+
set[k] = true
1045+
}
10381046

10391047
for k := range set {
10401048
// if no value is set, we output -
10411049
maxValue := "-"
10421050
minValue := "-"
10431051
defaultValue := "-"
1052+
defaultLimitValue := "-"
1053+
ratioValue := "-"
10441054

10451055
maxQuantity, maxQuantityFound := maxResources[k]
10461056
if maxQuantityFound {
@@ -1057,8 +1067,18 @@ func (d *ProjectDescriber) Describe(namespace, name string, settings kprinters.D
10571067
defaultValue = defaultQuantity.String()
10581068
}
10591069

1060-
msg := "\t%v\t%v\t%v\t%v\t%v\n"
1061-
fmt.Fprintf(out, msg, item.Type, k, minValue, maxValue, defaultValue)
1070+
defaultLimitQuantity, defaultLimitQuantityFound := defaultResources[k]
1071+
if defaultLimitQuantityFound {
1072+
defaultLimitValue = defaultLimitQuantity.String()
1073+
}
1074+
1075+
ratioQuantity, ratioQuantityFound := ratio[k]
1076+
if ratioQuantityFound {
1077+
ratioValue = ratioQuantity.String()
1078+
}
1079+
1080+
msg := "\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n"
1081+
fmt.Fprintf(out, msg, item.Type, k, minValue, maxValue, defaultValue, defaultLimitValue, ratioValue)
10621082
}
10631083
}
10641084
}

0 commit comments

Comments
 (0)