[iwhd: 1/2] Make the intent of the "path" clearer.
by Pete Zaitcev
commit 79e9516bf0dcea07bbdcf105082ecda389526d78
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Fri Jul 15 16:51:13 2011 -0600
Make the intent of the "path" clearer.
Use a more realistic example value. The "_fs" had negative value
for readers, as it turned out.
doc/registrations.md | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/doc/registrations.md b/doc/registrations.md
index 1fc09c5..13c77a4 100644
--- a/doc/registrations.md
+++ b/doc/registrations.md
@@ -41,7 +41,7 @@ There is no pre-set except configuring iwhd/conf.js like so:
{
"name": "main",
"type": "fs",
- "path": "_fs",
+ "path": "/home/iwhd/main"
}
]
@@ -105,7 +105,7 @@ The provider in iwhd/conf.js uses "fs-rhev-m" type:
{
"name": "main",
"type": "fs-rhev-m",
- "path": "_fs",
+ "path": "/home/iwhd/main"
}
]
@@ -153,7 +153,7 @@ The area S must be mounted at H, of course.
{
"name": "condor",
"type": "fs-condor",
- "path": "/home/iwhd/_fs",
+ "path": "/home/iwhd/condor"
}
]
@@ -178,7 +178,7 @@ to the specific host.
{
"name": "main",
"type": "fs-vmw",
- "path": "_fs",
+ "path": "/home/iwhd/main"
}
]
12 years, 9 months
[iwhd] Created tag v0.97
by Jim Meyering
The signed tag 'v0.97' was created.
Tagger: Jim Meyering <meyering(a)redhat.com>
Date: Tue Jul 12 19:59:25 2011 +0200
iwhd 0.97
Changes since the last tag 'v0.96':
Jim Meyering (4):
post-release administrivia
build: work around jansson-2.1's API change
build: disable -Wsign-compare, for now
version 0.97
Pete Zaitcev (4):
mark conf.js as a config file to avoid accidental overwrite
doc: update comments
do not leak "pending"
use POST body for ID and messages
12 years, 9 months
[iwhd] post-release administrivia
by Jim Meyering
commit 3b56450f6292ef9a06ff193358943676ab8f5505
Author: Jim Meyering <meyering(a)redhat.com>
Date: Tue Jul 12 20:02:36 2011 +0200
post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
.prev-version | 2 +-
NEWS | 3 +++
cfg.mk | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/.prev-version b/.prev-version
index 10b1865..ea6844b 100644
--- a/.prev-version
+++ b/.prev-version
@@ -1 +1 @@
-0.96
+0.97
diff --git a/NEWS b/NEWS
index c03fec6..45d65c4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
iwhd NEWS -*- outline -*-
+* Noteworthy changes in release ?.? (????-??-??) [?]
+
+
* Noteworthy changes in release 0.97 (2011-07-12) [stable]
** New features
diff --git a/cfg.mk b/cfg.mk
index cfc2cba..a88295e 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -38,7 +38,7 @@ bootstrap-tools = autoconf,automake,gnulib
# Now that we have better tests, make this the default.
export VERBOSE = yes
-old_NEWS_hash = 207c7ece9d99fa0538b14e13f73c5ee7
+old_NEWS_hash = 2f77846f433127ee87d65f2fa88c623a
sc_prohibit_echo_minus_en:
@prohibit='\<echo -[en]' \
12 years, 9 months
[iwhd] version 0.97
by Jim Meyering
commit 2f60c145c3e86edd40c850304d6fe26c6dd06e9e
Author: Jim Meyering <meyering(a)redhat.com>
Date: Tue Jul 12 19:59:25 2011 +0200
version 0.97
* NEWS: Record release date.
NEWS | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index d3da617..c03fec6 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,6 @@
iwhd NEWS -*- outline -*-
-* Noteworthy changes in release ?.? (????-??-??) [?]
+* Noteworthy changes in release 0.97 (2011-07-12) [stable]
** New features
12 years, 9 months
[iwhd] build: disable -Wsign-compare, for now
by Jim Meyering
commit 155334263a41d61312cf74340062337340ecb1d0
Author: Jim Meyering <meyering(a)redhat.com>
Date: Tue Jul 12 19:44:41 2011 +0200
build: disable -Wsign-compare, for now
There are two warnings in bison-generated qparser.c.
* configure.ac (WERROR_CFLAGS): Add -Wno-sign-compare.
configure.ac | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 61199c2..e23d1fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -153,6 +153,7 @@ if test "$gl_gcc_warnings" = yes; then
done
gl_WARN_ADD([-Wno-unused-function])
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
+ gl_WARN_ADD([-Wno-sign-compare]) # warnings in bison-generated qparser.c
# In spite of excluding -Wlogical-op above, it is enabled, as of
# gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
12 years, 9 months
[iwhd] use POST body for ID and messages
by Pete Zaitcev
commit 082b76a78c099283ef9f29255cb9b9679f8e14d3
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Mon Jul 11 16:31:06 2011 -0600
use POST body for ID and messages
This patch addresses two issues. First, RHEV-M sometimes throws some
diagnostics at us, which are far too long to stuff into a 64-byte
attribute, but which are desirable to see. Second, we now allow
multiple registrations for clouds that allow that. Requested by
Ian McLeod.
So, this patch adds a body to POST reply. Its first line is ID,
in same format as ami-id was, only longer, and the rest is the
diagnostic messages.
https://www.aeolusproject.org/redmine/issues/1253
https://www.aeolusproject.org/redmine/issues/1886
NEWS | 8 +++++
backend.c | 48 ++++++++++++++++++++++++++++++
dc-rhev-image.c | 78 ++++++++++++++++++++++++++++++++++---------------
doc/registrations.md | 16 ++++++++--
state_defs.h | 2 +-
5 files changed, 124 insertions(+), 28 deletions(-)
---
diff --git a/NEWS b/NEWS
index 63bbec9..d3da617 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,14 @@ iwhd NEWS -*- outline -*-
* Noteworthy changes in release ?.? (????-??-??) [?]
+** New features
+
+ A registration to RHEV-M now returns the ID and diagnostic messages
+ in the body of reply to POST request. This permits to register the
+ same image several times, and helps triaging any problems. The old
+ "ami-id" attribute is retained and remains the same across registration
+ back-end types.
+
** Bug fixes
On Fedora systems, /etc/iwhd/conf.js is not overwritten anymore when
diff --git a/backend.c b/backend.c
index 4102a00..62cb42b 100644
--- a/backend.c
+++ b/backend.c
@@ -62,6 +62,7 @@ static struct hstor_client *hstor;
#define ADDR_SIZE 256
#define LINE_SIZE 500
#define HEADER_SIZE 64
+#define ERR_SIZE 2000
#define S3_IMAGE_PATTERN "^IMAGE[[:blank:]]+([^[:space:]]+)"
#define S3_ERROR_PATTERN "^ERROR[[:blank:]]+([^[:space:]]+)"
@@ -1450,6 +1451,12 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
char ami_id_buf[64];
regmatch_t match[2];
+ struct MHD_Response *resp;
+ char res_buf[LINE_SIZE];
+ char msg_buf[ERR_SIZE+1];
+ char *msg_ptr;
+ int rc;
+
strcpy(ami_id_buf, "none");
if (!regex_ok) {
@@ -1583,14 +1590,27 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
strcpy(ami_id_buf,"failed (fdopen)");
goto cleanup;
}
+ res_buf[0] = 0;
+ msg_ptr = msg_buf;
while (fgets(buf,sizeof(buf)-1,fp)) {
if ((s = strchr(buf, '\n')) != NULL)
*s = '\0';
+
+ if (msg_ptr < &msg_buf[ERR_SIZE]) {
+ rc = snprintf(msg_ptr,&msg_buf[ERR_SIZE]-msg_ptr,
+ "%s\r\n",buf);
+ if (msg_ptr + rc >= &msg_buf[ERR_SIZE])
+ msg_ptr = &msg_buf[ERR_SIZE];
+ else
+ msg_ptr += rc;
+ }
+
if (regexec(&s3_success_pat,buf,2,match,0) == 0) {
buf[match[1].rm_eo] = '\0';
s = buf+match[1].rm_so;
DPRINTF("found image UUID: %s\n",s);
snprintf(ami_id_buf,sizeof(ami_id_buf),"OK %s",s);
+ snprintf(res_buf,LINE_SIZE,"OK %s\r\n",s);
ret = MHD_HTTP_OK;
}
else if (strncmp(buf,"ERROR",sizeof("ERROR")-1) == 0) {
@@ -1599,11 +1619,13 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
s++;
DPRINTF("found err marker: %s\n",s);
snprintf(ami_id_buf,sizeof(ami_id_buf),"failed %s",s);
+ snprintf(res_buf,LINE_SIZE,"failed\r\n");
}
else {
DPRINTF("<%s>\n",buf);
}
}
+ *msg_ptr = 0;
fclose(fp);
DPRINTF("waiting for child...\n");
@@ -1623,6 +1645,32 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
DPRINTF("...child exited\n");
}
+ /*
+ * TBD: Ian requested JSON output, so we should invoke
+ * MHD_lookup_connection_value(,,"Accept") here and negotiate
+ * JSON or plain text (or maybe XML). However, JSON requires
+ * escaping, which is kinda bothersome, so do it later.
+ */
+ rc = asprintf(&msg_ptr, "%s%s", res_buf, msg_buf);
+ if (rc < 0) {
+ ret = MHD_HTTP_INTERNAL_SERVER_ERROR;
+ strcpy(ami_id_buf,"failed (no core)");
+ goto cleanup;
+ }
+
+ resp = MHD_create_response_from_data(strlen(msg_ptr),msg_ptr,
+ MHD_YES,MHD_NO);
+ if (!resp) {
+ fprintf(stderr,"MHD_crfd failed\n");
+ ret = MHD_HTTP_INTERNAL_SERVER_ERROR;
+ strcpy(ami_id_buf,"failed (MHD_cfgd)");
+ goto cleanup;
+ }
+ MHD_queue_response(ms->conn,ret,resp);
+ MHD_destroy_response(resp);
+
+ ret = MHD_HTTP_PROCESSING;
+
if (strncmp(ami_id_buf,"pending",sizeof("pending")-1)==0) {
/*
* Unfortunately "pending" may get stuck if dc-rhev-image
diff --git a/dc-rhev-image.c b/dc-rhev-image.c
index c768445..00ee16c 100644
--- a/dc-rhev-image.c
+++ b/dc-rhev-image.c
@@ -1912,16 +1912,13 @@ static void copyimage(const struct config *cfg, const struct id_pack *idp,
static char *import_get_status(xmlNode *etparent)
{
- char *status;
+ char *status, *p;
+ const char *error;
xmlNode *et;
xmlNode *ettext;
+ int rc;
- for (et = etparent->children; et; et = et->next) {
- if (et->type != XML_ELEMENT_NODE)
- continue;
- if (strcmp((const char *)et->name, "status") == 0)
- break;
- }
+ et = xmlGetChild(etparent, "status");
if (!et) {
fprintf(stderr, "ERROR No import status\n");
exit(EXIT_FAILURE);
@@ -1933,10 +1930,56 @@ static char *import_get_status(xmlNode *etparent)
exit(EXIT_FAILURE);
}
- status = strdup((char *)ettext->content);
- if (!status)
+ status = (char *)ettext->content;
+ if (c_strcasecmp(status, "COMPLETE") == 0 ||
+ c_strcasecmp(status, "IN_PROGRESS") == 0 ||
+ c_strcasecmp(status, "PENDING") == 0)
+ {
+ status = strdup(status);
+ if (!status)
+ goto err_alloc;
+ return status;
+ }
+
+ /*
+ * The status is most likely "FAILED". Try to find out the reason.
+ * Actually, <reason> is usually inane, so just go for <detail>.
+ *
+ * <action>
+ * <storage_domain id="af096e18-4b05-4a04-bc60-5a4148d73b9c"/>
+ * <cluster id="2ffa21f2-0d68-4c6b-98e3-0ef6ec5003e7"/>
+ * <status>FAILED</status>
+ * <fault>
+ * <reason>RHEVM operation failed</reason>
+ * <detail>[vm cannot import template name exists, var action import, var type vm template]</detail>
+ * </fault>
+ * </action>
+ */
+ error = "-";
+ et = xmlGetChild(etparent, "fault");
+ if (et) {
+ et = xmlGetChild(et, "detail");
+ if (et) {
+ ettext = et->children;
+ if (ettext &&
+ ettext->type == XML_TEXT_NODE &&
+ ettext->content)
+ {
+ error = (const char *)ettext->content;
+ }
+ }
+ }
+
+ rc = asprintf(&status, "%s %s", status, error);
+ if (rc < 0)
goto err_alloc;
+ /* This special-casing helps to unravel Java tracebacks. */
+ for (p = status; *p != 0; p++) {
+ if (*p == '\r')
+ *p = ' ';
+ }
+
return status;
err_alloc:
@@ -2078,20 +2121,7 @@ static xmlChar *import_start(struct config *cfg, struct api_conn *connection,
c_strcasecmp(status, "IN_PROGRESS") == 0) {
;
} else {
- fprintf(stderr, "ERROR Bad import status `%s'\n", status);
- /*
- * XXX process "FAILED" status, report meaningful error
- *
- * <action>
- * <storage_domain id="af096e18-4b05-4a04-bc60-5a4148d73b9c"/>
- * <cluster id="2ffa21f2-0d68-4c6b-98e3-0ef6ec5003e7"/>
- * <status>FAILED</status>
- * <fault>
- * <reason>RHEVM operation failed</reason>
- * <detail>[vm cannot import template name exists, var action import, var type vm template]</detail>
- * </fault>
- * </action>
- */
+ fprintf(stderr, "ERROR import `%s'\n", status);
exit(EXIT_FAILURE);
}
@@ -2215,7 +2245,7 @@ static void import_tpl(struct config *cfg, struct api_conn *connection,
exit(EXIT_FAILURE);
}
} else {
- fprintf(stderr, "ERROR Unknown import status `%s'\n",
+ fprintf(stderr, "ERROR import `%s'\n",
status);
exit(EXIT_FAILURE);
}
diff --git a/doc/registrations.md b/doc/registrations.md
index b063ba0..1fc09c5 100644
--- a/doc/registrations.md
+++ b/doc/registrations.md
@@ -11,13 +11,23 @@ server M, the registration involves:
- notifying M with an API call
The registration is triggered with "op=register" posted to iwhd image.
-Unfortunately, paramteres are cloud-specific (see examples).
+Unfortunately, parameters are cloud-specific (see examples).
-When registrarion completes with code 200, application is supposed to
-extract a cloud ID from the "ami-id" attribute, and verify that it starts
+When registration completes with code 200, legacy applications extract
+a cloud ID from the "ami-id" attribute, and verify that it starts
with "OK". For example:
curl http://iwhdhost.eng.example.com:9090/buk1/test_img/ami-id
+Newer applications receive the "OK" tag and the ID in the first line of
+the body of the POST reply. This permits several registrations for the
+same object (obviously only for clouds that support such a concept).
+The rest of the reply consists of diagnostic messages from the registration
+back-end, which help to diagnose issues.
+
+The iwhd 0.96 and prior return an empty reply body (version is available
+in the GET /). Later versions continue to set "ami-id" attribute for
+compatibility.
+
Another unfortunate implementation limitation is that registrations are
going to fail unless iwhd uses a filesystem-type back-end. A work is ongoing
to lift this restriction.
diff --git a/state_defs.h b/state_defs.h
index 6a3fd0b..30bebb9 100644
--- a/state_defs.h
+++ b/state_defs.h
@@ -56,7 +56,7 @@ typedef struct _my_state {
long rc;
/* for proxy puts */
size_t size;
- /* for proxy puts and queries */
+ /* for proxy puts, queries, and registrations */
struct MHD_Connection *conn;
/* for proxy queries */
struct MHD_PostProcessor *post;
12 years, 9 months
[iwhd] do not leak "pending"
by Pete Zaitcev
commit 101c79cde451ae333de5f477eaa5801bf9014504
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Mon Jul 11 16:26:29 2011 -0600
do not leak "pending"
Currently we set "pending" in case anything goes wrong, we crash or
whatnot, so that users can know that ami-id may be invalid. This is
fine, but if the context of POST is lost, it is not possible to
figure out what is going on: either the registration is still in
progress, or it is failed. Of course if we actually crash after
setting "pending", then it's bad. But we also leave "pending"
dangling for any error exit of dc-rhev-image, and that is wrong.
So, plug the return paths where "pending" may remain set after
everything is over. Not that this patch is not complete: the waitpid
is going to be fixed over with another patch.
http://www.aeolusproject.org/redmine/issues/1888
NEWS | 5 +++
backend.c | 104 ++++++++++++++++++++++++++++++++++++++++++-------------------
2 files changed, 77 insertions(+), 32 deletions(-)
---
diff --git a/NEWS b/NEWS
index 2476201..63bbec9 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,11 @@ iwhd NEWS -*- outline -*-
On Fedora systems, /etc/iwhd/conf.js is not overwritten anymore when
upgrading the package (added %config(noreplace)).
+ Do not leave a value of "pending xxxx" remain in "ami-id" attribute
+ in case of an error in registration process. When we did, no application
+ or human administrator could tell if there was an error or a hung
+ registration.
+
** Infrastructure
Adapt to jansson-1.2's new, incompatible changed API, so we can build
diff --git a/backend.c b/backend.c
index cd1a685..4102a00 100644
--- a/backend.c
+++ b/backend.c
@@ -508,6 +508,7 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
if (pipe(organ) < 0) {
error (0, errno, _("pipe creation failed"));
+ strcpy(ami_id_buf,"failed (pipe)");
goto cleanup;
}
@@ -516,6 +517,7 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
error (0, errno, _("fork failed"));
close(organ[0]);
close(organ[1]);
+ strcpy(ami_id_buf,"failed (fork)");
goto cleanup;
}
@@ -538,18 +540,20 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
*s = '\0';
if (regexec(&s3_success_pat,buf,2,match,0) == 0) {
buf[match[1].rm_eo] = '\0';
- DPRINTF("found AMI ID: %s\n",buf+match[1].rm_so);
- sprintf(ami_id_buf,"OK %.60s",buf+match[1].rm_so);
+ s = buf+match[1].rm_so;
+ DPRINTF("found AMI ID: %s\n",s);
+ snprintf(ami_id_buf,sizeof(ami_id_buf),"OK %s",s);
rc = MHD_HTTP_OK;
}
else if (regexec(&s3_failure_pat,buf,2,match,0) == 0) {
buf[match[1].rm_eo] = '\0';
- DPRINTF("found error marker: %s\n",buf+match[1].rm_so);
- sprintf(ami_id_buf,"failed %.56s",buf+match[1].rm_so);
+ s = buf+match[1].rm_so;
+ DPRINTF("found error marker: %s\n",s);
+ snprintf(ami_id_buf,sizeof(ami_id_buf),"failed %s",s);
rc = MHD_HTTP_INTERNAL_SERVER_ERROR;
}
else {
- DPRINTF("ignoring line: <%s>\n",buf);
+ DPRINTF("<%s>\n",buf);
}
}
fclose(fp);
@@ -557,18 +561,23 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
DPRINTF("waiting for child...\n");
if (waitpid(pid,&wstat,0) < 0) {
error (0, errno, _("waitpid failed"));
+ strcpy(ami_id_buf,"failed (waitpid)");
goto cleanup;
}
if (!WIFEXITED(wstat)) {
error (0, 0, _("%s is killed (status 0x%x)"), cmd, wstat);
- goto cleanup;
}
- if (WEXITSTATUS(wstat)) {
+ else if (WEXITSTATUS(wstat)) {
error (0, 0, _("%s exited with code %d"),
cmd, WEXITSTATUS(wstat));
- goto cleanup;
}
- DPRINTF("...child exited\n");
+ else {
+ DPRINTF("...child exited\n");
+ }
+
+ if (strncmp(ami_id_buf,"pending",sizeof("pending")-1)==0) {
+ strcpy(ami_id_buf,"failed (back-end)");
+ }
cleanup:
/*
@@ -1546,6 +1555,7 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
if (pipe(organ) < 0) {
error (0, errno, _("pipe creation failed"));
+ strcpy(ami_id_buf,"failed (pipe)");
goto cleanup;
}
@@ -1554,6 +1564,7 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
error (0, errno, _("fork failed"));
close(organ[0]);
close(organ[1]);
+ strcpy(ami_id_buf,"failed (fork)");
goto cleanup;
}
@@ -1569,6 +1580,7 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
if (!fp) {
error (0, 0, _("could not open parent pipe stream"));
close(organ[0]);
+ strcpy(ami_id_buf,"failed (fdopen)");
goto cleanup;
}
while (fgets(buf,sizeof(buf)-1,fp)) {
@@ -1576,16 +1588,20 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
*s = '\0';
if (regexec(&s3_success_pat,buf,2,match,0) == 0) {
buf[match[1].rm_eo] = '\0';
- DPRINTF("found image UUID: %s\n",buf+match[1].rm_so);
- sprintf(ami_id_buf,"OK %.60s",buf+match[1].rm_so);
+ s = buf+match[1].rm_so;
+ DPRINTF("found image UUID: %s\n",s);
+ snprintf(ami_id_buf,sizeof(ami_id_buf),"OK %s",s);
ret = MHD_HTTP_OK;
}
else if (strncmp(buf,"ERROR",sizeof("ERROR")-1) == 0) {
- DPRINTF("found err marker: %s\n",buf+sizeof("ERROR"));
- sprintf(ami_id_buf,"failed %.56s",buf+sizeof("ERROR"));
+ s = buf+sizeof("ERROR")-1;
+ if (*s == ' ')
+ s++;
+ DPRINTF("found err marker: %s\n",s);
+ snprintf(ami_id_buf,sizeof(ami_id_buf),"failed %s",s);
}
else {
- DPRINTF("ignoring line: <%s>\n",buf);
+ DPRINTF("<%s>\n",buf);
}
}
fclose(fp);
@@ -1593,18 +1609,27 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
DPRINTF("waiting for child...\n");
if (waitpid(pid,&wstat,0) < 0) {
error (0, errno, _("waitpid failed"));
+ strcpy(ami_id_buf,"failed (waitpid)");
goto cleanup;
}
if (!WIFEXITED(wstat)) {
error (0, 0, _("%s is killed (status 0x%x)"), cmd, wstat);
- goto cleanup;
}
- if (WEXITSTATUS(wstat)) {
+ else if (WEXITSTATUS(wstat)) {
error (0, 0, _("%s exited with code %d"),
cmd, WEXITSTATUS(wstat));
- goto cleanup;
}
- DPRINTF("...child exited\n");
+ else {
+ DPRINTF("...child exited\n");
+ }
+
+ if (strncmp(ami_id_buf,"pending",sizeof("pending")-1)==0) {
+ /*
+ * Unfortunately "pending" may get stuck if dc-rhev-image
+ * bums on us by crashing or otherwise fails to post result.
+ */
+ strcpy(ami_id_buf,"failed (back-end)");
+ }
cleanup:
/*
@@ -1697,6 +1722,7 @@ fs_condor_register (my_state *ms, const provider_t *prov, const char *next,
if (pipe(organ) < 0) {
error (0, errno, _("pipe creation failed"));
+ strcpy(ami_id_buf,"failed (pipe)");
goto cleanup;
}
@@ -1705,6 +1731,7 @@ fs_condor_register (my_state *ms, const provider_t *prov, const char *next,
error (0, errno, _("fork failed"));
close(organ[0]);
close(organ[1]);
+ strcpy(ami_id_buf,"failed (fork)");
goto cleanup;
}
@@ -1720,6 +1747,7 @@ fs_condor_register (my_state *ms, const provider_t *prov, const char *next,
if (!fp) {
error (0, 0, _("could not open parent pipe stream"));
close(organ[0]);
+ strcpy(ami_id_buf,"failed (fdopen)");
goto cleanup;
}
while (fgets(buf,sizeof(buf)-1,fp)) {
@@ -1727,12 +1755,13 @@ fs_condor_register (my_state *ms, const provider_t *prov, const char *next,
*s = '\0';
if (regexec(&s3_success_pat,buf,2,match,0) == 0) {
buf[match[1].rm_eo] = '\0';
- DPRINTF("found AMI ID: %s\n",buf+match[1].rm_so);
- sprintf(ami_id_buf,"OK %.60s",buf+match[1].rm_so);
+ s = buf+match[1].rm_so;
+ DPRINTF("found image UUID: %s\n",s);
+ snprintf(ami_id_buf,sizeof(ami_id_buf),"OK %s",s);
rc = MHD_HTTP_OK;
}
else {
- DPRINTF("ignoring line: <%s>\n",buf);
+ DPRINTF("<%s>\n",buf);
}
}
fclose(fp);
@@ -1740,18 +1769,23 @@ fs_condor_register (my_state *ms, const provider_t *prov, const char *next,
DPRINTF("waiting for child...\n");
if (waitpid(pid,&wstat,0) < 0) {
error (0, errno, _("waitpid failed"));
+ strcpy(ami_id_buf,"failed (waitpid)");
goto cleanup;
}
if (!WIFEXITED(wstat)) {
error (0, 0, _("%s is killed (status 0x%x)"), cmd, wstat);
- goto cleanup;
}
- if (WEXITSTATUS(wstat)) {
+ else if (WEXITSTATUS(wstat)) {
error (0, 0, _("%s exited with code %d"),
cmd, WEXITSTATUS(wstat));
- goto cleanup;
}
- DPRINTF("...child exited\n");
+ else {
+ DPRINTF("...child exited\n");
+ }
+
+ if (strncmp(ami_id_buf,"pending",sizeof("pending")-1)==0) {
+ strcpy(ami_id_buf,"failed (back-end)");
+ }
cleanup:
(void)meta_set_value(ms->bucket,ms->key,"ami-id",ami_id_buf);
@@ -1883,12 +1917,13 @@ fs_vmw_register (my_state *ms, const provider_t *prov, const char *next,
*s = '\0';
if (regexec(&s3_success_pat,buf,2,match,0) == 0) {
buf[match[1].rm_eo] = '\0';
- DPRINTF("found image tag: %s\n",buf+match[1].rm_so);
- sprintf(ami_id_buf,"OK %.60s",buf+match[1].rm_so);
+ s = buf+match[1].rm_so;
+ DPRINTF("found image tag: %s\n",s);
+ snprintf(ami_id_buf,sizeof(ami_id_buf),"OK %s",s);
ret = MHD_HTTP_OK;
}
else {
- DPRINTF("ignoring line: <%s>\n",buf);
+ DPRINTF("<%s>\n",buf);
}
}
fclose(fp);
@@ -1896,18 +1931,23 @@ fs_vmw_register (my_state *ms, const provider_t *prov, const char *next,
DPRINTF("waiting for child...\n");
if (waitpid(pid,&wstat,0) < 0) {
error (0, errno, _("waitpid failed"));
+ strcpy(ami_id_buf,"failed (waitpid)");
goto cleanup;
}
if (!WIFEXITED(wstat)) {
error (0, 0, _("%s is killed (status 0x%x)"), cmd, wstat);
- goto cleanup;
}
- if (WEXITSTATUS(wstat)) {
+ else if (WEXITSTATUS(wstat)) {
error (0, 0, _("%s exited with code %d"),
cmd, WEXITSTATUS(wstat));
- goto cleanup;
}
- DPRINTF("...child exited\n");
+ else {
+ DPRINTF("...child exited\n");
+ }
+
+ if (strncmp(ami_id_buf,"pending",sizeof("pending")-1)==0) {
+ strcpy(ami_id_buf,"failed (back-end)");
+ }
cleanup:
free(vm_image);
12 years, 9 months
[iwhd] doc: update comments
by Jim Meyering
commit b2dc64039e812dc0a7f89919a10eb861fc41daae
Author: Pete Zaitcev <zaitcev(a)kotori.zaitcev.us>
Date: Wed Jul 6 17:04:05 2011 -0600
doc: update comments
We supported SSL in RHEV-M URLs since the addition of RHEV-M 2.2, which
almost always comes with SSL and nothing else. So, delete the comment.
Also, we have docs.
backend.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
---
diff --git a/backend.c b/backend.c
index 163f1e8..cd1a685 100644
--- a/backend.c
+++ b/backend.c
@@ -1465,10 +1465,6 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
}
#endif
- /*
- * This is always "http://xxxxxx.xxxx.xxx/rhevm-api".
- * SSL does not work yet, sorry.
- */
api_url = kv_hash_lookup(args,"api-url");
if (!api_url) {
/* TBD: This has to have a defined field in provider, too. */
@@ -1495,7 +1491,7 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
}
/*
- * We need to document how this all works.
+ * Details are in doc/registrations.md, but here's the gist:
* - NFS host and NFS path are matched against the list of storage
* domains in RHEV-M (we fetch the list using RESTful API).
* This way we find the UUIDs that we have to write out.
12 years, 9 months