Skip to content

Commit 7e4c128

Browse files
committed
in_kubernetes_events: add missing config parameter descriptions
Add db.locking, db.journal_mode, and db.sync configuration parameters with proper validation. Remove dns_retries and dns_wait_time options as they were never implemented in the plugin. - Add config_map entries for db.locking, db.journal_mode - Add db.sync property reading code and journal_mode validation - Remove dns_retries and dns_wait_time (unused, unlike filter_kubernetes) Fix for #11243. Signed-off-by: Eric D. Schabell <[email protected]>
1 parent 10ebd3a commit 7e4c128

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

plugins/in_kubernetes_events/kubernetes_events.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,18 @@ static struct flb_config_map config_map[] = {
10851085
0, FLB_FALSE, 0,
10861086
"set a database sync method. values: extra, full, normal and off."
10871087
},
1088+
{
1089+
FLB_CONFIG_MAP_BOOL, "db.locking", "false",
1090+
0, FLB_TRUE, offsetof(struct k8s_events, db_locking),
1091+
"set exclusive locking mode, increase performance but don't allow "
1092+
"external connections to the database file."
1093+
},
1094+
{
1095+
FLB_CONFIG_MAP_STR, "db.journal_mode", "WAL",
1096+
0, FLB_TRUE, offsetof(struct k8s_events, db_journal_mode),
1097+
"set the journal mode for the database. values: DELETE, TRUNCATE, "
1098+
"PERSIST, MEMORY, WAL, OFF."
1099+
},
10881100
#endif
10891101

10901102
/* EOF */

plugins/in_kubernetes_events/kubernetes_events.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ struct k8s_events {
6767
char *auth;
6868
size_t auth_len;
6969

70-
int dns_retries;
71-
int dns_wait_time;
72-
7370
struct flb_tls *tls;
7471

7572
struct flb_log_event_encoder *encoder;

plugins/in_kubernetes_events/kubernetes_events_conf.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,45 @@ struct k8s_events *k8s_events_conf_create(struct flb_input_instance *ins)
232232
}
233233

234234
#ifdef FLB_HAVE_SQLDB
235+
/* Database sync mode (needs to be set before opening the database) */
236+
ctx->db_sync = 1; /* default: sqlite sync 'normal' */
237+
tmp = flb_input_get_property("db.sync", ins);
238+
if (tmp) {
239+
if (strcasecmp(tmp, "extra") == 0) {
240+
ctx->db_sync = 3;
241+
}
242+
else if (strcasecmp(tmp, "full") == 0) {
243+
ctx->db_sync = 2;
244+
}
245+
else if (strcasecmp(tmp, "normal") == 0) {
246+
ctx->db_sync = 1;
247+
}
248+
else if (strcasecmp(tmp, "off") == 0) {
249+
ctx->db_sync = 0;
250+
}
251+
else {
252+
flb_plg_error(ctx->ins, "invalid database 'db.sync' value: %s", tmp);
253+
k8s_events_conf_destroy(ctx);
254+
return NULL;
255+
}
256+
}
257+
258+
/* Journal mode validation */
259+
tmp = flb_input_get_property("db.journal_mode", ins);
260+
if (tmp) {
261+
if (strcasecmp(tmp, "DELETE") != 0 &&
262+
strcasecmp(tmp, "TRUNCATE") != 0 &&
263+
strcasecmp(tmp, "PERSIST") != 0 &&
264+
strcasecmp(tmp, "MEMORY") != 0 &&
265+
strcasecmp(tmp, "WAL") != 0 &&
266+
strcasecmp(tmp, "OFF") != 0) {
267+
268+
flb_plg_error(ctx->ins, "invalid db.journal_mode=%s", tmp);
269+
k8s_events_conf_destroy(ctx);
270+
return NULL;
271+
}
272+
}
273+
235274
/* Initialize database */
236275
tmp = flb_input_get_property("db", ins);
237276
if (tmp) {

0 commit comments

Comments
 (0)