Darryl L. Pierce
2009-Jan-19 22:32 UTC
[Ovirt-devel] [PATCH node] Fixed check for whether the network restarted.
The last network interface touched by the script is checked to see if it has active ARP entries. If not then the restart is considered a failure even through the service itself restarted. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-networking | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index 5727c47..646b36d 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -17,6 +17,7 @@ trap '__st=$?; rm -rf "$WORKDIR"; stop_log; exit $__st' 0 trap 'exit $?' 1 2 13 15 CONFIG_FILE_ROOT="/files/etc/sysconfig/network-scripts/ifcfg" +CONFIGURED_IFACE="" function configure_interface { @@ -34,6 +35,8 @@ function configure_interface local IF_FILENAME="$WORKDIR/augtool-$NIC" local BR_FILENAME="$WORKDIR/augtool-$BRIDGE" + CONFIGURED_IFACE=$BRIDGE + printf "\nConfigure $BRIDGE for use by $NIC..\n\n" local IF_ROOT="$CONFIG_FILE_ROOT-$NIC" @@ -239,10 +242,12 @@ if ls "$WORKDIR"/augtool-* > /dev/null 2>&1 ; then cat "$WORKDIR"/augtool-* > $config \ && augtool $config \ && service network restart - if [ $? = 0 ]; then - log "Network configured successfully" - else + # check of rthe bridge's existence + net_check=$(arp -i $CONFIGURED_IFACE) + if [[ $net_check =~ "no match found" ]]; then log "Error configuring network, see $OVIRT_LOGFILE" + else + log "Network configured successfully" fi fi ovirt_store_config /etc/sysconfig/network-scripts/ifcfg* -- 1.6.0.6
Alan Pevec
2009-Jan-20 12:42 UTC
[Ovirt-devel] [PATCH node] Fixed check for whether the network restarted.
On Mon, Jan 19, 2009 at 11:32 PM, Darryl L. Pierce <dpierce at redhat.com>wrote:> The last network interface touched by the script is checked to see if it > has active ARP entries. If not then the restart is considered a failure > even through the service itself restarted. >Background of this patch is that /etc/init.d/network script returns 0 even after printing FAILED for some interfaces. Unfortunately checking for ARP cache entries is fragile: works after successful DHCP session, but fails if we configured static IP + if [[ $net_check =~ "no match found" ]]; then> log "Error configuring network, see $OVIRT_LOGFILE" >should also return non-0 error code otherwise confusing success message is printed right after error: http://apevec.fedorapeople.org/o-c-netcfg-fail-no-dhcp.png -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20090120/8353e909/attachment.htm>
Darryl L. Pierce
2009-Jan-20 19:20 UTC
[Ovirt-devel] [PATCH node] Fixed check for whether the network restarted.
The last network interface touched by the script is checked to see if it has active ARP entries. If not then the restart is considered a failure even through the service itself restarted. It then returns a result code of 1. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-networking | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index 5727c47..cad47e1 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -17,6 +17,7 @@ trap '__st=$?; rm -rf "$WORKDIR"; stop_log; exit $__st' 0 trap 'exit $?' 1 2 13 15 CONFIG_FILE_ROOT="/files/etc/sysconfig/network-scripts/ifcfg" +CONFIGURED_IFACE="" function configure_interface { @@ -34,6 +35,8 @@ function configure_interface local IF_FILENAME="$WORKDIR/augtool-$NIC" local BR_FILENAME="$WORKDIR/augtool-$BRIDGE" + CONFIGURED_IFACE=$BRIDGE + printf "\nConfigure $BRIDGE for use by $NIC..\n\n" local IF_ROOT="$CONFIG_FILE_ROOT-$NIC" @@ -239,10 +242,13 @@ if ls "$WORKDIR"/augtool-* > /dev/null 2>&1 ; then cat "$WORKDIR"/augtool-* > $config \ && augtool $config \ && service network restart - if [ $? = 0 ]; then - log "Network configured successfully" - else + # check of rthe bridge's existence + net_check=$(arp -i $CONFIGURED_IFACE) + if [[ $net_check =~ "no match found" ]]; then log "Error configuring network, see $OVIRT_LOGFILE" + exit 1 + else + log "Network configured successfully" fi fi ovirt_store_config /etc/sysconfig/network-scripts/ifcfg* -- 1.6.0.6