@cryptotaxi247 / netdata-1 / commits / a61257231

aesthetic changes in the code (#18808)

Costa Tsaousis committed Oct 17, 2024 at 22:36 UTC a612572310fa635b8dfb5a111cdfe3f7b57b6d24
14 files changed +39 -39
src/collectors/systemd-journal.plugin/systemd-journal.c
+7 -7
@@ -753,7 +753,7 @@ static int netdata_systemd_journal_query(BUFFER *wb, LOGS_QUERY_STATUS *lqs) {
753 for(size_t f = 0; f < files_used ;f++)
754 dictionary_acquired_item_release(journal_files_registry, file_items[f]);
755
756 - return rrd_call_function_error(wb, "not modified", HTTP_RESP_NOT_MODIFIED);
756 + return rrd_call_function_error(wb, "No new data since the previous call.", HTTP_RESP_NOT_MODIFIED);
757 }
758
759 // sort the files, so that they are optimal for facets
@@ -911,7 +911,7 @@ static int netdata_systemd_journal_query(BUFFER *wb, LOGS_QUERY_STATUS *lqs) {
911 switch (status) {
912 case ND_SD_JOURNAL_OK:
913 if(lqs->rq.if_modified_since && !lqs->c.rows_useful)
914 - return rrd_call_function_error(wb, "no useful logs, not modified", HTTP_RESP_NOT_MODIFIED);
914 + return rrd_call_function_error(wb, "No additional useful data since the previous call.", HTTP_RESP_NOT_MODIFIED);
915 break;
916
917 case ND_SD_JOURNAL_TIMED_OUT:
@@ -919,19 +919,19 @@ static int netdata_systemd_journal_query(BUFFER *wb, LOGS_QUERY_STATUS *lqs) {
919 break;
920
921 case ND_SD_JOURNAL_CANCELLED:
922 - return rrd_call_function_error(wb, "client closed connection", HTTP_RESP_CLIENT_CLOSED_REQUEST);
922 + return rrd_call_function_error(wb, "Request cancelled.", HTTP_RESP_CLIENT_CLOSED_REQUEST);
923
924 case ND_SD_JOURNAL_NOT_MODIFIED:
925 - return rrd_call_function_error(wb, "not modified", HTTP_RESP_NOT_MODIFIED);
925 + return rrd_call_function_error(wb, "No new data since the previous call.", HTTP_RESP_NOT_MODIFIED);
926
927 case ND_SD_JOURNAL_FAILED_TO_OPEN:
928 - return rrd_call_function_error(wb, "failed to open journal", HTTP_RESP_INTERNAL_SERVER_ERROR);
928 + return rrd_call_function_error(wb, "Failed to open systemd journal file.", HTTP_RESP_INTERNAL_SERVER_ERROR);
929
930 case ND_SD_JOURNAL_FAILED_TO_SEEK:
931 - return rrd_call_function_error(wb, "failed to seek in journal", HTTP_RESP_INTERNAL_SERVER_ERROR);
931 + return rrd_call_function_error(wb, "Failed to seek in systemd journal file.", HTTP_RESP_INTERNAL_SERVER_ERROR);
932
933 default:
934 - return rrd_call_function_error(wb, "unknown status", HTTP_RESP_INTERNAL_SERVER_ERROR);
934 + return rrd_call_function_error(wb, "Unknown status", HTTP_RESP_INTERNAL_SERVER_ERROR);
935 }
936
937 buffer_json_member_add_uint64(wb, "status", HTTP_RESP_OK);
src/daemon/config/dyncfg-tree.c
+1 -1
@@ -264,7 +264,7 @@ static int dyncfg_config_execute_cb(struct rrd_function_execute *rfe, void *data
264
265 rrd_call_function_error(
266 rfe->result.wb,
267 - "unknown config id given", code);
267 + "Unknown config id given.", code);
268 }
269
270 cleanup:
src/database/rrdfunctions-exporters.c
+4 -4
@@ -60,7 +60,7 @@ static void functions2json(DICTIONARY *functions, BUFFER *wb) {
60 struct rrd_host_function *t;
61 dfe_start_read(functions, t) {
62 if (!rrd_collector_running(t->collector)) continue;
63 - if(t->options & (RRD_FUNCTION_DYNCFG|RRD_FUNCTION_HIDDEN)) continue;
63 + if(t->options & (RRD_FUNCTION_DYNCFG| RRD_FUNCTION_RESTRICTED)) continue;
64
65 buffer_json_member_add_object(wb, t_dfe.name);
66 {
@@ -99,7 +99,7 @@ void host_functions2json(RRDHOST *host, BUFFER *wb) {
99 struct rrd_host_function *t;
100 dfe_start_read(host->functions, t) {
101 if(!rrd_collector_running(t->collector)) continue;
102 - if(t->options & (RRD_FUNCTION_DYNCFG|RRD_FUNCTION_HIDDEN)) continue;
102 + if(t->options & (RRD_FUNCTION_DYNCFG| RRD_FUNCTION_RESTRICTED)) continue;
103
104 buffer_json_member_add_object(wb, t_dfe.name);
105 {
@@ -130,7 +130,7 @@ void chart_functions_to_dict(DICTIONARY *rrdset_functions_view, DICTIONARY *dst,
130 struct rrd_host_function *t;
131 dfe_start_read(rrdset_functions_view, t) {
132 if(!rrd_collector_running(t->collector)) continue;
133 - if(t->options & (RRD_FUNCTION_DYNCFG|RRD_FUNCTION_HIDDEN)) continue;
133 + if(t->options & (RRD_FUNCTION_DYNCFG| RRD_FUNCTION_RESTRICTED)) continue;
134
135 dictionary_set(dst, t_dfe.name, value, value_size);
136 }
@@ -144,7 +144,7 @@ void host_functions_to_dict(RRDHOST *host, DICTIONARY *dst, void *value, size_t
144 struct rrd_host_function *t;
145 dfe_start_read(host->functions, t) {
146 if(!rrd_collector_running(t->collector)) continue;
147 - if(t->options & (RRD_FUNCTION_DYNCFG|RRD_FUNCTION_HIDDEN)) continue;
147 + if(t->options & (RRD_FUNCTION_DYNCFG| RRD_FUNCTION_RESTRICTED)) continue;
148
149 if(help)
150 *help = t->help;
src/database/rrdfunctions-inflight.c
+7 -7
@@ -351,7 +351,7 @@ static int rrd_call_function_async_and_wait(struct rrd_function_inflight *r) {
351 HTTP_RESP_CLIENT_CLOSED_REQUEST);
352 else
353 code = rrd_call_function_error(r->result.wb,
354 - "Timeout while waiting for a response from the collector.",
354 + "Timeout while waiting for a response from the plugin that serves this features",
355 HTTP_RESP_GATEWAY_TIMEOUT);
356
357 tmp->free_with_signal = true;
@@ -359,7 +359,7 @@ static int rrd_call_function_async_and_wait(struct rrd_function_inflight *r) {
359 }
360 else {
361 code = rrd_call_function_error(
362 - r->result.wb, "Internal error while communicating with the collector",
362 + r->result.wb, "Internal error while communicating with the plugin that serves this feature.",
363 HTTP_RESP_INTERNAL_SERVER_ERROR);
364
365 tmp->free_with_signal = true;
@@ -398,7 +398,7 @@ int rrd_function_run(RRDHOST *host, BUFFER *result_wb, int timeout_s,
398 rrd_function_result_callback_t result_cb, void *result_cb_data,
399 rrd_function_progress_cb_t progress_cb, void *progress_cb_data,
400 rrd_function_is_cancelled_cb_t is_cancelled_cb, void *is_cancelled_cb_data,
401 - BUFFER *payload, const char *source, bool hidden) {
401 + BUFFER *payload, const char *source, bool allow_restricted) {
402
403 int code;
404 char sanitized_cmd[PLUGINSD_LINE_MAX + 1];
@@ -412,7 +412,7 @@ int rrd_function_run(RRDHOST *host, BUFFER *result_wb, int timeout_s,
412 if(!host) {
413 code = HTTP_RESP_INTERNAL_SERVER_ERROR;
414
415 - rrd_call_function_error(result_wb, "no host given for running the function", code);
415 + rrd_call_function_error(result_wb, "No host given for routing this request to.", code);
416
417 if(result_cb)
418 result_cb(result_wb, code, result_cb_data);
@@ -436,9 +436,9 @@ int rrd_function_run(RRDHOST *host, BUFFER *result_wb, int timeout_s,
436
437 struct rrd_host_function *rdcf = dictionary_acquired_item_value(host_function_acquired);
438
439 - if((rdcf->options & RRD_FUNCTION_HIDDEN) && !hidden) {
439 + if((rdcf->options & RRD_FUNCTION_RESTRICTED) && !allow_restricted) {
440 code = rrd_call_function_error(result_wb,
441 - "You cannot access a hidden function like this. ",
441 + "This feature is not available via this API.",
442 HTTP_ACCESS_PERMISSION_DENIED_HTTP_CODE(user_access));
443 dictionary_acquired_item_release(host->functions, host_function_acquired);
444
@@ -546,7 +546,7 @@ int rrd_function_run(RRDHOST *host, BUFFER *result_wb, int timeout_s,
546 "FUNCTIONS: duplicate transaction '%s', function: '%s'",
547 t.transaction, t.cmd);
548
549 - code = rrd_call_function_error(result_wb, "duplicate transaction", HTTP_RESP_BAD_REQUEST);
549 + code = rrd_call_function_error(result_wb, "Duplicate transaction.", HTTP_RESP_BAD_REQUEST);
550
551 rrd_functions_inflight_cleanup(&t);
552 dictionary_acquired_item_release(r->host->functions, t.host_function_acquired);
src/database/rrdfunctions-internals.h
+1 -1
@@ -11,7 +11,7 @@ typedef enum __attribute__((packed)) {
11 RRD_FUNCTION_LOCAL = (1 << 0),
12 RRD_FUNCTION_GLOBAL = (1 << 1),
13 RRD_FUNCTION_DYNCFG = (1 << 2),
14 - RRD_FUNCTION_HIDDEN = (1 << 3),
14 + RRD_FUNCTION_RESTRICTED = (1 << 3), // this function is restricted (hidden from user)
15
16 // this is 8-bit
17 } RRD_FUNCTION_OPTIONS;
src/database/rrdfunctions.c
+4 -4
@@ -161,7 +161,7 @@ void rrd_functions_host_destroy(RRDHOST *host) {
161
162 // ----------------------------------------------------------------------------
163
164 -static inline bool is_function_hidden(const char *name, const char *tags) {
164 +static inline bool is_function_restricted(const char *name, const char *tags) {
165 return (name && name[0] == '_' && name[1] == '_') || (tags && strstr(tags, RRDFUNCTIONS_TAG_HIDDEN) != NULL);
166 }
167
@@ -185,7 +185,7 @@ static inline RRD_FUNCTION_OPTIONS get_function_options(RRDSET *st, const char *
185
186 RRD_FUNCTION_OPTIONS options = st ? RRD_FUNCTION_LOCAL : RRD_FUNCTION_GLOBAL;
187
188 - return options | (is_function_hidden(name, tags) ? RRD_FUNCTION_HIDDEN : 0);
188 + return options | (is_function_restricted(name, tags) ? RRD_FUNCTION_RESTRICTED : 0);
189 }
190
191 void rrd_function_add(RRDHOST *host, RRDSET *st, const char *name, int timeout, int priority,
@@ -283,11 +283,11 @@ int rrd_functions_find_by_name(RRDHOST *host, BUFFER *wb, const char *name, size
283 if(!(*item)) {
284 if(found)
285 return rrd_call_function_error(wb,
286 - "The collector that registered this function, is not currently running.",
286 + "The plugin that registered this feature, is not currently running.",
287 HTTP_RESP_SERVICE_UNAVAILABLE);
288 else
289 return rrd_call_function_error(wb,
290 - "No collector is supplying this function on this host at this time.",
290 + "This feature is not available on this host at this time.",
291 HTTP_RESP_NOT_FOUND);
292 }
293
src/database/rrdfunctions.h
+1 -1
@@ -80,7 +80,7 @@ int rrd_function_run(RRDHOST *host, BUFFER *result_wb, int timeout_s,
80 rrd_function_result_callback_t result_cb, void *result_cb_data,
81 rrd_function_progress_cb_t progress_cb, void *progress_cb_data,
82 rrd_function_is_cancelled_cb_t is_cancelled_cb, void *is_cancelled_cb_data,
83 - BUFFER *payload, const char *source, bool hidden);
83 + BUFFER *payload, const char *source, bool allow_restricted);
84
85 bool rrd_function_available(RRDHOST *host, const char *function);
86
src/libnetdata/json/json-c-parser-inline.c
+2 -2
@@ -16,13 +16,13 @@ int rrd_call_function_error(BUFFER *wb, const char *msg, int code) {
16
17 struct json_object *json_parse_function_payload_or_error(BUFFER *output, BUFFER *payload, int *code, json_parse_function_payload_t cb, void *cb_data) {
18 if(!payload || !buffer_strlen(payload)) {
19 - *code = rrd_call_function_error(output, "No payload given", HTTP_RESP_BAD_REQUEST);
19 + *code = rrd_call_function_error(output, "No payload given, but a payload is required for this feature.", HTTP_RESP_BAD_REQUEST);
20 return NULL;
21 }
22
23 struct json_tokener *tokener = json_tokener_new();
24 if (!tokener) {
25 - *code = rrd_call_function_error(output, "Cannot initialize json parser", HTTP_RESP_INTERNAL_SERVER_ERROR);
25 + *code = rrd_call_function_error(output, "Failed to initialize json parser.", HTTP_RESP_INTERNAL_SERVER_ERROR);
26 return NULL;
27 }
28
src/plugins.d/pluginsd_functions.c
+4 -4
@@ -59,7 +59,7 @@ static void inflight_functions_insert_callback(const DICTIONARY_ITEM *item, void
59
60 pf->code = HTTP_RESP_SERVICE_UNAVAILABLE;
61 netdata_log_error("FUNCTION '%s': failed to send it to the plugin, error %zd", string2str(pf->function), ret);
62 - rrd_call_function_error(pf->result_body_wb, "Failed to communicate with collector", pf->code);
62 + rrd_call_function_error(pf->result_body_wb, "Failed to send this request to the plugin that offered it.", pf->code);
63 }
64 else {
65 pf->sent_successfully = true;
@@ -75,7 +75,7 @@ static bool inflight_functions_conflict_callback(const DICTIONARY_ITEM *item __m
75 struct inflight_function *pf = new_func;
76
77 netdata_log_error("PLUGINSD_PARSER: duplicate UUID on pending function '%s' detected. Ignoring the second one.", string2str(pf->function));
78 - pf->code = rrd_call_function_error(pf->result_body_wb, "This request is already in progress", HTTP_RESP_BAD_REQUEST);
78 + pf->code = rrd_call_function_error(pf->result_body_wb, "This transaction is already in progress.", HTTP_RESP_BAD_REQUEST);
79 pf->result.cb(pf->result_body_wb, pf->code, pf->result.data);
80 string_freez(pf->function);
81
@@ -94,7 +94,7 @@ static void inflight_functions_delete_callback(const DICTIONARY_ITEM *item __may
94 pf->sent_monotonic_ut - pf->started_monotonic_ut, now_realtime_usec() - pf->sent_monotonic_ut);
95
96 if(pf->code == HTTP_RESP_SERVICE_UNAVAILABLE && !buffer_strlen(pf->result_body_wb))
97 - rrd_call_function_error(pf->result_body_wb, "The plugin exited while servicing this call.", pf->code);
97 + rrd_call_function_error(pf->result_body_wb, "The plugin that was servicing this request, exited before responding.", pf->code);
98
99 pf->result.cb(pf->result_body_wb, pf->code, pf->result.data);
100
@@ -127,7 +127,7 @@ void pluginsd_inflight_functions_garbage_collect(PARSER *parser, usec_t now_ut)
127
128 if(!buffer_strlen(pf->result_body_wb) || pf->code == HTTP_RESP_OK)
129 pf->code = rrd_call_function_error(pf->result_body_wb,
130 - "Timeout waiting for collector response.",
130 + "Timeout waiting for a response.",
131 HTTP_RESP_GATEWAY_TIMEOUT);
132
133 dictionary_del(parser->inflight.functions, pf_dfe.name);
src/streaming/sender_execute.c
+1 -1
@@ -84,7 +84,7 @@ static void execute_commands_function(struct sender_state *s, const char *comman
84
85 if(code != HTTP_RESP_OK) {
86 if (!buffer_strlen(wb))
87 - rrd_call_function_error(wb, "Failed to route request to collector", code);
87 + rrd_call_function_error(wb, "Failed to route this request to the plugin that offered it.", code);
88 }
89 }
90 }
src/web/api/functions/function-bearer_get_token.c
+1 -1
@@ -28,7 +28,7 @@ static bool bearer_parse_json_payload(json_object *jobj, const char *path, void
28 int function_bearer_get_token(BUFFER *wb, const char *function __maybe_unused, BUFFER *payload, const char *source) {
29 if(!request_source_is_cloud(source))
30 return rrd_call_function_error(
31 - wb, "You cannot access this function from outside Netdata Cloud", HTTP_RESP_BAD_REQUEST);
31 + wb, "Bearer tokens can only be provided via NC.", HTTP_RESP_BAD_REQUEST);
32
33 int code;
34 struct bearer_token_request rq = { 0 };
src/web/api/v1/api_v1_config.c
+3 -3
@@ -46,12 +46,12 @@ int api_v1_config(RRDHOST *host, struct web_client *w, char *url __maybe_unused)
46 else {
47 DYNCFG_CMDS c = dyncfg_cmds2id(action);
48 if(!id || !*id || !dyncfg_is_valid_id(id)) {
49 - rrd_call_function_error(w->response.data, "invalid id given", HTTP_RESP_BAD_REQUEST);
49 + rrd_call_function_error(w->response.data, "Invalid id", HTTP_RESP_BAD_REQUEST);
50 return HTTP_RESP_BAD_REQUEST;
51 }
52
53 if(c == DYNCFG_CMD_NONE) {
54 - rrd_call_function_error(w->response.data, "invalid action given", HTTP_RESP_BAD_REQUEST);
54 + rrd_call_function_error(w->response.data, "Invalid action", HTTP_RESP_BAD_REQUEST);
55 return HTTP_RESP_BAD_REQUEST;
56 }
57
@@ -68,7 +68,7 @@ int api_v1_config(RRDHOST *host, struct web_client *w, char *url __maybe_unused)
68 }
69
70 if(!add_name || !*add_name || !dyncfg_is_valid_id(add_name)) {
71 - rrd_call_function_error(w->response.data, "invalid name given", HTTP_RESP_BAD_REQUEST);
71 + rrd_call_function_error(w->response.data, "Invalid name", HTTP_RESP_BAD_REQUEST);
72 return HTTP_RESP_BAD_REQUEST;
73 }
74 snprintfz(cmd, sizeof(cmd), PLUGINSD_FUNCTION_CONFIG " %s %s %s", id, dyncfg_id2cmd_one(c), add_name);
src/web/api/v2/api_v2_bearer.c
+2 -2
@@ -71,10 +71,10 @@ int api_v2_bearer_protection(RRDHOST *host __maybe_unused, struct web_client *w
71
72 int bearer_get_token_json_response(BUFFER *wb, RRDHOST *host, const char *claim_id, const char *machine_guid, const char *node_id, HTTP_USER_ROLE user_role, HTTP_ACCESS access, nd_uuid_t cloud_account_id, const char *client_name) {
73 if(!claim_id_matches_any(claim_id))
74 - return rrd_call_function_error(wb, "The request is for a different claimed agent", HTTP_RESP_BAD_REQUEST);
74 + return rrd_call_function_error(wb, "The request is for a different agent", HTTP_RESP_BAD_REQUEST);
75
76 if(!verify_host_uuids(host, machine_guid, node_id))
77 - return rrd_call_function_error(wb, "The request is missing or not matching local UUIDs", HTTP_RESP_BAD_REQUEST);
77 + return rrd_call_function_error(wb, "The request is missing or not matching local node UUIDs", HTTP_RESP_BAD_REQUEST);
78
79 nd_uuid_t uuid;
80 time_t expires_s = bearer_create_token(&uuid, user_role, access, cloud_account_id, client_name);
src/web/api/v3/api_v3_settings.c
+1 -1
@@ -260,7 +260,7 @@ int api_v3_settings(RRDHOST *host, struct web_client *w, char *url) {
260 if(web_client_flags_check_auth(w) != WEB_CLIENT_FLAG_AUTH_BEARER && strcmp(file, "default") != 0)
261 return rrd_call_function_error(
262 w->response.data,
263 - "Only the 'default' settings file is allowed for unauthenticated users",
263 + "Only the 'default' settings file is allowed for anonymous users",
264 HTTP_RESP_BAD_REQUEST);
265
266 switch(w->mode) {