Skip to content

Commit

Permalink
Fix qos bug 24.12.23
Browse files Browse the repository at this point in the history
Signed-off-by: dolibali <[email protected]>
  • Loading branch information
dolibali committed Dec 23, 2024
1 parent 3245c91 commit 3631040
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
6 changes: 4 additions & 2 deletions pkg/daemon/controller_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,12 @@ 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))
return nil
}
klog.Infof("handle qos update for pod %s/%s", namespace, name)

pod, err := c.podsLister.Pods(namespace).Get(name)
if err != nil {
Expand All @@ -557,7 +557,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
Expand All @@ -574,6 +574,8 @@ 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 {
Expand Down
29 changes: 20 additions & 9 deletions pkg/ovs/ovs-vsctl_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
func SetInterfaceBandwidth(podName, podNamespace, iface, ingress, egress string) error {
ingressMPS, _ := strconv.Atoi(ingress)
ingressKPS := ingressMPS * 1000
ingressBurst := ingressKPS * 8 / 10

interfaceList, err := ovsFind("interface", "name", fmt.Sprintf("external-ids:iface-id=%s", iface))
if err != nil {
klog.Error(err)
Expand All @@ -33,35 +35,42 @@ 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
err := ovsSet("interface", ifName, fmt.Sprintf("ingress_policing_rate=%d", ingressKPS), fmt.Sprintf("ingress_policing_burst=%d", ingressKPS*8/10))
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
} else {

Check failure on line 47 in pkg/ovs/ovs-vsctl_linux.go

View workflow job for this annotation

GitHub Actions / Build kube-ovn

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
klog.V(3).Infof("Successfully set ingress policing rate to %d Kbps on interface %s", ingressKPS, ifName)
}

if egressBPS > 0 {
queueUID, err := SetHtbQosQueueRecord(podName, podNamespace, iface, egressBPS, queueIfaceUIDMap)
if err != nil {
klog.Error(err)
return err
}
} else {

Check failure on line 56 in pkg/ovs/ovs-vsctl_linux.go

View workflow job for this annotation

GitHub Actions / Build kube-ovn

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
klog.V(3).Infof("Successfully set HTB QoS queue record for interface %s with egress %d Bps", iface, egressBPS)
}

if err = SetQosQueueBinding(podName, podNamespace, ifName, iface, queueUID, qosIfaceUIDMap); err != nil {
klog.Error(err)
return err
}
} else {

Check failure on line 63 in pkg/ovs/ovs-vsctl_linux.go

View workflow job for this annotation

GitHub Actions / Build kube-ovn

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
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
}
Expand All @@ -74,7 +83,9 @@ 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 {

Check failure on line 86 in pkg/ovs/ovs-vsctl_linux.go

View workflow job for this annotation

GitHub Actions / Build kube-ovn

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
klog.V(3).Infof("Successfully removed rate limit for queue ID %s in pod %v/%v", queueID, podNamespace, podName)
}
}
}

Expand Down

0 comments on commit 3631040

Please sign in to comment.