From 47a1536a47094e269eb81c058d9c7480bfbac8bf Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Wed, 31 Oct 2012 09:42:37 +0100 Subject: [PATCH] * usr/bin/byobu-janitor, usr/lib/byobu/include/shutil: LP: #1071287 - ensure that we re-check metadata service availability each time byobu-janitor runs - move metadata_available flag to more ephemeral run dir - drop timeout on metadata check to 5 seconds --- debian/changelog | 5 +++++ usr/bin/byobu-janitor | 3 +++ usr/lib/byobu/include/shutil | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 22d781e9..d9595e3b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,11 @@ byobu (5.22) unreleased; urgency=low - use a better variable name for memory usage * usr/lib/byobu/custom, usr/share/man/man1/byobu.1: - fix color for custom scripts; default to no color changes + * usr/bin/byobu-janitor, usr/lib/byobu/include/shutil: LP: #1071287 + - ensure that we re-check metadata service availability each time + byobu-janitor runs + - move metadata_available flag to more ephemeral run dir + - drop timeout on metadata check to 5 seconds [ Jake Biesinger and Dustin Kirkland ] * usr/share/byobu/keybindings/common, usr/share/byobu/keybindings/f- diff --git a/usr/bin/byobu-janitor b/usr/bin/byobu-janitor index e3bced1e..a32faaad 100755 --- a/usr/bin/byobu-janitor +++ b/usr/bin/byobu-janitor @@ -27,6 +27,9 @@ PKG="byobu" # Ensure that all updates get run immediately rm -rf "$BYOBU_RUN_DIR/.last.$BYOBU_BACKEND" +# Ensure that we re-check metadata service +rm -f "$BYOBU_CONFIG_DIR/.metadata_available" "$BYOBU_RUN_DIR/.metadata_available" + # Exit immediately, if we're not forced, and there is no reload flag FLAG="$BYOBU_RUN_DIR/reload-required" if [ "$1" != "--force" ] && [ ! -e "$FLAG" ]; then diff --git a/usr/lib/byobu/include/shutil b/usr/lib/byobu/include/shutil index b82cf860..5b356269 100755 --- a/usr/lib/byobu/include/shutil +++ b/usr/lib/byobu/include/shutil @@ -209,7 +209,7 @@ metadata_available() { # This is really ugly. We need a reliable, fast way of determining # if a metadata service is available, that does NOT slow down non-ec2 # machines. - local x=0 cache="$BYOBU_CONFIG_DIR/.metadata_available" + local x=0 cache="$BYOBU_RUN_DIR/.metadata_available" # First, check the cache if [ -s "$cache" ]; then # Metadata is non-empty, so we have metadata available @@ -218,7 +218,7 @@ metadata_available() { # Must seed the cache if [ -e /etc/ec2_version ] || [ -e /usr/sbin/update-grub-legacy-ec2 ]; then # This *looks* like a machine with metadata, so background a potentially slow check - wget -q -O "$cache" --timeout=10 --tries=1 http://169.254.169.254 2>/dev/null & + wget -q -O "$cache" --timeout=5 --tries=1 http://169.254.169.254 2>/dev/null & sleep 0.02 [ -s "$cache" ] && x=1 fi