summaryrefslogtreecommitdiffstats
path: root/aclk/aclk_query.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-30 18:47:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-30 18:47:05 +0000
commit97e01009d69b8fbebfebf68f51e3d126d0ed43fc (patch)
tree02e8b836c3a9d89806f3e67d4a5fe9f52dbb0061 /aclk/aclk_query.c
parentReleasing debian version 1.36.1-1. (diff)
downloadnetdata-97e01009d69b8fbebfebf68f51e3d126d0ed43fc.tar.xz
netdata-97e01009d69b8fbebfebf68f51e3d126d0ed43fc.zip
Merging upstream version 1.37.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'aclk/aclk_query.c')
-rw-r--r--aclk/aclk_query.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/aclk/aclk_query.c b/aclk/aclk_query.c
index 981c0196..5301c281 100644
--- a/aclk/aclk_query.c
+++ b/aclk/aclk_query.c
@@ -38,9 +38,7 @@ static RRDHOST *node_id_2_rrdhost(const char *node_id)
int res;
uuid_t node_id_bin, host_id_bin;
- rrd_rdlock();
- RRDHOST *host = find_host_by_node_id((char *) node_id);
- rrd_unlock();
+ RRDHOST *host = find_host_by_node_id((char *)node_id);
if (host)
return host;
@@ -54,7 +52,7 @@ static RRDHOST *node_id_2_rrdhost(const char *node_id)
return NULL;
}
uuid_unparse_lower(host_id_bin, host_id);
- return rrdhost_find_by_guid(host_id, 0);
+ return rrdhost_find_by_guid(host_id);
}
#define NODE_ID_QUERY "/node/"
@@ -82,7 +80,7 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
strcpy(w->origin, "*"); // Simulate web_client_create_on_fd()
w->cookie1[0] = 0; // Simulate web_client_create_on_fd()
w->cookie2[0] = 0; // Simulate web_client_create_on_fd()
- w->acl = 0x1f;
+ w->acl = WEB_CLIENT_ACL_ACLK;
buffer_strcat(log_buffer, query->data.http_api_v2.query);
size_t size = 0;
@@ -101,7 +99,6 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
}
}
- 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];
@@ -116,14 +113,11 @@ 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) {
- 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;
- }
+ 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;
}
}
@@ -144,8 +138,7 @@ 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 ? query_host : temp_host, w, mysep ? mysep + 1 : "noop");
- free_temporary_host(temp_host);
+ t = aclk_web_api_v1_request(query_host, w, mysep ? mysep + 1 : "noop");
size = (w->mode == WEB_CLIENT_MODE_FILECOPY) ? w->response.rlen : w->response.data->len;
sent = size;
@@ -263,7 +256,7 @@ static int send_bin_msg(struct aclk_query_thread *query_thr, aclk_query_t query)
return 0;
}
-const char *aclk_query_get_name(aclk_query_type_t qt)
+const char *aclk_query_get_name(aclk_query_type_t qt, int unknown_ok)
{
switch (qt) {
case HTTP_API_V2: return "http_api_request_v2";
@@ -280,7 +273,8 @@ const char *aclk_query_get_name(aclk_query_type_t qt)
case UPDATE_NODE_COLLECTORS: return "update_node_collectors";
case PROTO_BIN_MESSAGE: return "generic_binary_proto_message";
default:
- error_report("Unknown query type used %d", (int) qt);
+ if (!unknown_ok)
+ error_report("Unknown query type used %d", (int) qt);
return "unknown";
}
}
@@ -329,7 +323,7 @@ int aclk_query_process_msgs(struct aclk_query_thread *query_thr)
static void worker_aclk_register(void) {
worker_register("ACLKQUERY");
for (int i = 1; i < ACLK_QUERY_TYPE_COUNT; i++) {
- worker_register_job_name(i, aclk_query_get_name(i));
+ worker_register_job_name(i, aclk_query_get_name(i, 0));
}
}