diff --git a/pkg/daemon/controller_linux.go b/pkg/daemon/controller_linux.go index 37086f59e0a..a89c6b7b2c8 100644 --- a/pkg/daemon/controller_linux.go +++ b/pkg/daemon/controller_linux.go @@ -533,7 +533,6 @@ func (c *Controller) handlePod(key string) error { utilruntime.HandleError(fmt.Errorf("invalid resource key: %s", key)) return nil } - klog.Infof("handle qos update for pod %s/%s", namespace, name) pod, err := c.podsLister.Pods(namespace).Get(name) if err != nil { @@ -550,6 +549,8 @@ func (c *Controller) handlePod(key string) error { return err } + klog.Infof("handle qos update for pod %s/%s", namespace, name) + podName := pod.Name if pod.Annotations[fmt.Sprintf(util.VMAnnotationTemplate, util.OvnProvider)] != "" { podName = pod.Annotations[fmt.Sprintf(util.VMAnnotationTemplate, util.OvnProvider)] @@ -557,7 +558,7 @@ func (c *Controller) handlePod(key string) error { // set default nic bandwidth ifaceID := ovs.PodNameToPortName(podName, pod.Namespace, util.OvnProvider) - err = ovs.SetInterfaceBandwidth(podName, pod.Namespace, ifaceID, pod.Annotations[util.EgressRateAnnotation], pod.Annotations[util.IngressRateAnnotation]) + err = ovs.SetInterfaceBandwidth(podName, pod.Namespace, ifaceID, pod.Annotations[util.IngressRateAnnotation], pod.Annotations[util.EgressRateAnnotation]) if err != nil { klog.Error(err) return err diff --git a/pkg/ovs/ovs-vsctl_linux.go b/pkg/ovs/ovs-vsctl_linux.go index a378c129295..7c97d00b3ac 100644 --- a/pkg/ovs/ovs-vsctl_linux.go +++ b/pkg/ovs/ovs-vsctl_linux.go @@ -15,6 +15,10 @@ import ( func SetInterfaceBandwidth(podName, podNamespace, iface, ingress, egress string) error { ingressMPS, _ := strconv.Atoi(ingress) ingressKPS := ingressMPS * 1000 + ingressBurst := ingressKPS * 8 / 10 + egressMPS, _ := strconv.Atoi(egress) + egressBPS := egressMPS * 1000 * 1000 + interfaceList, err := ovsFind("interface", "name", fmt.Sprintf("external-ids:iface-id=%s", iface)) if err != nil { klog.Error(err) @@ -35,22 +39,21 @@ func SetInterfaceBandwidth(podName, podNamespace, iface, ingress, egress string) for _, ifName := range interfaceList { // ingress_policing_rate is in Kbps - err := ovsSet("interface", ifName, fmt.Sprintf("ingress_policing_rate=%d", ingressKPS), fmt.Sprintf("ingress_policing_burst=%d", ingressKPS*8/10)) + klog.V(3).Infof("Set ingress policing rate to %d Kbps on interface %s", ingressKPS, ifName) + err := ovsSet("interface", ifName, fmt.Sprintf("ingress_policing_rate=%d", ingressKPS), fmt.Sprintf("ingress_policing_burst=%d", ingressBurst)) if err != nil { klog.Error(err) return err } - egressMPS, _ := strconv.Atoi(egress) - egressBPS := egressMPS * 1000 * 1000 - if egressBPS > 0 { + klog.V(3).Infof("Set HTB QoS queue record for interface %s with egress %d Bps", iface, egressBPS) queueUID, err := SetHtbQosQueueRecord(podName, podNamespace, iface, egressBPS, queueIfaceUIDMap) if err != nil { klog.Error(err) return err } - + klog.V(3).Infof("Bound QoS queue for interface %s", ifName) if err = SetQosQueueBinding(podName, podNamespace, ifName, iface, queueUID, qosIfaceUIDMap); err != nil { klog.Error(err) return err @@ -62,6 +65,7 @@ func SetInterfaceBandwidth(podName, podNamespace, iface, ingress, egress string) klog.Error(err) return err } + if qosType != util.HtbQos { continue }