Skip to content

Commit 4c4f8c0

Browse files
nuclearpidgeonpwhelan
authored andcommitted
in_calyptia_fleet: log info about config pulled from API
Also set local timestamp to -1 on startup as otherwise it could end up being read as an uninitialised value Signed-off-by: Stewart Webb <[email protected]>
1 parent 9885705 commit 4c4f8c0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

plugins/in_calyptia_fleet/in_calyptia_fleet.c

+16
Original file line numberDiff line numberDiff line change
@@ -991,12 +991,14 @@ static int get_calyptia_file(struct flb_in_calyptia_fleet_config *ctx,
991991
}
992992

993993
if (dst == NULL) {
994+
// Assuming this is the base Fleet config file
994995
flb_strptime(fbit_last_modified, "%a, %d %B %Y %H:%M:%S GMT", &tm_last_modified);
995996
last_modified = mktime(&tm_last_modified.tm);
996997

997998
fname = time_fleet_config_filename(ctx, last_modified);
998999
}
9991000
else {
1001+
// Fleet File file
10001002
fname = flb_sds_create_len(dst, strlen(dst));
10011003
}
10021004

@@ -1818,6 +1820,19 @@ int get_calyptia_fleet_config(struct flb_in_calyptia_fleet_config *ctx)
18181820

18191821
/* new file created! */
18201822
if (ret == 1) {
1823+
if (ctx->config_timestamp > 0) {
1824+
if (ctx->config_timestamp < time_last_modified) {
1825+
flb_plg_info(ctx->ins, "fleet API returned config with newer timestamp than current config (%ld -> %ld)", ctx->config_timestamp, time_last_modified);
1826+
}
1827+
else if (ctx->config_timestamp == time_last_modified) {
1828+
flb_plg_debug(ctx->ins, "fleet API returned config with same timestamp as current config (%ld)", time_last_modified);
1829+
}
1830+
else {
1831+
flb_plg_warn(ctx->ins, "fleet API returned config with earlier timestamp than current config (%ld -> %ld)", ctx->config_timestamp, time_last_modified);
1832+
}
1833+
} else {
1834+
flb_plg_info(ctx->ins, "fleet API returned new config (none -> %ld)", time_last_modified);
1835+
}
18211836
get_calyptia_files(ctx, time_last_modified);
18221837

18231838
cfgname = time_fleet_config_filename(ctx, time_last_modified);
@@ -2187,6 +2202,7 @@ static int in_calyptia_fleet_init(struct flb_input_instance *in,
21872202
ctx->ins = in;
21882203
ctx->collect_fd = -1;
21892204
ctx->fleet_id_found = FLB_FALSE;
2205+
ctx->config_timestamp = -1;
21902206

21912207
/* Load the config map */
21922208
ret = flb_input_config_map_set(in, (void *) ctx);

0 commit comments

Comments
 (0)