Skip to content

Commit

Permalink
custom_calyptia: switch to YAML for Fleet config
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Stephens <[email protected]>
  • Loading branch information
patrick-stephens committed Jan 6, 2025
1 parent 68f1887 commit 3ddc993
Show file tree
Hide file tree
Showing 16 changed files with 424 additions and 108 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
CC: ${{ matrix.compiler }}
CXX: ${{ matrix.compiler }}
FLB_OPT: ${{ matrix.flb_option }}
CALYPTIA_FLEET_TOKEN: ${{ secrets.CALYPTIA_FLEET_TOKEN }}

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

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

run-qemu-ubuntu-unit-tests:
# We chain this after Linux one as there are CPU time costs for QEMU emulation
Expand Down Expand Up @@ -217,7 +220,6 @@ jobs:
make -j $nparallel
ctest -j $nparallel --build-run-dir . --output-on-failure
# Required check looks at this so do not remove
run-all-unit-tests:
if: always()
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ init/fluent-bit.service
lib/chunkio/include/chunkio/cio_version.h
lib/monkey/monkey.service
lib/monkey/include/monkey/mk_core/mk_core_info.h
lib/cprofiles/include/cprofiles/cprof_info.h

packaging/.env
packaging/packages
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)

# Fluent Bit Version
set(FLB_VERSION_MAJOR 4)
set(FLB_VERSION_MINOR 0)
set(FLB_VERSION_PATCH 0)
set(FLB_VERSION_MAJOR 3)
set(FLB_VERSION_MINOR 2)
set(FLB_VERSION_PATCH 5)
set(FLB_VERSION_STR "${FLB_VERSION_MAJOR}.${FLB_VERSION_MINOR}.${FLB_VERSION_PATCH}")

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# docker buildx build --platform "linux/amd64,linux/arm64,linux/arm/v7,linux/s390x" -f ./dockerfiles/Dockerfile.multiarch --build-arg FLB_TARBALL=https://github.com/fluent/fluent-bit/archive/v1.8.11.tar.gz ./dockerfiles/

# Set this to the current release version: it gets done so as part of the release.
ARG RELEASE_VERSION=3.2.4
ARG RELEASE_VERSION=3.2.5

# For multi-arch builds - assumption is running on an AMD64 host
FROM multiarch/qemu-user-static:x86_64-arm AS qemu-arm32
Expand Down
4 changes: 3 additions & 1 deletion include/fluent-bit/calyptia/calyptia_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
#define CALYPTIA_ENDPOINT_TRACE "/v1/traces/%s"

#define CALYPTIA_ENDPOINT_FLEETS "/v1/fleets"
#define CALYPTIA_ENDPOINT_FLEET_CONFIG_INI "/v1/fleets/%s/config?format=ini"
#define CALYPTIA_ENDPOINT_FLEET_CONFIG_INI "/v1/fleets/%s/config?format=ini&config_format=ini"
#define CALYPTIA_ENDPOINT_FLEET_CONFIG_YAML "/v1/fleets/%s/config?format=yaml&config_format=yaml"
#define CALYPTIA_ENDPOINT_FLEET_FILES "/v1/fleets/%s/files"
#define CALYPTIA_ENDPOINT_FLEET_BY_NAME "/v1/search?project_id=%s&resource=fleet&term=%s&exact=true"

/* Storage */
#define CALYPTIA_SESSION_FILE "session.CALYPTIA"
Expand Down
20 changes: 14 additions & 6 deletions lib/cprofiles/include/cprofiles/cprof_encode_msgpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@
#ifndef CPROF_ENCODE_MSGPACK_H
#define CPROF_ENCODE_MSGPACK_H

#include <cprofiles/cprofiles.h>
#include <mpack/mpack.h>
#include <cfl/cfl_sds.h>
#define CPROF_SOURCE_DIR "/Users/pat/github/fluent/fluent-bit"

#define CPROF_ENCODE_MSGPACK_SUCCESS 0
#define CPROF_ENCODE_MSGPACK_ALLOCATION_ERROR 1
#define CPROF_ENCODE_MSGPACK_INVALID_ARGUMENT_ERROR 2
/* General flags set by /CMakeLists.txt */
#ifndef CPROF_HAVE_TIMESPEC_GET
#define CPROF_HAVE_TIMESPEC_GET
#endif
#ifndef CPROF_HAVE_CLOCK_GET_TIME
#define CPROF_HAVE_CLOCK_GET_TIME
#endif
#ifndef CPROF_HAVE_CFL
#define CPROF_HAVE_CFL
#endif
#ifndef CPROF_HAVE_FLUENT_OTEL_PROTO
#define CPROF_HAVE_FLUENT_OTEL_PROTO
#endif

struct cprof_msgpack_encoding_context {
mpack_writer_t writer;
Expand Down
8 changes: 7 additions & 1 deletion plugins/custom_calyptia/calyptia.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ int set_fleet_input_properties(struct calyptia *ctx, struct flb_input_instance *
flb_input_set_property(fleet, "host", ctx->cloud_host);
flb_input_set_property(fleet, "port", ctx->cloud_port);
flb_input_set_property(fleet, "config_dir", ctx->fleet_config_dir);
flb_input_set_property(fleet, "fleet_config_legacy_format", ctx->fleet_config_legacy_format == 1 ? "on" : "off");

/* Set TLS properties */
flb_input_set_property(fleet, "tls", ctx->cloud_tls == 1 ? "on" : "off");
Expand Down Expand Up @@ -617,7 +618,7 @@ static int cb_calyptia_init(struct flb_custom_instance *ins,
flb_free(ctx);
return -1;
}
ctx->machine_id_auto_configured = 1;
ctx->machine_id_auto_configured = FLB_TRUE;
}

/* input collector */
Expand Down Expand Up @@ -774,6 +775,11 @@ static struct flb_config_map config_map[] = {
0, FLB_TRUE, offsetof(struct calyptia, register_retry_on_flush),
"Retry agent registration on flush if failed on init."
},
{
FLB_CONFIG_MAP_BOOL, "fleet_config_legacy_format", "true",
0, FLB_TRUE, offsetof(struct calyptia, fleet_config_legacy_format),
"If set, use legacy (TOML) format for configuration files."
},
/* EOF */
{0}
};
Expand Down
5 changes: 2 additions & 3 deletions plugins/custom_calyptia/calyptia.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#ifndef FLB_CALYPTIA_H
#define FLB_CALYPTIA_H

#include <stdbool.h>

struct calyptia {
/* config map options */
flb_sds_t api_key;
Expand Down Expand Up @@ -55,7 +53,8 @@ struct calyptia {
flb_sds_t fleet_max_http_buffer_size;
flb_sds_t fleet_interval_sec;
flb_sds_t fleet_interval_nsec;
bool register_retry_on_flush; /* retry registration on flush if failed */
int register_retry_on_flush; /* retry registration on flush if failed */
int fleet_config_legacy_format; /* Fleet config format to use: INI (true) or YAML (false) */
};

int set_fleet_input_properties(struct calyptia *ctx, struct flb_input_instance *fleet);
Expand Down
Loading

0 comments on commit 3ddc993

Please sign in to comment.