summaryrefslogtreecommitdiffstats
path: root/aclk
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2022-04-19 11:32:49 +0300
committerGitHub <noreply@github.com>2022-04-19 11:32:49 +0300
commit3e1ed14d8e8fd30864ddde6a236467dc4919ed13 (patch)
tree447960a7923a2fab96a96ffa23da098f5d3fc7db /aclk
parent9d13da121c801ddcdd37af79a19ab3cdc065f2ff (diff)
Add the ability to perform a data query using an offline node id (#12650)
* Add the ability to build a host structure by node id to execute queries for archived hosts * Add the ability to execute queries from the cloud for archived hosts by node id * Add free_temporary_host function
Diffstat (limited to 'aclk')
-rw-r--r--aclk/aclk_query.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/aclk/aclk_query.c b/aclk/aclk_query.c
index ae56593103..d66d781dbb 100644
--- a/aclk/aclk_query.c
+++ b/aclk/aclk_query.c
@@ -111,6 +111,7 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
w->tv_in = query->created_tv;
now_realtime_timeval(&w->tv_ready);
+ RRDHOST *temp_host = NULL;
if (!strncmp(query->data.http_api_v2.query, NODE_ID_QUERY, strlen(NODE_ID_QUERY))) {
char *node_uuid = query->data.http_api_v2.query + strlen(NODE_ID_QUERY);
char nodeid[UUID_STR_LEN];
@@ -125,11 +126,14 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
query_host = node_id_2_rrdhost(nodeid);
if (!query_host) {
- error_report("Host with node_id \"%s\" not found! Returning 404 to Cloud!", nodeid);
- retval = 1;
- w->response.code = 404;
- aclk_http_msg_v2_err(query_thr->client, query->callback_topic, query->msg_id, w->response.code, CLOUD_EC_NODE_NOT_FOUND, CLOUD_EMSG_NODE_NOT_FOUND, NULL, 0);
- goto cleanup;
+ temp_host = sql_create_host_by_uuid(nodeid);
+ if (!temp_host) {
+ error_report("Host with node_id \"%s\" not found! Returning 404 to Cloud!", nodeid);
+ retval = 1;
+ w->response.code = 404;
+ aclk_http_msg_v2_err(query_thr->client, query->callback_topic, query->msg_id, w->response.code, CLOUD_EC_NODE_NOT_FOUND, CLOUD_EMSG_NODE_NOT_FOUND, NULL, 0);
+ goto cleanup;
+ }
}
}
@@ -150,7 +154,8 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
}
// execute the query
- t = aclk_web_api_v1_request(query_host, w, mysep ? mysep + 1 : "noop");
+ t = aclk_web_api_v1_request(query_host ? query_host : temp_host, w, mysep ? mysep + 1 : "noop");
+ free_temporary_host(temp_host);
size = (w->mode == WEB_CLIENT_MODE_FILECOPY) ? w->response.rlen : w->response.data->len;
sent = size;