Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix qos bug #4866

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/daemon/controller_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -550,14 +549,16 @@ 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)]
}

// 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 Down
14 changes: 9 additions & 5 deletions pkg/ovs/ovs-vsctl_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -62,6 +65,7 @@ func SetInterfaceBandwidth(podName, podNamespace, iface, ingress, egress string)
klog.Error(err)
return err
}

if qosType != util.HtbQos {
continue
}
Expand Down
Loading