@cryptotaxi247 / netdata-1 / commits / 250d1bdf9

Do not register removed node on agent restart (#19609)

* If unregistered during startup and it was removed by cli or cleanup, do not register again * Code cleanup

Stelios Fragkakis committed Feb 10, 2025 at 20:26 UTC 250d1bdf9b0be79aee345dca8cf09803093ce1f0
1 file changed +4 -2
src/database/sqlite/sqlite_aclk.c
+4 -2
@@ -131,7 +131,7 @@ static int create_host_callback(void *data, int argc, char **argv, char **column
131 char guid[UUID_STR_LEN];
132 uuid_unparse_lower(*(nd_uuid_t *)argv[IDX_HOST_ID], guid);
133
134 - if (is_ephemeral && rrdhost_free_ephemeral_time_s && age > rrdhost_free_ephemeral_time_s) {
134 + if (is_ephemeral && ((!is_registered && last_connected == 1) || (rrdhost_free_ephemeral_time_s && age > rrdhost_free_ephemeral_time_s))) {
135 netdata_log_info(
136 "%s ephemeral hostname \"%s\" with GUID \"%s\", age = %ld seconds (limit %ld seconds)",
137 is_registered ? "Loading registered" : "Skipping unregistered",
@@ -141,7 +141,7 @@ static int create_host_callback(void *data, int argc, char **argv, char **column
141 rrdhost_free_ephemeral_time_s);
142
143 if (!is_registered)
144 - return 0;
144 + goto done;
145 }
146
147 struct rrdhost_system_info *system_info = rrdhost_system_info_create();
@@ -196,6 +196,8 @@ static int create_host_callback(void *data, int argc, char **argv, char **column
196 internal_error(true, "Adding archived host \"%s\" with GUID \"%s\" node id = \"%s\" ephemeral=%d",
197 rrdhost_hostname(host), host->machine_guid, node_str, is_ephemeral);
198 #endif
199 +
200 +done:
201 return 0;
202 }
203