minor Dyncfg mvp0 fixes (#15785)
* fix invalid url response if first error exit taken * fixup job state in master * minor - fix nonsense comment
Timotej S committed
Aug 10, 2023 at 15:15 UTC
060dfc80ed6de73416fff69761bdc9e32abfbcfd
3 files changed
+7
-3
collectors/plugins.d/pluginsd_parser.c
+3
@@ -2397,6 +2397,9 @@ PARSER_RC parser_execute(PARSER *parser, PARSER_KEYWORD *keyword, char **words,
2397
case 102:
2398
return pluginsd_register_module(words, num_words, parser);
2399
2400
+ case 110:
2401
+ return pluginsd_job_status(words, num_words, parser);
2402
+
2403
default:
2404
fatal("Unknown keyword '%s' with id %zu", keyword->keyword, keyword->id);
2405
}
libnetdata/dyn_conf/dyn_conf.h
+2
-2
@@ -37,7 +37,7 @@ enum job_status {
37
JOB_STATUS_ERROR
38
};
39
40
-inline enum job_status str2job_state(const char *state_name) {
40
+static inline enum job_status str2job_state(const char *state_name) {
41
if (strcmp(state_name, "stopped") == 0)
42
return JOB_STATUS_STOPPED;
43
else if (strcmp(state_name, "running") == 0)
@@ -57,7 +57,7 @@ struct job
57
{
58
char *name;
59
60
- //state reported by config
60
+ // state reported by plugin
61
enum job_status status; // reported by plugin, enum as this has to be interpreted by UI
62
int state; // code reported by plugin which can mean anything plugin wants
63
char *reason; // reported by plugin, can be NULL (optional)
web/api/web_api_v2.c
+2
-1
@@ -657,8 +657,10 @@ static int web_client_api_request_v2_config(RRDHOST *host __maybe_unused, struct
657
char *url = strdupz(buffer_tostring(w->url_as_received));
658
char *url_full = url;
659
660
+ buffer_flush(w->response.data);
661
if (strncmp(url, CONFIG_API_V2_URL, strlen(CONFIG_API_V2_URL)) != 0) {
662
buffer_sprintf(w->response.data, "Invalid URL");
663
+ freez(url_full);
664
return HTTP_RESP_BAD_REQUEST;
665
}
666
url += strlen(CONFIG_API_V2_URL);
@@ -669,7 +671,6 @@ static int web_client_api_request_v2_config(RRDHOST *host __maybe_unused, struct
671
char *job_id = strtok_r(NULL, "/", &save_ptr);
672
char *extra = strtok_r(NULL, "/", &save_ptr);
673
672
- buffer_flush(w->response.data);
674
if (extra != NULL) {
675
buffer_sprintf(w->response.data, "Invalid URL");
676
freez(url_full);