make remove-stale-node remove also ephemeral nodes (#19602)
Costa Tsaousis committed
Feb 10, 2025 at 09:56 UTC
1f7116cd0226cdf2e97f48533f5b94fe6f21728b
1 file changed
+23
-18
src/daemon/commands.c
+23
-18
@@ -362,31 +362,36 @@ static int remove_ephemeral_host(BUFFER *wb, RRDHOST *host, bool report_error, b
362
return 0;
363
}
364
365
+ bool marked = false;
366
if (!rrdhost_option_check(host, RRDHOST_OPTION_EPHEMERAL_HOST)) {
367
rrdhost_option_set(host, RRDHOST_OPTION_EPHEMERAL_HOST);
367
- sql_set_host_label(&host->host_id.uuid, "_is_ephemeral", "true");
368
+ marked = true;
369
+ }
370
369
- if(unregister) {
370
- aclk_host_state_update(host, 0, 0);
371
- unregister_node(host->machine_guid);
372
- host->node_id = UUID_ZERO;
373
- buffer_sprintf(wb, "Node '%s' (machine guid: %s) has been unregistered",
374
- rrdhost_hostname(host), host->machine_guid);
375
- rrd_wrlock();
376
- rrdhost_free___while_having_rrd_wrlock(host);
377
- rrd_wrunlock();
378
- }
379
- else {
380
- pulse_host_status(host, 0, 0);
381
- buffer_sprintf(wb, "Node '%s' (machine guid: %s) has been marked ephemeral",
382
- rrdhost_hostname(host), host->machine_guid);
383
- }
371
+ sql_set_host_label(&host->host_id.uuid, "_is_ephemeral", "true");
372
+ pulse_host_status(host, 0, 0);
373
374
+ if(unregister) {
375
+ aclk_host_state_update(host, 0, 0);
376
+ unregister_node(host->machine_guid);
377
+ host->node_id = UUID_ZERO;
378
+ buffer_sprintf(wb, "Node '%s' (machine guid: %s) has been unregistered",
379
+ rrdhost_hostname(host), host->machine_guid);
380
+ rrd_wrlock();
381
+ rrdhost_free___while_having_rrd_wrlock(host);
382
+ rrd_wrunlock();
383
return 1;
384
}
387
- if (report_error)
388
- buffer_sprintf(wb, "Node '%s' (machine guid: %s) is already ephemeral - not changing it",
385
+ else if(marked) {
386
+ buffer_sprintf(wb, "Node '%s' (machine guid: %s) has been marked ephemeral",
387
rrdhost_hostname(host), host->machine_guid);
388
+ return 1;
389
+ }
390
+ else if (report_error) {
391
+ buffer_sprintf(wb, "Node '%s' (machine guid: %s) is already ephemeral - not changing it",
392
+ rrdhost_hostname(host), host->machine_guid);
393
+ }
394
+
395
return 0;
396
}
397