Merge lp:~dpb/orange-box/use-nc-not-ping-1361714 into lp:orange-box

Proposed by David Britton
Status: Merged
Merged at revision: 472
Proposed branch: lp:~dpb/orange-box/use-nc-not-ping-1361714
Merge into: lp:orange-box
Diff against target: 76 lines (+51/-3)
2 files modified
debian/postinst (+2/-3)
usr/bin/orange-box-test-uplink (+49/-0)
To merge this branch: bzr merge lp:~dpb/orange-box/use-nc-not-ping-1361714
Reviewer Review Type Date Requested Status
Dustin Kirkland  Pending
Review via email: mp+232490@code.launchpad.net

Description of the change

Introduce new script ob-test-uplink and call this instead of using icmp ping.

Please let me know if you would like any more hosts added.

To post a comment you must log in.
Revision history for this message
Dustin Kirkland  (kirkland) wrote :
Download full text (4.3 KiB)

Review: Needs Fixing

On Wed, Aug 27, 2014 at 6:10 PM, David Britton
<email address hidden> wrote:
> David Britton has proposed merging lp:~davidpbritton/orange-box/use-nc-not-ping-1361714 into lp:orange-box.
>
> Requested reviews:
> Orange Box (orange-box)
> Related bugs:
> Bug #1361714 in Orange Box: "orange-box postinst uses ping to test connectivity to maas.ubuntu.com"
> https://bugs.launchpad.net/orange-box/+bug/1361714
>
> For more details, see:
> https://code.launchpad.net/~davidpbritton/orange-box/use-nc-not-ping-1361714/+merge/232490
>
> Introduce new script ob-test-uplink and call this instead of using icmp ping.
>
> Please let me know if you would like any more hosts added.
> --
> https://code.launchpad.net/~davidpbritton/orange-box/use-nc-not-ping-1361714/+merge/232490
> You are subscribed to branch lp:orange-box.
>
> === modified file 'debian/postinst'
> --- debian/postinst 2014-08-25 16:40:02 +0000
> +++ debian/postinst 2014-08-27 23:09:22 +0000
> @@ -37,7 +37,8 @@
> fi
> # Setup nat
> # Ensure we have an external connection
> - run-one-until-success ping -c 3 maas.ubuntu.com
> + orange-box-test-uplink
> + run-one-until-success

This isn't quite right. You would need to put these both on the same
line, like this:

run-one-until-success orange-box-test-uplink

Also, check that you're using tabs here, and not 8 white spaces.

> orange-box-setup-nat
> # Redirect to MAAS web interface
> cat >/var/www/html/index.html <<EOF
> @@ -96,8 +97,7 @@
> # MAAS won't work very well until this is done, so we're going to block
> # until this completes
> # Network access may not be immediately available;
> - # wait until we can talk to maas
> - run-one-until-success ping -c 3 maas.ubuntu.com
> + orange-box-test-uplink

Use a tab. And wrap with run-one-until-success.

> # Support MAAS 1.5, and 1.6
> maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
> if dpkg --compare-versions $maas_ver lt 1.6; then
>
> === added file 'usr/bin/orange-box-test-uplink'
> --- usr/bin/orange-box-test-uplink 1970-01-01 00:00:00 +0000
> +++ usr/bin/orange-box-test-uplink 2014-08-27 23:09:22 +0000
> @@ -0,0 +1,46 @@
> +#!/bin/sh
> +#
> +# orange-box-amt-recover - recover a dead AMT by dropping all connections

Thanks for copying the template. Make sure you update this line
appropriately ;-)

> +# Copyright (C) 2014 Canonical Ltd.
> +#
> +# Authors: David Britton <email address hidden>
> +#
> +# This program is free software: you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation, version 3 of the License.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www...

Read more...

462. By David Britton

kirkland[diff]: s/spaces/tabs/, update header, set -e, set -x

463. By David Britton

kirkland[diff]: s/spaces/tabs/

Revision history for this message
David Britton (dpb) wrote :

Thanks Dustin --

I believe I've addressed all the feedback except one thing,

orange-box-test-uplink already does a timeout and run-one-until-success, you would like another wrapper around that? You think there should be a timeout associated too? One issue I noticed is that it was waiting forever which seemed odd for a postinst.

Thoughts?

And ya, timeout is pretty rad. got rid of so many boilerplate loops in my shell scripts. :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/postinst'
2--- debian/postinst 2014-08-25 16:40:02 +0000
3+++ debian/postinst 2014-08-28 00:48:51 +0000
4@@ -37,7 +37,7 @@
5 fi
6 # Setup nat
7 # Ensure we have an external connection
8- run-one-until-success ping -c 3 maas.ubuntu.com
9+ orange-box-test-uplink
10 orange-box-setup-nat
11 # Redirect to MAAS web interface
12 cat >/var/www/html/index.html <<EOF
13@@ -96,8 +96,7 @@
14 # MAAS won't work very well until this is done, so we're going to block
15 # until this completes
16 # Network access may not be immediately available;
17- # wait until we can talk to maas
18- run-one-until-success ping -c 3 maas.ubuntu.com
19+ orange-box-test-uplink
20 # Support MAAS 1.5, and 1.6
21 maas_ver=$(dpkg -l maas | tail -n1 | awk '{print $3}')
22 if dpkg --compare-versions $maas_ver lt 1.6; then
23
24=== added file 'usr/bin/orange-box-test-uplink'
25--- usr/bin/orange-box-test-uplink 1970-01-01 00:00:00 +0000
26+++ usr/bin/orange-box-test-uplink 2014-08-28 00:48:51 +0000
27@@ -0,0 +1,49 @@
28+#!/bin/sh
29+
30+set -e
31+set -x
32+
33+#
34+# orange-box-test-uplink - ensure network resources are reachable
35+# Copyright (C) 2014 Canonical Ltd.
36+#
37+# Authors: David Britton <dpb@canonical.com>
38+#
39+# This program is free software: you can redistribute it and/or modify
40+# it under the terms of the GNU General Public License as published by
41+# the Free Software Foundation, version 3 of the License.
42+#
43+# This program is distributed in the hope that it will be useful,
44+# but WITHOUT ANY WARRANTY; without even the implied warranty of
45+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46+# GNU General Public License for more details.
47+#
48+# You should have received a copy of the GNU General Public License
49+# along with this program. If not, see <http://www.gnu.org/licenses/>.
50+
51+# Wait until tcp connection established to specified host:port
52+# Expects: (host, port)
53+wait_tcp_connect() {
54+ timeout 2m run-one-until-success nc -w 10 -zvv $@
55+}
56+
57+wait_udp_connect() {
58+ # Best effort on UDP, it's connectionless. Short
59+ # of starting up a real client, it's prone to false positives
60+ timeout 2m run-one-until-success nc -w 5 -uzvv $@
61+}
62+
63+tcp_servers="maas.ubuntu.com:80 archive.ubuntu.com:80"
64+udp_servers="ntp.ubuntu.com:123"
65+
66+for entry in $tcp_servers; do
67+ server=$(echo $entry | awk -F : '{ print $1 }')
68+ port=$(echo $entry | awk -F : '{ print $2 }')
69+ wait_tcp_connect $server $port
70+done
71+
72+for entry in $udp_servers; do
73+ server=$(echo $entry | awk -F : '{ print $1 }')
74+ port=$(echo $entry | awk -F : '{ print $2 }')
75+ wait_udp_connect $server $port
76+done

Subscribers

People subscribed via source and target branches