diff --git a/pkg/describe/describe.go b/pkg/describe/describe.go index 924e745b0..d88095ac2 100644 --- a/pkg/describe/describe.go +++ b/pkg/describe/describe.go @@ -871,7 +871,7 @@ func describePod(pod *corev1.Pod, events *corev1.EventList) (string, error) { } } describeVolumes(pod.Spec.Volumes, w, "") - w.Write(LEVEL_0, "QoS Class:\t%s\n", qos.PodQOSClass(pod)) + w.Write(LEVEL_0, "QoS Class:\t%s\n", qos.GetPodQOS(pod)) printLabelsMultiline(w, "Node-Selectors", pod.Spec.NodeSelector) printPodTolerationsMultiline(w, "Tolerations", pod.Spec.Tolerations) describeTopologySpreadConstraints(pod.Spec.TopologySpreadConstraints, w, "") diff --git a/pkg/util/qos/qos.go b/pkg/util/qos/qos.go index 87183a095..16a8846a7 100644 --- a/pkg/util/qos/qos.go +++ b/pkg/util/qos/qos.go @@ -28,20 +28,20 @@ func isSupportedQoSComputeResource(name core.ResourceName) bool { return supportedQoSComputeResources.Has(string(name)) } -// PodQOSClass returns the QoS class of a pod persisted in the PodStatus. -// If QOSClass is empty, it returns value of GetPodQOS() which computes pod's QoS class. -func PodQOSClass(pod *core.Pod) core.PodQOSClass { +// GetPodQOS returns the QoS class of a pod persisted in the PodStatus.QOSClass field. +// If PodStatus.QOSClass is empty, it returns value of ComputePodQOS() which evaluates pod's QoS class. +func GetPodQOS(pod *core.Pod) core.PodQOSClass { if pod.Status.QOSClass != "" { return pod.Status.QOSClass } - return GetPodQOS(pod) + return ComputePodQOS(pod) } -// GetPodQOS returns the QoS class of a pod. +// ComputePodQOS evaluates the list of containers to determine a pod's QoS class. This function is expensive. // A pod is besteffort if none of its containers have specified any requests or limits. // A pod is guaranteed only when requests and limits are specified for all the containers and they are equal. // A pod is burstable if limits and requests do not match across all containers. -func GetPodQOS(pod *core.Pod) core.PodQOSClass { +func ComputePodQOS(pod *core.Pod) core.PodQOSClass { requests := core.ResourceList{} limits := core.ResourceList{} zeroQuantity := resource.MustParse("0")