Skip to content

Commit

Permalink
use_wolfssl: Fix compilation with WolfSSL and disable cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoftsm committed Apr 28, 2024
1 parent 6f31fea commit c815ede
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/claim/claim.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CLAIM_AGENT_RESPONSE claim_agent(const char *claiming_arguments, bool force, con
return CLAIM_AGENT_CLOUD_DISABLED;
}

#ifndef DISABLE_CLOUD
#if defined(ENABLE_CLOUD) && defined(ENABLE_ACLK)
int exit_code;
pid_t command_pid;
char command_exec_buffer[CLAIMING_COMMAND_LENGTH + 1];
Expand Down
7 changes: 7 additions & 0 deletions src/daemon/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,17 @@ static cmd_status_t cmd_ping_execute(char *args, char **message)
static cmd_status_t cmd_aclk_state(char *args, char **message)
{
netdata_log_info("COMMAND: Reopening aclk/cloud state.");
#ifdef ENABLE_ACLK
if (strstr(args, "json"))
*message = aclk_state_json();
else
*message = aclk_state();
#else
if (strstr(args, "json"))
*message = strdupz("{\"aclk-available\":false}");
else
*message = strdupz("ACLK Available: No");;
#endif

return CMD_STATUS_SUCCESS;
}
Expand Down
6 changes: 6 additions & 0 deletions src/database/contexts/api_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ static void rrdhost_sender_to_json(BUFFER *wb, RRDHOST_STATUS *s, const char *ke
buffer_json_object_close(wb); // streaming
}

#ifdef ENABLE_ACLK
static void agent_capabilities_to_json(BUFFER *wb, RRDHOST *host, const char *key) {
buffer_json_member_add_array(wb, key);

Expand All @@ -816,6 +817,7 @@ static void agent_capabilities_to_json(BUFFER *wb, RRDHOST *host, const char *ke
buffer_json_array_close(wb);
freez(capas);
}
#endif

static inline void host_dyncfg_to_json_v2(BUFFER *wb, const char *key, RRDHOST_STATUS *s) {
buffer_json_member_add_object(wb, key);
Expand Down Expand Up @@ -893,7 +895,9 @@ static void rrdcontext_to_json_v2_rrdhost(BUFFER *wb, RRDHOST *host, struct rrdc
buffer_json_member_add_string(wb, "state", rrdhost_state_cloud_emulation(host) ? "reachable" : "stale");

rrdhost_health_to_json_v2(wb, "health", &s);
#ifdef ENABLE_ACLK
agent_capabilities_to_json(wb, host, "capabilities");
#endif
}

if (ctl->mode & (CONTEXTS_V2_NODE_INSTANCES)) {
Expand Down Expand Up @@ -937,7 +941,9 @@ static void rrdcontext_to_json_v2_rrdhost(BUFFER *wb, RRDHOST *host, struct rrdc
rrdhost_health_to_json_v2(wb, "health", &s);

host_functions2json(host, wb); // functions
#ifdef ENABLE_ACLK
agent_capabilities_to_json(wb, host, "capabilities");
#endif

host_dyncfg_to_json_v2(wb, "dyncfg", &s);
}
Expand Down
2 changes: 2 additions & 0 deletions src/database/contexts/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,11 @@ static void rrdcontext_dequeue_from_hub_queue(RRDCONTEXT *rc) {

static void rrdcontext_dispatch_queued_contexts_to_hub(RRDHOST *host, usec_t now_ut) {

#ifdef ENABLE_ACLK
// check if we have received a streaming command for this host
if(!rrdhost_flag_check(host, RRDHOST_FLAG_ACLK_STREAM_CONTEXTS) || !aclk_connected || !host->rrdctx.hub_queue)
return;
#endif

// check if there are queued items to send
if(!dictionary_entries(host->rrdctx.hub_queue))
Expand Down
4 changes: 4 additions & 0 deletions src/database/rrdfunctions-inflight.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,17 @@ int rrd_function_run(RRDHOST *host, BUFFER *result_wb, int timeout_s,

if(!http_access_user_has_enough_access_level_for_endpoint(user_access, rdcf->access)) {

#ifdef ENABLE_ACLK
if(!aclk_connected)
code = rrd_call_function_error(result_wb,
"This Netdata must be connected to Netdata Cloud for Single-Sign-On (SSO) "
"access this feature. Claim this Netdata to Netdata Cloud to enable access.",
HTTP_ACCESS_PERMISSION_DENIED_HTTP_CODE(user_access));

else if((rdcf->access & HTTP_ACCESS_SIGNED_ID) && !(user_access & HTTP_ACCESS_SIGNED_ID))
#else
if((rdcf->access & HTTP_ACCESS_SIGNED_ID) && !(user_access & HTTP_ACCESS_SIGNED_ID))
#endif
code = rrd_call_function_error(result_wb,
"You need to be authenticated via Netdata Cloud Single-Sign-On (SSO) "
"to access this feature. Sign-in on this dashboard, "
Expand Down
2 changes: 2 additions & 0 deletions src/database/rrdhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,9 @@ static void rrdhost_load_auto_labels(void) {
if (localhost->system_info->prebuilt_dist)
rrdlabels_add(labels, "_prebuilt_dist", localhost->system_info->prebuilt_dist, RRDLABEL_SRC_AUTO);

#ifdef ENABLE_ACLK
add_aclk_host_labels();
#endif

// The source should be CONF, but when it is set, these labels are exported by default ('send configured labels' in exporting.conf).
// Their export seems to break exporting to Graphite, see https://github.com/netdata/netdata/issues/14084.
Expand Down
2 changes: 2 additions & 0 deletions src/streaming/receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,9 @@ static bool rrdhost_set_receiver(RRDHOST *host, struct receiver_state *rpt) {
rrdpush_receiver_replication_reset(host);

rrdhost_flag_clear(rpt->host, RRDHOST_FLAG_RRDPUSH_RECEIVER_DISCONNECTED);
#ifdef ENABLE_ACLK
aclk_queue_node_info(rpt->host, true);
#endif

rrdpush_reset_destinations_postpone_time(host);

Expand Down
4 changes: 4 additions & 0 deletions src/streaming/sender.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ static bool rrdpush_sender_connect_ssl(struct sender_state *s __maybe_unused) {
#endif
}

#if defined(ENABLE_H2O) && defined(ENABLE_OPENSSL)
static int rrdpush_http_upgrade_prelude(RRDHOST *host, struct sender_state *s) {

char http[HTTP_HEADER_SIZE + 1];
Expand Down Expand Up @@ -731,6 +732,7 @@ static int rrdpush_http_upgrade_prelude(RRDHOST *host, struct sender_state *s) {
http_parse_ctx_destroy(&ctx);
return 1;
}
#endif

static bool rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_port, int timeout, struct sender_state *s) {

Expand Down Expand Up @@ -869,6 +871,7 @@ static bool rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_p
if(!rrdpush_sender_connect_ssl(s))
return false;

#if defined(ENABLE_H2O) && defined(ENABLE_OPENSSL)
if (s->parent_using_h2o && rrdpush_http_upgrade_prelude(host, s)) {
ND_LOG_STACK lgs[] = {
ND_LOG_FIELD_TXT(NDF_RESPONSE_CODE, RRDPUSH_STATUS_CANT_UPGRADE_CONNECTION),
Expand All @@ -882,6 +885,7 @@ static bool rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_p
host->destination->postpone_reconnection_until = now_realtime_sec() + 1 * 60;
return false;
}
#endif

ssize_t bytes, len = (ssize_t)strlen(http);

Expand Down
4 changes: 4 additions & 0 deletions src/web/api/web_api_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,7 @@ inline int web_client_api_request_v1_info(RRDHOST *host, struct web_client *w, c
return HTTP_RESP_OK;
}

#ifdef ENABLE_OPENSSL
static int web_client_api_request_v1_aclk_state(RRDHOST *host, struct web_client *w, char *url) {
UNUSED(url);
UNUSED(host);
Expand All @@ -1431,6 +1432,7 @@ static int web_client_api_request_v1_aclk_state(RRDHOST *host, struct web_client
buffer_no_cacheable(wb);
return HTTP_RESP_OK;
}
#endif

int web_client_api_request_v1_metric_correlations(RRDHOST *host, struct web_client *w, char *url) {
return web_client_api_request_weights(host, w, url, default_metric_correlations_method, WEIGHTS_FORMAT_CHARTS, 1);
Expand Down Expand Up @@ -1890,6 +1892,7 @@ static struct web_api_command api_commands_v1[] = {
.callback = web_client_api_request_v1_info,
.allow_subpaths = 0
},
#ifdef ENABLE_OPENSSL
{
.api = "aclk",
.hash = 0,
Expand All @@ -1898,6 +1901,7 @@ static struct web_api_command api_commands_v1[] = {
.callback = web_client_api_request_v1_aclk_state,
.allow_subpaths = 0
},
#endif
{
// deprecated - use /api/v2/info
.api = "dbengine_stats",
Expand Down

0 comments on commit c815ede

Please sign in to comment.