Merge ~mwhudson/curtin:bye-route-hello-ip into curtin:master

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: fc81793acf628792d11b2f31dac4a571af68d4a8
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~mwhudson/curtin:bye-route-hello-ip
Merge into: curtin:master
Diff against target: 53 lines (+15/-9)
2 files modified
tests/vmtests/__init__.py (+5/-3)
tools/find-tgt (+10/-6)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Dan Bungert Approve
Olivier Gayot Approve
Review via email: mp+427468@code.launchpad.net

Commit message

tests: use 'ip route' and 'ss' instead of 'route' and 'netstat'

net-tools is (a) ancient (b) apparently not installed on some CI hosts

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
~mwhudson/curtin:bye-route-hello-ip updated
2662577... by Michael Hudson-Doyle

s/netstat/ss/ too

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
~mwhudson/curtin:bye-route-hello-ip updated
891fa4c... by Michael Hudson-Doyle

use ip route in vmtests

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Olivier Gayot (ogayot) wrote (last edit ):

yay, bye net-tools \o/

one comment inline.

Revision history for this message
Olivier Gayot (ogayot) :
review: Approve
Revision history for this message
Dan Bungert (dbungert) :
review: Approve
~mwhudson/curtin:bye-route-hello-ip updated
2c8a455... by Michael Hudson-Doyle

use ss filter

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
~mwhudson/curtin:bye-route-hello-ip updated
fc81793... by Michael Hudson-Doyle

bah

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/vmtests/__init__.py b/tests/vmtests/__init__.py
2index c52c442..467c8a2 100644
3--- a/tests/vmtests/__init__.py
4+++ b/tests/vmtests/__init__.py
5@@ -2412,9 +2412,11 @@ def boot_log_wrap(name, func, cmd, console_log, timeout, purpose):
6 def get_lan_ip():
7 (out, _) = util.subp(['ip', 'a'], capture=True)
8 info = ip_a_to_dict(out)
9- (routes, _) = util.subp(['route', '-n'], capture=True)
10- gwdevs = [route.split()[-1] for route in routes.splitlines()
11- if route.startswith('0.0.0.0') and 'UG' in route]
12+ (routes, _) = util.subp(['ip', '-json', 'route', 'show'], capture=True)
13+ gwdevs = []
14+ for route in json.loads(routes):
15+ if route['dst'] == 'default':
16+ gwdevs.append(route['dev'])
17 if len(gwdevs) > 0:
18 dev = gwdevs.pop()
19 addr = info[dev].get('inet4')[0].get('address')
20diff --git a/tools/find-tgt b/tools/find-tgt
21index 435dde2..e269beb 100755
22--- a/tools/find-tgt
23+++ b/tools/find-tgt
24@@ -29,7 +29,12 @@ EOF
25 find_ipv4addr() {
26 # tgtd/tgtadmin end up using a suffix from here of the control port
27 local dev="" addr=""
28- dev=$(route -n | awk '$1 == "0.0.0.0" { print $8 }')
29+ dev=$(ip -json route show | python3 -c 'import json, sys
30+for r in json.load(sys.stdin):
31+ if r["dst"] == "default":
32+ print(r["dev"])
33+ break
34+')
35 [ -n "$dev" ] || { error "failed to find ipv4 device"; return 1; }
36 addr=$(ip addr show dev "$dev" |
37 awk '$1 == "inet" {gsub(/\/.*/,"", $2); print $2; exit}')
38@@ -47,11 +52,10 @@ wait_for_tgtd() {
39 local out="" pidstgt="" name="tgtd"
40 while :; do
41 # did we succesfully attach to the correct port?
42- out=$(netstat --program --all --numeric 2>/dev/null) ||
43- fail "failed to netstat --program --all --numeric"
44- pidstgt=$(echo "$out" |
45- awk '$4 == portal { print $7; exit(0); }' "portal=$portal")
46- if [ "$pidstgt" = "$pid/$name" ]; then
47+ out=$(ss --no-header --processes --listening --numeric "src = inet:$portal" 2>/dev/null) ||
48+ fail "failed to ss --no-header --processes --listening --numeric src = inet:$portal"
49+ pidstgt=$(echo "$out" | awk '{ print $7; exit(0); }')
50+ if echo $pidstgt | grep --quiet "pid=$pid,"; then
51 error "expected pid $pid is listening on $portal on try $try."
52 return 0
53 elif [ -n "$pidstgt" ]; then

Subscribers

People subscribed via source and target branches