Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 13cfeec

Browse files
committed
fix portmapping failure introduced by hyperhq/runv#592
the format of ip field was changed to cidr format. and added a test for portmapping Signed-off-by: Wang Xu <gnawux@gmail.com>
1 parent 7e7b124 commit 13cfeec

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616

1717
before_install:
1818
- sudo apt-get update -qq
19-
- sudo apt-get install -y -qq autoconf automake pkg-config libdevmapper-dev libsqlite3-dev libvirt-dev libvirt-bin aufs-tools wget libaio1 libpixman-1-0
19+
- sudo apt-get install -y -qq autoconf automake pkg-config libdevmapper-dev libsqlite3-dev libvirt-dev libvirt-bin aufs-tools wget libaio1 libpixman-1-0 netcat
2020
- wget https://s3-us-west-1.amazonaws.com/hypercontainer-download/qemu-hyper/qemu-hyper_2.4.1-1_amd64.deb && sudo dpkg -i --force-all qemu-hyper_2.4.1-1_amd64.deb
2121
- cd `mktemp -d`
2222
- mkdir -p ${GOPATH}/src/github.com/hyperhq

daemon/pod/provision.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package pod
33
import (
44
"fmt"
55
"path/filepath"
6+
"strings"
67
"sync"
78
"time"
89

@@ -419,7 +420,8 @@ func (p *XPod) prepareResources() error {
419420
return err
420421
}
421422
if p.containerIP == "" {
422-
p.containerIP = inf.descript.Ip
423+
fields := strings.SplitN(inf.descript.Ip, "/", 2)
424+
p.containerIP = fields[0]
423425
}
424426
}
425427

hack/lib/test.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,25 @@ hyper::test::container_readonly_rootfs_and_volume() {
242242
sudo hyperctl rm $id
243243
test $res1 -eq 0 -a $res2 -eq 0
244244
}
245+
246+
hyper::test::portmapping() {
247+
echo "Container portmapping test"
248+
ipaddr=$(ip addr show hyper0 |sed -ne 's/.*inet \([.0-9]\{7,15\}\)\/[0-9]\{1,2\} .*/\1/p')
249+
echo "hyper0 address is $ipaddr"
250+
started=
251+
while read output; do
252+
response=$(echo "$output" |tr -d "[:space:]")
253+
echo "got $response"
254+
if [ "x$started" == "x" ]; then
255+
started=$response
256+
sleep 3
257+
nc $ipaddr 3000 <<END
258+
ok
259+
END
260+
elif [ "x$response" = "xok" ]; then
261+
return 0
262+
else
263+
return 1
264+
fi
265+
done < <(sudo hyperctl run -t --rm --publish 3000:1300 busybox:latest sh -c 'echo "start" ; nc -l -p 1300')
266+
}

hack/test-cmd.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ __EOF__
199199
hyper::test::force_kill_container
200200
hyper::test::container_logs_no_newline
201201
hyper::test::container_readonly_rootfs_and_volume
202+
hyper::test::portmapping
202203

203204
stop_hyperd
204205
}

0 commit comments

Comments
 (0)