Skip to content

Commit d6ba6ee

Browse files
committed
ovs: fix memory leak in qos
1 parent 056b4cf commit d6ba6ee

File tree

3 files changed

+27
-35
lines changed

3 files changed

+27
-35
lines changed

.github/workflows/build-x86-image.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ jobs:
271271
- build-kube-ovn
272272
- build-e2e-binaries
273273
runs-on: ubuntu-22.04
274-
timeout-minutes: 15
274+
timeout-minutes: 20
275275
strategy:
276276
fail-fast: false
277277
matrix:

dist/images/Dockerfile.base

+16-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ RUN cd /usr/src/ && \
2121
# ovsdb-tool: add optional server id parameter for "join-cluster" command
2222
curl -s https://github.com/kubeovn/ovs/commit/ebf61515da71fa2e23125a92859fbdb96dcbffe7.patch | git apply && \
2323
# Add jitter parameter patch for netem qos
24-
curl -s https://github.com/kubeovn/ovs/commit/2eaaf89fbf3ee2172719ed10d045fd79900edc8e.patch | git apply
24+
curl -s https://github.com/kubeovn/ovs/commit/2eaaf89fbf3ee2172719ed10d045fd79900edc8e.patch | git apply && \
25+
# fix memory leak in qos
26+
curl -s https://github.com/kubeovn/ovs/commit/6a4dd2f4b9311a227cc26fef7c398ae9b241311b.patch | git apply
2527

2628
RUN cd /usr/src/ && git clone -b branch-22.12 --depth=1 https://github.com/ovn-org/ovn.git && \
2729
cd ovn && \
@@ -69,14 +71,12 @@ RUN mkdir /packages/ && \
6971

7072
FROM ubuntu:22.04
7173

72-
ARG DEBUG=false
7374
ARG DEBIAN_FRONTEND=noninteractive
7475
RUN apt update && apt upgrade -y && apt install ca-certificates python3 hostname libunwind8 netbase \
7576
ethtool iproute2 ncat libunbound-dev procps libatomic1 kmod iptables python3-netifaces python3-sortedcontainers \
7677
tcpdump ipset curl uuid-runtime openssl inetutils-ping arping ndisc6 \
7778
logrotate dnsutils net-tools strongswan strongswan-pki libcharon-extra-plugins \
7879
libcharon-extauth-plugins libstrongswan-extra-plugins libstrongswan-standard-plugins -y --no-install-recommends && \
79-
if [ "${DEBUG}" = "true" ]; then apt install -y --no-install-recommends valgrind; fi && \
8080
rm -rf /var/lib/apt/lists/* && \
8181
rm -rf /etc/localtime
8282

@@ -94,12 +94,6 @@ ENV KUBE_VERSION="v1.27.2"
9494
RUN curl -L https://dl.k8s.io/${KUBE_VERSION}/kubernetes-client-linux-${ARCH}.tar.gz | tar -xz -C . && cp ./kubernetes/client/bin/kubectl /usr/bin/kubectl \
9595
&& chmod +x /usr/bin/kubectl && rm -rf ./kubernetes
9696

97-
RUN --mount=type=bind,target=/packages,from=ovs-builder,source=/packages \
98-
dpkg -i /packages/openvswitch-*.deb /packages/python3-openvswitch*.deb && \
99-
dpkg -i --ignore-depends=openvswitch-switch,openvswitch-common /packages/ovn-*.deb && \
100-
if [ "${DEBUG}" = "true" ]; then dpkg -i --ignore-depends=openvswitch-switch,openvswitch-common /packages/*.ddeb; fi && \
101-
rm -rf /var/lib/openvswitch/pki/
102-
10397
ENV BFDD_VERSION="v0.5.4"
10498
RUN curl -sSf -L --retry 3 -o /usr/local/bin/bfdd-control https://github.com/bobz965/bfd-binary-for-kube-ovn-cni/releases/download/${BFDD_VERSION}/bfdd-control && \
10599
curl -sSf -L --retry 3 -o /usr/local/bin/bfdd-beacon https://github.com/bobz965/bfd-binary-for-kube-ovn-cni/releases/download/${BFDD_VERSION}/bfdd-beacon && \
@@ -111,4 +105,17 @@ RUN dumb_init_arch="x86_64"; \
111105
curl -sSf -L --retry 5 -o /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_${dumb_init_arch} && \
112106
chmod +x /usr/bin/dumb-init
113107

108+
RUN --mount=type=bind,target=/packages,from=ovs-builder,source=/packages \
109+
dpkg -i /packages/openvswitch-*.deb /packages/python3-openvswitch*.deb && \
110+
dpkg -i --ignore-depends=openvswitch-switch,openvswitch-common /packages/ovn-*.deb && \
111+
rm -rf /var/lib/openvswitch/pki/
112+
113+
ARG DEBUG=false
114+
RUN --mount=type=bind,target=/packages,from=ovs-builder,source=/packages \
115+
if [ "${DEBUG}" = "true" ]; then \
116+
apt update && apt install -y --no-install-recommends valgrind && \
117+
rm -rf /var/lib/apt/lists/* && \
118+
dpkg -i --ignore-depends=openvswitch-switch,openvswitch-common /packages/*.ddeb; \
119+
fi
120+
114121
ENTRYPOINT ["/usr/bin/dumb-init", "--"]

test/e2e/kube-ovn/qos/qos.go

+10-25
Original file line numberDiff line numberDiff line change
@@ -75,27 +75,23 @@ func waitOvsQosForPod(f *framework.Framework, table string, pod *corev1.Pod, exp
7575
var _ = framework.Describe("[group:qos]", func() {
7676
f := framework.NewDefaultFramework("qos")
7777

78-
var subnetName, namespaceName string
78+
var podName, namespaceName string
7979
var podClient *framework.PodClient
80-
var subnetClient *framework.SubnetClient
8180

8281
ginkgo.BeforeEach(func() {
8382
podClient = f.PodClient()
84-
subnetClient = f.SubnetClient()
8583
namespaceName = f.Namespace.Name
84+
podName = "pod-" + framework.RandomSuffix()
8685
})
8786
ginkgo.AfterEach(func() {
88-
if subnetName != "" {
89-
ginkgo.By("Deleting subnet " + subnetName)
90-
subnetClient.DeleteSync(subnetName)
91-
}
87+
ginkgo.By("Deleting pod " + podName)
88+
podClient.DeleteSync(podName)
9289
})
9390

9491
framework.ConformanceIt("should support netem QoS", func() {
9592
f.SkipVersionPriorTo(1, 9, "Support for netem QoS was introduced in v1.9")
9693

97-
name := "pod-" + framework.RandomSuffix()
98-
ginkgo.By("Creating pod " + name)
94+
ginkgo.By("Creating pod " + podName)
9995
latency, jitter, limit, loss := 600, 400, 2000, 10
10096
annotations := map[string]string{
10197
util.NetemQosLatencyAnnotation: strconv.Itoa(latency),
@@ -105,7 +101,7 @@ var _ = framework.Describe("[group:qos]", func() {
105101
if !f.VersionPriorTo(1, 12) {
106102
annotations[util.NetemQosJitterAnnotation] = strconv.Itoa(jitter)
107103
}
108-
pod := framework.MakePod(namespaceName, name, nil, annotations, "", nil, nil)
104+
pod := framework.MakePod(namespaceName, podName, nil, annotations, "", nil, nil)
109105
pod = podClient.CreateSync(pod)
110106

111107
ginkgo.By("Validating pod annotations")
@@ -126,17 +122,13 @@ var _ = framework.Describe("[group:qos]", func() {
126122
}
127123
framework.ExpectHaveKeyWithValue(qos, "limit", strconv.Itoa(limit))
128124
framework.ExpectHaveKeyWithValue(qos, "loss", strconv.Itoa(loss))
129-
130-
ginkgo.By("Deleting pod " + name)
131-
podClient.DeleteSync(pod.Name)
132125
})
133126

134127
framework.ConformanceIt("should be able to update netem QoS", func() {
135128
f.SkipVersionPriorTo(1, 9, "Support for netem QoS was introduced in v1.9")
136129

137-
name := "pod-" + framework.RandomSuffix()
138-
ginkgo.By("Creating pod " + name + " without QoS")
139-
pod := framework.MakePod(namespaceName, name, nil, nil, "", nil, nil)
130+
ginkgo.By("Creating pod " + podName + " without QoS")
131+
pod := framework.MakePod(namespaceName, podName, nil, nil, "", nil, nil)
140132
pod = podClient.CreateSync(pod)
141133

142134
ginkgo.By("Validating pod annotations")
@@ -176,21 +168,17 @@ var _ = framework.Describe("[group:qos]", func() {
176168
}
177169
framework.ExpectHaveKeyWithValue(qos, "limit", strconv.Itoa(limit))
178170
framework.ExpectHaveKeyWithValue(qos, "loss", strconv.Itoa(loss))
179-
180-
ginkgo.By("Deleting pod " + name)
181-
podClient.DeleteSync(pod.Name)
182171
})
183172

184173
framework.ConformanceIt("should support htb QoS", func() {
185174
f.SkipVersionPriorTo(1, 9, "Support for htb QoS with priority was introduced in v1.9")
186175

187-
name := "pod-" + framework.RandomSuffix()
188-
ginkgo.By("Creating pod " + name)
176+
ginkgo.By("Creating pod " + podName)
189177
ingressRate := 300
190178
annotations := map[string]string{
191179
util.IngressRateAnnotation: strconv.Itoa(ingressRate),
192180
}
193-
pod := framework.MakePod(namespaceName, name, nil, annotations, "", nil, nil)
181+
pod := framework.MakePod(namespaceName, podName, nil, annotations, "", nil, nil)
194182
pod = podClient.CreateSync(pod)
195183

196184
ginkgo.By("Validating pod annotations")
@@ -201,8 +189,5 @@ var _ = framework.Describe("[group:qos]", func() {
201189
ginkgo.By("Validating OVS Queue")
202190
queue := getOvsQosForPod(f, "queue", pod)
203191
framework.ExpectHaveKeyWithValue(queue, "max-rate", strconv.Itoa(ingressRate*1000*1000))
204-
205-
ginkgo.By("Deleting pod " + name)
206-
podClient.DeleteSync(pod.Name)
207192
})
208193
})

0 commit comments

Comments
 (0)