diff --git a/pkg/daemon/controller_linux.go b/pkg/daemon/controller_linux.go index 539e00e1b6f..a89c6b7b2c8 100644 --- a/pkg/daemon/controller_linux.go +++ b/pkg/daemon/controller_linux.go @@ -528,7 +528,6 @@ func (c *Controller) getPolicyRouting(subnet *kubeovnv1.Subnet) ([]netlink.Rule, } func (c *Controller) handlePod(key string) error { - klog.V(3).Infof("v3 log start success") namespace, name, err := cache.SplitMetaNamespaceKey(key) if err != nil { utilruntime.HandleError(fmt.Errorf("invalid resource key: %s", key)) @@ -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)] @@ -574,8 +575,6 @@ func (c *Controller) handlePod(key string) error { return err } - klog.V(3).Infof("handle qos update for pod %s/%s", namespace, name) - // set multus-nic bandwidth attachNets, err := nadutils.ParsePodNetworkAnnotation(pod) if err != nil { diff --git a/pkg/ovs/ovs-vsctl_linux.go b/pkg/ovs/ovs-vsctl_linux.go index ba843e3a149..7c97d00b3ac 100644 --- a/pkg/ovs/ovs-vsctl_linux.go +++ b/pkg/ovs/ovs-vsctl_linux.go @@ -16,6 +16,8 @@ func SetInterfaceBandwidth(podName, podNamespace, iface, ingress, egress string) 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 { @@ -35,41 +37,34 @@ func SetInterfaceBandwidth(podName, podNamespace, iface, ingress, egress string) return err } - egressMPS, _ := strconv.Atoi(egress) - egressBPS := egressMPS * 1000 * 1000 - for _, ifName := range interfaceList { // ingress_policing_rate is in Kbps + 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 - } else { - klog.V(3).Infof("Successfully set ingress policing rate to %d Kbps on interface %s", ingressKPS, ifName) - } + } 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 - } else { - klog.V(3).Infof("Successfully set HTB QoS queue record for interface %s with egress %d Bps", iface, egressBPS) - } - + } + 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 - } else { - klog.V(3).Infof("Successfully bound QoS queue for interface %s", ifName) - } + } } else { if qosUID, ok := qosIfaceUIDMap[iface]; ok { qosType, err := ovsGet("qos", qosUID, "type", "") if err != nil { klog.Error(err) return err - } + } if qosType != util.HtbQos { continue @@ -83,9 +78,7 @@ func SetInterfaceBandwidth(podName, podNamespace, iface, ingress, egress string) if _, err := Exec("remove", "queue", queueID, "other_config", "max-rate"); err != nil { klog.Error(err) return fmt.Errorf("failed to remove rate limit for queue in pod %v/%v, %w", podNamespace, podName, err) - } else { - klog.V(3).Infof("Successfully removed rate limit for queue ID %s in pod %v/%v", queueID, podNamespace, podName) - } + } } }