summaryrefslogtreecommitdiffstats
path: root/src/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.c')
-rw-r--r--src/client.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/src/client.c b/src/client.c
index cdc7b6b..2480768 100644
--- a/src/client.c
+++ b/src/client.c
@@ -1290,11 +1290,9 @@ static int og_agent_http_response_code(const char *buf)
return -1;
}
-static int og_clear_image_placeholder()
+static int og_resp_image_create_error(struct og_client *cli)
{
- uint32_t image_id = 0;
struct og_dbi *dbi;
- dbi_result result;
dbi = og_dbi_open(&ogconfig.db);
if (!dbi) {
@@ -1303,26 +1301,9 @@ static int og_clear_image_placeholder()
return -1;
}
- result = dbi_conn_queryf(dbi->conn,
- "SELECT idimagen FROM imagenes WHERE fechacreacion IS NULL");
- if (!result) {
- syslog(LOG_ERR, "failed to query database\n");
- return -1;
- }
-
- if (!dbi_result_next_row(result)) {
- dbi_result_free(result);
- og_dbi_close(dbi);
- return 0;
- }
-
- image_id = dbi_result_get_uint(result, "idimagen");
- dbi_result_free(result);
-
- syslog(LOG_INFO, "Trying to delete uninitialized image with id %d\n", image_id);
-
- if (og_dbi_delete_image(dbi, image_id) < 0) {
- og_dbi_close(dbi);
+ if (og_dbi_delete_image(dbi, cli->last_cmd.ctx.image.id) < 0) {
+ syslog(LOG_WARNING, "Cannot delete image stub with id %d\n",
+ cli->last_cmd.ctx.image.id);
return -1;
}
@@ -1334,6 +1315,7 @@ static void og_client_reset_cmd(struct og_client *cli)
{
cli->last_cmd.id = 0;
cli->last_cmd.type = OG_CMD_UNSPEC;
+ memset(&cli->last_cmd.ctx, 0, sizeof(cli->last_cmd.ctx));
}
int og_agent_state_process_response(struct og_client *cli)
@@ -1389,11 +1371,16 @@ int og_agent_state_process_response(struct og_client *cli)
else
cli->last_cmd.result = OG_FAILURE;
- if (!success && cmd_type == OG_CMD_IMAGE_CREATE)
- og_clear_image_placeholder();
+ if (!success && cmd_type == OG_CMD_IMAGE_CREATE) {
+ syslog(LOG_ERR, "Client %s:%hu reports failure when creating image with id %d\n",
+ inet_ntoa(cli->addr.sin_addr), ntohs(cli->addr.sin_port),
+ cli->last_cmd.ctx.image.id);
+ og_resp_image_create_error(cli);
+ }
if (code != 200 && code != 103) {
cli->last_cmd.id = 0;
+ memset(&cli->last_cmd.ctx, 0, sizeof(cli->last_cmd.ctx));
return ret;
}