[patch iwhd] Raise the RHEV-M import timeout

Jim Meyering jim at meyering.net
Mon Aug 22 09:37:50 UTC 2011


Pete Zaitcev wrote:
> Early field experiments showed that I was too optimistic about the time
> it takes to copy a typical image: 1 minute is definitely too short.
>
> With this change in place both James Labocki and Richard Su report success.
>
> ---
>  dc-rhev-image.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/dc-rhev-image.c b/dc-rhev-image.c
> index 00ee16c..b332b8a 100644
> --- a/dc-rhev-image.c
> +++ b/dc-rhev-image.c
> @@ -2238,7 +2249,8 @@ static void import_tpl(struct config *cfg, struct api_conn *connection,
>  		}
>  		if (c_strcasecmp(status, "PENDING") == 0 ||
>  		    c_strcasecmp(status, "IN_PROGRESS") == 0) {
> -			if (++i >= 20) {
> +			/* Yes, 10 minutes may be needed, 1 is way too small. */
> +			if (++i >= 200) {
>  				fprintf(stderr,
>  				    "ERROR import times out, status `%s'\n",
>  				    status);

Thanks, Pete.
I've pushed your patch, along with the following touch-up.

Minor nit: I've changed the pre-increment "++i" to be "i++".
Otherwise, while documenting the new constants, I realized the
timeout would expire IMPORT_SLEEP_SECONDS earlier than expected.


>From d1c95d665c76f4d83f51929a1181fd4b71a78e2c Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Mon, 22 Aug 2011 11:06:39 +0200
Subject: [PATCH] maint: give names to import-related sleep/timeout constants

* dc-rhev-image.c (IMPORT_SLEEP_SECONDS): Define.
(IMPORT_SLEEP_SECONDS): Define.
(import_tpl): Use those rather than hard-coded constants.
* NEWS (Bug fixes): Mention it.
---
 NEWS            |    3 +++
 dc-rhev-image.c |   15 ++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index e122bcf..b859a8b 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ iwhd NEWS                                                   -*- outline -*-

 ** Bug fixes

+  dc-rhev-image now allows a RHEV-M import to take 10 minutes.
+  Before, it would timeout after just 1 minute, which was often inadequate.
+
   object deletion now succeeds for an object whose FS-backed file has been
   removed behind iwhd's back.

diff --git a/dc-rhev-image.c b/dc-rhev-image.c
index 20a1d13..6b74f35 100644
--- a/dc-rhev-image.c
+++ b/dc-rhev-image.c
@@ -63,6 +63,15 @@

 static const char NULID[] = "00000000-0000-0000-0000-000000000000";

+enum {
+  /* How long to sleep between import status queries.  */
+  IMPORT_SLEEP_SECONDS = 3,
+
+  /* An import times out after this many seconds.  60 is too small.
+     600 appears to be adequate in some real-life situations.  */
+  IMPORT_MAXIMUM_DURATION_SECONDS = 600
+};
+
 struct config {
 	char *image;
 	char *apiurl;
@@ -2238,8 +2247,8 @@ static void import_tpl(struct config *cfg, struct api_conn *connection,
 		}
 		if (c_strcasecmp(status, "PENDING") == 0 ||
 		    c_strcasecmp(status, "IN_PROGRESS") == 0) {
-			/* Yes, 10 minutes may be needed, 1 is way too small. */
-			if (++i >= 200) {
+			if (i++ * IMPORT_SLEEP_SECONDS
+			    >= IMPORT_MAXIMUM_DURATION_SECONDS) {
 				fprintf(stderr,
 				    "ERROR import times out, status `%s'\n",
 				    status);
@@ -2251,7 +2260,7 @@ static void import_tpl(struct config *cfg, struct api_conn *connection,
 			exit(EXIT_FAILURE);
 		}

-		tm.tv_sec = 3;
+		tm.tv_sec = IMPORT_SLEEP_SECONDS;
 		tm.tv_nsec = 0;
 		nanosleep(&tm, NULL);

--
1.7.6.677.gb5fca


More information about the iwhd-devel mailing list