Skip to content

Commit

Permalink
minor Dyncfg mvp0 fixes (netdata#15785)
Browse files Browse the repository at this point in the history
* fix invalid url response if first error exit taken
* fixup job state in master
* minor - fix nonsense comment
  • Loading branch information
underhood committed Aug 10, 2023
1 parent f04d9f5 commit 060dfc8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions collectors/plugins.d/pluginsd_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2397,6 +2397,9 @@ PARSER_RC parser_execute(PARSER *parser, PARSER_KEYWORD *keyword, char **words,
case 102:
return pluginsd_register_module(words, num_words, parser);

case 110:
return pluginsd_job_status(words, num_words, parser);

default:
fatal("Unknown keyword '%s' with id %zu", keyword->keyword, keyword->id);
}
Expand Down
4 changes: 2 additions & 2 deletions libnetdata/dyn_conf/dyn_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum job_status {
JOB_STATUS_ERROR
};

inline enum job_status str2job_state(const char *state_name) {
static inline enum job_status str2job_state(const char *state_name) {
if (strcmp(state_name, "stopped") == 0)
return JOB_STATUS_STOPPED;
else if (strcmp(state_name, "running") == 0)
Expand All @@ -57,7 +57,7 @@ struct job
{
char *name;

//state reported by config
// state reported by plugin
enum job_status status; // reported by plugin, enum as this has to be interpreted by UI
int state; // code reported by plugin which can mean anything plugin wants
char *reason; // reported by plugin, can be NULL (optional)
Expand Down
3 changes: 2 additions & 1 deletion web/api/web_api_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,10 @@ static int web_client_api_request_v2_config(RRDHOST *host __maybe_unused, struct
char *url = strdupz(buffer_tostring(w->url_as_received));
char *url_full = url;

buffer_flush(w->response.data);
if (strncmp(url, CONFIG_API_V2_URL, strlen(CONFIG_API_V2_URL)) != 0) {
buffer_sprintf(w->response.data, "Invalid URL");
freez(url_full);
return HTTP_RESP_BAD_REQUEST;
}
url += strlen(CONFIG_API_V2_URL);
Expand All @@ -669,7 +671,6 @@ static int web_client_api_request_v2_config(RRDHOST *host __maybe_unused, struct
char *job_id = strtok_r(NULL, "/", &save_ptr);
char *extra = strtok_r(NULL, "/", &save_ptr);

buffer_flush(w->response.data);
if (extra != NULL) {
buffer_sprintf(w->response.data, "Invalid URL");
freez(url_full);
Expand Down

0 comments on commit 060dfc8

Please sign in to comment.