Skip to content

Commit 8fe7485

Browse files
authored
Switching over to soft feature flag (netdata#8545)
Preparing for the cloud release. This changes how we handle the feature flag so that it no longer requires installer switches and can be set from the config file. This still requires internal access to use and is not ready for public access yet.
1 parent ef2bd39 commit 8fe7485

14 files changed

+98
-45
lines changed

Makefile.am

+11-9
Original file line numberDiff line numberDiff line change
@@ -469,14 +469,18 @@ BACKENDS_PLUGIN_FILES = \
469469
backends/prometheus/backend_prometheus.h \
470470
$(NULL)
471471

472-
CLAIM_PLUGIN_FILES = \
472+
CLAIM_FILES = \
473473
claim/claim.c \
474474
claim/claim.h \
475475
$(NULL)
476476

477-
ACLK_PLUGIN_FILES = \
477+
ACLK_FILES = \
478478
aclk/aclk_common.c \
479479
aclk/aclk_common.h \
480+
$(NULL)
481+
482+
if ENABLE_ACLK
483+
ACLK_FILES += \
480484
aclk/agent_cloud_link.c \
481485
aclk/agent_cloud_link.h \
482486
aclk/mqtt.c \
@@ -486,6 +490,9 @@ ACLK_PLUGIN_FILES = \
486490
aclk/aclk_lws_https_client.c \
487491
aclk/aclk_lws_https_client.h \
488492
$(NULL)
493+
endif
494+
495+
489496

490497
EXPORTING_ENGINE_FILES = \
491498
exporting/exporting_engine.c \
@@ -575,15 +582,10 @@ NETDATA_FILES = \
575582
$(STREAMING_PLUGIN_FILES) \
576583
$(STATSD_PLUGIN_FILES) \
577584
$(WEB_PLUGIN_FILES) \
578-
$(CLAIM_PLUGIN_FILES) \
585+
$(CLAIM_FILES) \
586+
$(ACLK_FILES) \
579587
$(NULL)
580588

581-
if ENABLE_ACLK
582-
NETDATA_FILES += \
583-
$(ACLK_PLUGIN_FILES) \
584-
$(NULL)
585-
endif
586-
587589
if FREEBSD
588590
NETDATA_FILES += \
589591
$(FREEBSD_PLUGIN_FILES) \

aclk/agent_cloud_link.c

+7
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,10 @@ void *aclk_main(void *ptr)
13091309
struct netdata_static_thread *query_thread;
13101310

13111311
netdata_thread_cleanup_push(aclk_main_cleanup, ptr);
1312+
if (!netdata_cloud_setting) {
1313+
info("Killing ACLK thread -> cloud functionality has been disabled");
1314+
return NULL;
1315+
}
13121316

13131317
info("Waiting for netdata to be ready");
13141318
while (!netdata_ready) {
@@ -1755,6 +1759,9 @@ int aclk_update_chart(RRDHOST *host, char *chart_name, ACLK_CMD aclk_cmd)
17551759
UNUSED(chart_name);
17561760
return 0;
17571761
#else
1762+
if (!netdata_cloud_setting)
1763+
return 0;
1764+
17581765
if (host != localhost)
17591766
return 0;
17601767

claim/claim.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ extern struct registry registry;
4141
/* rrd_init() must have been called before this function */
4242
void claim_agent(char *claiming_arguments)
4343
{
44-
#ifndef ENABLE_CLOUD
45-
info("The claiming feature has been disabled");
46-
return;
47-
#endif
44+
if (!netdata_cloud_setting) {
45+
error("Refusing to claim agent -> cloud functionality has been disabled");
46+
return;
47+
}
4848

49+
#ifndef DISABLE_CLOUD
4950
int exit_code;
5051
pid_t command_pid;
5152
char command_buffer[CLAIMING_COMMAND_LENGTH + 1];
@@ -106,6 +107,7 @@ void claim_agent(char *claiming_arguments)
106107
}
107108
error("Agent failed to be claimed with the following error message:");
108109
error("\"%s\"", claiming_errors[exit_code]);
110+
#endif
109111
}
110112

111113
void load_claiming_state(void)

configure.ac

+15-9
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,18 @@ AC_ARG_ENABLE(
169169
[cloud],
170170
[AS_HELP_STRING([--disable-cloud],
171171
[Disables all cloud functionality])],
172-
[],
173-
[enable_cloud="no"]
172+
[ enable_cloud="$enableval" ],
173+
[ enable_cloud="yes" ]
174174
)
175175

176176
AC_MSG_CHECKING([if cloud functionality should be enabled])
177-
if test "${enable_cloud}" != "no"; then
178-
AC_DEFINE([ENABLE_CLOUD], [1], [netdata cloud functionality])
179-
aclk_required="detect"
180-
else
177+
if test "${enable_cloud}" = "no"; then
178+
AC_DEFINE([DISABLE_CLOUD], [1], [disable netdata cloud functionality])
181179
aclk_required="no"
180+
else
181+
aclk_required="detect"
182182
fi
183183
AC_MSG_RESULT([${enable_cloud}])
184-
AM_CONDITIONAL([ENABLE_CLOUD], [test "${enable_cloud}" = "yes"])
185184

186185
# -----------------------------------------------------------------------------
187186
# netdata required checks
@@ -557,9 +556,16 @@ AM_CONDITIONAL([ENABLE_CAPABILITY], [test "${with_libcap}" = "yes"])
557556
# ACLK
558557

559558
if test "$enable_cloud" = "yes"; then
560-
AC_MSG_CHECKING([if libmosquitto static lib is present])
559+
AC_MSG_CHECKING([if libmosquitto static lib is present (and builds)])
561560
if test -f "externaldeps/mosquitto/libmosquitto.a"; then
562-
HAVE_libmosquitto_a="yes"
561+
LIBS_SAVES="$LIBS"
562+
LIBS="externaldeps/mosquitto/libmosquitto.a"
563+
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main (int argc, char **argv)) {
564+
int m,mm,r;
565+
mosquitto_lib_version(&m, &mm, &r);
566+
}]]),
567+
[HAVE_libmosquitto_a="yes"],
568+
[HAVE_libmosquitto_a="no"]])
563569
else
564570
HAVE_libmosquitto_a="no"
565571
AC_DEFINE([ACLK_NO_LIBMOSQ], [1], [Libmosquitto.a was not found during build.])

daemon/commands.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,18 @@ static cmd_status_t cmd_reload_claiming_state_execute(char *args, char **message
186186
(void)args;
187187
(void)message;
188188

189-
#ifndef ENABLE_CLOUD
189+
#ifdef DISABLE_CLOUD
190190
info("The claiming feature has been disabled");
191191
return CMD_STATUS_FAILURE;
192192
#endif
193193
#ifndef ENABLE_ACLK
194194
info("Cloud functionality is not enabled because of missing dependencies at build-time.");
195195
return CMD_STATUS_FAILURE;
196196
#endif
197+
if (!netdata_cloud_setting) {
198+
error("Cannot reload claiming status -> cloud functionality has been disabled");
199+
return CMD_STATUS_FAILURE;
200+
}
197201

198202
error_log_limit_unlimited();
199203
info("COMMAND: Reloading Agent Claiming configuration.");

daemon/common.c

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ char *netdata_configured_home_dir = CACHE_DIR;
1414
char *netdata_configured_host_prefix = NULL;
1515
char *netdata_configured_timezone = NULL;
1616
int netdata_ready;
17+
int netdata_cloud_setting;
18+

daemon/common.h

+1
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,6 @@ extern int netdata_zero_metrics_enabled;
8888
extern int netdata_anonymous_statistics_enabled;
8989

9090
extern int netdata_ready;
91+
extern int netdata_cloud_setting;
9192

9293
#endif /* NETDATA_COMMON_H */

daemon/main.c

+15
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,21 @@ static void get_netdata_configured_variables() {
575575
get_system_HZ();
576576
get_system_cpus();
577577
get_system_pid_max();
578+
579+
// --------------------------------------------------------------------
580+
// Check if the cloud is enabled
581+
#ifdef DISABLE_CLOUD
582+
netdata_cloud_setting = 0;
583+
#else
584+
char *cloud = config_get(CONFIG_SECTION_GLOBAL, "netdata cloud", "coming soon");
585+
if (!strcmp(cloud, "coming soon")) {
586+
netdata_cloud_setting = 0; // Note: this flips to 1 after the release
587+
} else if (!strcmp(cloud, "enable")) {
588+
netdata_cloud_setting = 1;
589+
} else if (!strcmp(cloud, "disable")) {
590+
netdata_cloud_setting = 0;
591+
}
592+
#endif
578593
}
579594

580595
static void get_system_timezone(void) {

database/rrddim.c

+14-7
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ void rrdcalc_link_to_rrddim(RRDDIM *rd, RRDSET *st, RRDHOST *host) {
184184
}
185185
}
186186
#ifdef ENABLE_ACLK
187-
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
187+
if (netdata_cloud_setting)
188+
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
188189
#endif
189190
}
190191

@@ -428,7 +429,8 @@ RRDDIM *rrddim_add_custom(RRDSET *st, const char *id, const char *name, collecte
428429
}
429430
rrdset_unlock(st);
430431
#ifdef ENABLE_ACLK
431-
aclk_update_chart(host, st->id, ACLK_CMD_CHART);
432+
if (netdata_cloud_setting)
433+
aclk_update_chart(host, st->id, ACLK_CMD_CHART);
432434
#endif
433435
return(rd);
434436
}
@@ -484,7 +486,8 @@ void rrddim_free(RRDSET *st, RRDDIM *rd)
484486
break;
485487
}
486488
#ifdef ENABLE_ACLK
487-
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
489+
if (netdata_cloud_setting)
490+
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
488491
#endif
489492
}
490493

@@ -505,7 +508,8 @@ int rrddim_hide(RRDSET *st, const char *id) {
505508

506509
rrddim_flag_set(rd, RRDDIM_FLAG_HIDDEN);
507510
#ifdef ENABLE_ACLK
508-
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
511+
if (netdata_cloud_setting)
512+
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
509513
#endif
510514
return 0;
511515
}
@@ -522,7 +526,8 @@ int rrddim_unhide(RRDSET *st, const char *id) {
522526

523527
rrddim_flag_clear(rd, RRDDIM_FLAG_HIDDEN);
524528
#ifdef ENABLE_ACLK
525-
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
529+
if (netdata_cloud_setting)
530+
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
526531
#endif
527532
return 0;
528533
}
@@ -533,7 +538,8 @@ inline void rrddim_is_obsolete(RRDSET *st, RRDDIM *rd) {
533538
rrddim_flag_set(rd, RRDDIM_FLAG_OBSOLETE);
534539
rrdset_flag_set(st, RRDSET_FLAG_OBSOLETE_DIMENSIONS);
535540
#ifdef ENABLE_ACLK
536-
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
541+
if (netdata_cloud_setting)
542+
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
537543
#endif
538544
}
539545

@@ -542,7 +548,8 @@ inline void rrddim_isnot_obsolete(RRDSET *st __maybe_unused, RRDDIM *rd) {
542548

543549
rrddim_flag_clear(rd, RRDDIM_FLAG_OBSOLETE);
544550
#ifdef ENABLE_ACLK
545-
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
551+
if (netdata_cloud_setting)
552+
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHART);
546553
#endif
547554
}
548555

database/rrdset.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,10 @@ void rrdset_delete(RRDSET *st) {
425425

426426
recursively_delete_dir(st->cache_dir, "left-over chart");
427427
#ifdef ENABLE_ACLK
428-
aclk_del_collector(st->rrdhost->hostname, st->plugin_name, st->module_name);
429-
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHARTDEL);
428+
if (netdata_cloud_setting) {
429+
aclk_del_collector(st->rrdhost->hostname, st->plugin_name, st->module_name);
430+
aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHARTDEL);
431+
}
430432
#endif
431433
}
432434

@@ -768,8 +770,10 @@ RRDSET *rrdset_create_custom(
768770

769771
rrdhost_unlock(host);
770772
#ifdef ENABLE_ACLK
771-
aclk_add_collector(host->hostname, plugin, module);
772-
aclk_update_chart(host, st->id, ACLK_CMD_CHART);
773+
if (netdata_cloud_setting) {
774+
aclk_add_collector(host->hostname, plugin, module);
775+
aclk_update_chart(host, st->id, ACLK_CMD_CHART);
776+
}
773777
#endif
774778
return(st);
775779
}

health/health.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ void health_reload_host(RRDHOST *host) {
180180
*/
181181
void health_reload(void) {
182182
#ifdef ENABLE_ACLK
183-
aclk_single_update_disable();
183+
if (netdata_cloud_setting)
184+
aclk_single_update_disable();
184185
#endif
185186
rrd_rdlock();
186187

@@ -190,8 +191,10 @@ void health_reload(void) {
190191

191192
rrd_unlock();
192193
#ifdef ENABLE_ACLK
193-
aclk_single_update_enable();
194-
aclk_alarm_reload();
194+
if (netdata_cloud_setting) {
195+
aclk_single_update_enable();
196+
aclk_alarm_reload();
197+
}
195198
#endif
196199
}
197200

health/health_log.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ inline void health_alarm_log_save(RRDHOST *host, ALARM_ENTRY *ae) {
153153
}
154154
}
155155
#ifdef ENABLE_ACLK
156-
aclk_update_alarm(host, ae);
156+
if (netdata_cloud_setting)
157+
aclk_update_alarm(host, ae);
157158
#endif
158159
}
159160

netdata-installer.sh

-4
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,6 @@ while [ -n "${1}" ]; do
283283
NETDATA_DISABLE_CLOUD=1
284284
NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-cloud/} --disable-cloud"
285285
;;
286-
"--cloud-testing") # Temporary, until we flip the feature flag. Internal use only
287-
unset NETDATA_DISABLE_CLOUD
288-
NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-cloud/} --enable-cloud"
289-
;;
290286
"--install")
291287
NETDATA_PREFIX="${2}/netdata"
292288
shift 1

web/api/web_api_v1.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -862,10 +862,13 @@ inline int web_client_api_request_v1_info_fill_buffer(RRDHOST *host, BUFFER *wb)
862862
chartcollectors2json(host, wb);
863863
buffer_strcat(wb, "\n\t],\n");
864864

865-
#ifdef ENABLE_CLOUD
866-
buffer_strcat(wb, "\t\"cloud-enabled\": true,\n");
867-
#else
865+
#ifdef DISABLE_CLOUD
868866
buffer_strcat(wb, "\t\"cloud-enabled\": false,\n");
867+
#else
868+
if (netdata_cloud_setting)
869+
buffer_strcat(wb, "\t\"cloud-enabled\": true,\n");
870+
else
871+
buffer_strcat(wb, "\t\"cloud-enabled\": false,\n");
869872
#endif
870873
#ifdef ENABLE_ACLK
871874
buffer_strcat(wb, "\t\"cloud-available\": true,\n");

0 commit comments

Comments
 (0)