@cryptotaxi247 / netdata-1 / commits / df8930ddd

Send ML feature information with UpdateNodeInfo. (#11913)

* Send ML feature information with UpdateNodeInfo. We achieve this by adding the `ml_{capable,enabled}` fields in `system_info`. When streaming, these fields allow a parent to understand if the child has ML and if it runs ML for itself. The UpdateNodeInfo includes this information about a child, plus a boolean that is set to true when the parent runs ML for the child. * Fix unit test and building with --disable-ml. * Refactoring to use the new MachineLearningInfo message * Update aclk-schemas repository to include latest ML info message.

vkalintiris committed Dec 22, 2021 at 11:15 UTC df8930ddd370b2a9fec96b1cbb45e8ae530c0aad
8 files changed +57 -2
aclk/aclk-schemas
+1 -1
@@ -1 +1 @@
1 -Subproject commit 72d0a600dccf965b939a1ae4f7818d0ac896842a
1 +Subproject commit b23f6a671ccf6d2766d6a208fc1e48b0fbf2fdad
aclk/schema-wrappers/node_info.cc
+8
@@ -62,6 +62,10 @@ static int generate_node_info(nodeinstance::info::v1::NodeInfo *info, struct acl
62 if (data->machine_guid)
63 info->set_machine_guid(data->machine_guid);
64
65 + nodeinstance::info::v1::MachineLearningInfo *ml_info = info->mutable_ml_info();
66 + ml_info->set_ml_capable(data->ml_info.ml_capable);
67 + ml_info->set_ml_enabled(data->ml_info.ml_enabled);
68 +
69 map = info->mutable_host_labels();
70 label = data->host_labels_head;
71 while (label) {
@@ -86,6 +90,10 @@ char *generate_update_node_info_message(size_t *len, struct update_node_info *in
90 msg.set_machine_guid(info->machine_guid);
91 msg.set_child(info->child);
92
93 + nodeinstance::info::v1::MachineLearningInfo *ml_info = msg.mutable_ml_info();
94 + ml_info->set_ml_capable(info->ml_info.ml_capable);
95 + ml_info->set_ml_enabled(info->ml_info.ml_enabled);
96 +
97 *len = PROTO_COMPAT_MSG_SIZE(msg);
98 char *bin = (char*)malloc(*len);
99 if (bin)
aclk/schema-wrappers/node_info.h
+9
@@ -11,6 +11,11 @@
11 extern "C" {
12 #endif
13
14 +struct machine_learning_info {
15 + bool ml_capable;
16 + bool ml_enabled;
17 +};
18 +
19 struct aclk_node_info {
20 char *name;
21
@@ -49,6 +54,8 @@ struct aclk_node_info {
54 char *machine_guid;
55
56 struct label *host_labels_head;
57 +
58 + struct machine_learning_info ml_info;
59 };
60
61 struct update_node_info {
@@ -58,6 +65,8 @@ struct update_node_info {
65 struct timeval updated_at;
66 char *machine_guid;
67 int child;
68 +
69 + struct machine_learning_info ml_info;
70 };
71
72 char *generate_update_node_info_message(size_t *len, struct update_node_info *info);
database/rrd.h
+2
@@ -754,6 +754,8 @@ struct rrdhost_system_info {
754 char *container_detection;
755 char *is_k8s_node;
756 uint16_t hops;
757 + bool ml_capable;
758 + bool ml_enabled;
759 };
760
761 struct rrdhost {
database/rrdhost.c
+12
@@ -382,7 +382,19 @@ RRDHOST *rrdhost_create(const char *hostname,
382 else localhost = host;
383 }
384
385 + // ------------------------------------------------------------------------
386 + // init new ML host and update system_info to let upstreams know
387 + // about ML functionality
388 +
389 ml_new_host(host);
390 + if (is_localhost && host->system_info) {
391 +#ifndef ENABLE_ML
392 + host->system_info->ml_capable = 0;
393 +#else
394 + host->system_info->ml_capable = 1;
395 +#endif
396 + host->system_info->ml_enabled = host->ml_host != NULL;
397 + }
398
399 info("Host '%s' (at registry as '%s') with guid '%s' initialized"
400 ", os '%s'"
database/sqlite/sqlite_aclk_node.c
+4
@@ -22,6 +22,8 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat
22 node_info.claim_id = is_agent_claimed();
23 node_info.machine_guid = wc->host_guid;
24 node_info.child = (wc->host != localhost);
25 + node_info.ml_info.ml_capable = localhost->system_info->ml_capable;
26 + node_info.ml_info.ml_enabled = wc->host->ml_host != NULL;
27 now_realtime_timeval(&node_info.updated_at);
28
29 RRDHOST *host = wc->host;
@@ -46,6 +48,8 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat
48 node_info.data.services = NULL; // char **
49 node_info.data.service_count = 0;
50 node_info.data.machine_guid = wc->host_guid;
51 + node_info.data.ml_info.ml_capable = host->system_info->ml_capable;
52 + node_info.data.ml_info.ml_enabled = host->system_info->ml_enabled;
53
54 struct label_index *labels = &host->labels;
55 netdata_rwlock_wrlock(&labels->labels_rwlock);
streaming/rrdpush.c
+4
@@ -522,6 +522,10 @@ int rrdpush_receiver_thread_spawn(struct web_client *w, char *url) {
522 utc_offset = (int32_t)strtol(value, NULL, 0);
523 else if(!strcmp(name, "hops"))
524 system_info->hops = (uint16_t) strtoul(value, NULL, 0);
525 + else if(!strcmp(name, "ml_capable"))
526 + system_info->ml_capable = strtoul(value, NULL, 0);
527 + else if(!strcmp(name, "ml_enabled"))
528 + system_info->ml_enabled = strtoul(value, NULL, 0);
529 else if(!strcmp(name, "tags"))
530 tags = value;
531 else if(!strcmp(name, "ver"))
streaming/sender.c
+17 -1
@@ -214,7 +214,21 @@ static int rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_po
214
215 char http[HTTP_HEADER_SIZE + 1];
216 int eol = snprintfz(http, HTTP_HEADER_SIZE,
217 - "STREAM key=%s&hostname=%s&registry_hostname=%s&machine_guid=%s&update_every=%d&os=%s&timezone=%s&abbrev_timezone=%s&utc_offset=%d&hops=%d&tags=%s&ver=%u"
217 + "STREAM "
218 + "key=%s"
219 + "&hostname=%s"
220 + "&registry_hostname=%s"
221 + "&machine_guid=%s"
222 + "&update_every=%d"
223 + "&os=%s"
224 + "&timezone=%s"
225 + "&abbrev_timezone=%s"
226 + "&utc_offset=%d"
227 + "&hops=%d"
228 + "&ml_capable=%d"
229 + "&ml_enabled=%d"
230 + "&tags=%s"
231 + "&ver=%u"
232 "&NETDATA_SYSTEM_OS_NAME=%s"
233 "&NETDATA_SYSTEM_OS_ID=%s"
234 "&NETDATA_SYSTEM_OS_ID_LIKE=%s"
@@ -253,6 +267,8 @@ static int rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_po
267 , host->abbrev_timezone
268 , host->utc_offset
269 , host->system_info->hops + 1
270 + , host->system_info->ml_capable
271 + , host->system_info->ml_enabled
272 , (host->tags) ? host->tags : ""
273 , STREAMING_PROTOCOL_CURRENT_VERSION
274 , se.os_name