Skip to content

Commit 417d129

Browse files
author
Pat
authored
custom_calyptia: switch to YAML for Fleet config (#9698)
* custom_calyptia: switch to YAML for Fleet config Signed-off-by: Patrick Stephens <[email protected]> * in_calyptia_fleet: code review comments Signed-off-by: Patrick Stephens <[email protected]> --------- Signed-off-by: Patrick Stephens <[email protected]>
1 parent 14ca011 commit 417d129

File tree

12 files changed

+411
-98
lines changed

12 files changed

+411
-98
lines changed

.github/workflows/unit-tests.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878
CC: ${{ matrix.compiler }}
7979
CXX: ${{ matrix.compiler }}
8080
FLB_OPT: ${{ matrix.flb_option }}
81+
CALYPTIA_FLEET_TOKEN: ${{ secrets.CALYPTIA_FLEET_TOKEN }}
8182

8283
run-macos-unit-tests:
8384
# We chain this after Linux one as there are costs and restrictions associated
@@ -111,6 +112,7 @@ jobs:
111112
CC: gcc
112113
CXX: g++
113114
FLB_OPT: ${{ matrix.flb_option }}
115+
CALYPTIA_FLEET_TOKEN: ${{ secrets.CALYPTIA_FLEET_TOKEN }}
114116

115117
run-aarch64-unit-tests:
116118
# Ensure for OSS Fluent Bit repo we enable usage of Actuated runners for ARM builds, for forks it should keep existing ubuntu-latest usage.
@@ -167,6 +169,7 @@ jobs:
167169
env:
168170
CC: ${{ matrix.config.compiler }}
169171
CXX: ${{ matrix.config.compiler }}
172+
CALYPTIA_FLEET_TOKEN: ${{ secrets.CALYPTIA_FLEET_TOKEN }}
170173

171174
run-qemu-ubuntu-unit-tests:
172175
# We chain this after Linux one as there are CPU time costs for QEMU emulation
@@ -217,7 +220,6 @@ jobs:
217220
make -j $nparallel
218221
ctest -j $nparallel --build-run-dir . --output-on-failure
219222
220-
221223
# Required check looks at this so do not remove
222224
run-all-unit-tests:
223225
if: always()

include/fluent-bit/calyptia/calyptia_constants.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@
3636
#define CALYPTIA_ENDPOINT_TRACE "/v1/traces/%s"
3737

3838
#define CALYPTIA_ENDPOINT_FLEETS "/v1/fleets"
39-
#define CALYPTIA_ENDPOINT_FLEET_CONFIG_INI "/v1/fleets/%s/config?format=ini"
39+
#define CALYPTIA_ENDPOINT_FLEET_CONFIG_INI "/v1/fleets/%s/config?format=ini&config_format=ini"
40+
#define CALYPTIA_ENDPOINT_FLEET_CONFIG_YAML "/v1/fleets/%s/config?format=yaml&config_format=yaml"
4041
#define CALYPTIA_ENDPOINT_FLEET_FILES "/v1/fleets/%s/files"
42+
#define CALYPTIA_ENDPOINT_FLEET_BY_NAME "/v1/search?project_id=%s&resource=fleet&term=%s&exact=true"
4143

4244
/* Storage */
4345
#define CALYPTIA_SESSION_FILE "session.CALYPTIA"

plugins/custom_calyptia/calyptia.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ int set_fleet_input_properties(struct calyptia *ctx, struct flb_input_instance *
232232
flb_input_set_property(fleet, "host", ctx->cloud_host);
233233
flb_input_set_property(fleet, "port", ctx->cloud_port);
234234
flb_input_set_property(fleet, "config_dir", ctx->fleet_config_dir);
235+
flb_input_set_property(fleet, "fleet_config_legacy_format", ctx->fleet_config_legacy_format == 1 ? "on" : "off");
235236

236237
/* Set TLS properties */
237238
flb_input_set_property(fleet, "tls", ctx->cloud_tls == 1 ? "on" : "off");
@@ -617,7 +618,7 @@ static int cb_calyptia_init(struct flb_custom_instance *ins,
617618
flb_free(ctx);
618619
return -1;
619620
}
620-
ctx->machine_id_auto_configured = 1;
621+
ctx->machine_id_auto_configured = FLB_TRUE;
621622
}
622623

623624
/* input collector */
@@ -774,6 +775,11 @@ static struct flb_config_map config_map[] = {
774775
0, FLB_TRUE, offsetof(struct calyptia, register_retry_on_flush),
775776
"Retry agent registration on flush if failed on init."
776777
},
778+
{
779+
FLB_CONFIG_MAP_BOOL, "fleet_config_legacy_format", "true",
780+
0, FLB_TRUE, offsetof(struct calyptia, fleet_config_legacy_format),
781+
"If set, use legacy (TOML) format for configuration files."
782+
},
777783
/* EOF */
778784
{0}
779785
};

plugins/custom_calyptia/calyptia.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#ifndef FLB_CALYPTIA_H
2121
#define FLB_CALYPTIA_H
2222

23-
#include <stdbool.h>
24-
2523
struct calyptia {
2624
/* config map options */
2725
flb_sds_t api_key;
@@ -55,7 +53,8 @@ struct calyptia {
5553
flb_sds_t fleet_max_http_buffer_size;
5654
flb_sds_t fleet_interval_sec;
5755
flb_sds_t fleet_interval_nsec;
58-
bool register_retry_on_flush; /* retry registration on flush if failed */
56+
int register_retry_on_flush; /* retry registration on flush if failed */
57+
int fleet_config_legacy_format; /* Fleet config format to use: INI (true) or YAML (false) */
5958
};
6059

6160
int set_fleet_input_properties(struct calyptia *ctx, struct flb_input_instance *fleet);

0 commit comments

Comments
 (0)