Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input: add support for upstream configuration for input client plugins. #8142

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/fluent-bit/flb_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <fluent-bit/flb_coro.h>
#include <fluent-bit/flb_config.h>
#include <fluent-bit/flb_network.h>
#include <fluent-bit/flb_downstream.h>
#include <fluent-bit/flb_upstream.h>
#include <fluent-bit/flb_mem.h>
#include <fluent-bit/flb_str.h>
#include <fluent-bit/flb_bits.h>
Expand Down
57 changes: 46 additions & 11 deletions src/flb_help.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ int flb_help_input(struct flb_input_instance *ins, void **out_buf, size_t *out_s
msgpack_sbuffer mp_sbuf;
msgpack_packer mp_pck;
int options_size = 0;
struct mk_list *tls_config;
struct flb_config_map m_input_net_listen = {
.type = FLB_CONFIG_MAP_STR,
.name = "host",
Expand Down Expand Up @@ -245,25 +244,61 @@ int flb_help_input(struct flb_input_instance *ins, void **out_buf, size_t *out_s
if ((ins->flags & (FLB_INPUT_NET | FLB_INPUT_NET_SERVER)) != 0) {
options_size += 2;
}
if (ins->flags & FLB_IO_OPT_TLS) {
tls_config = flb_tls_get_config_map(ins->config);
options_size += mk_list_size(tls_config);
}

msgpack_pack_array(&mp_pck, options_size);

if ((ins->flags & (FLB_INPUT_NET | FLB_INPUT_NET_SERVER)) != 0) {
pack_config_map_entry(&mp_pck, &m_input_net_listen);
pack_config_map_entry(&mp_pck, &m_input_net_port);
}
if (ins->flags & FLB_IO_OPT_TLS) {
mk_list_foreach(head, tls_config) {
m = mk_list_entry(head, struct flb_config_map, _head);
pack_config_map_entry(&mp_pck, m);
}
flb_config_map_destroy(tls_config);

mk_list_foreach(head, config_map) {
m = mk_list_entry(head, struct flb_config_map, _head);
pack_config_map_entry(&mp_pck, m);
}
flb_config_map_destroy(config_map);
}

if (ins->p->flags & FLB_INPUT_NET_SERVER) {
flb_mp_map_header_append(&mh);
pack_str(&mp_pck, "networking");

config_map = flb_downstream_get_config_map(ins->config);
msgpack_pack_array(&mp_pck, mk_list_size(config_map));
mk_list_foreach(head, config_map) {
m = mk_list_entry(head, struct flb_config_map, _head);
pack_config_map_entry(&mp_pck, m);
}
flb_config_map_destroy(config_map);
}
else if (ins->p->flags & FLB_INPUT_NET) {
flb_mp_map_header_append(&mh);
pack_str(&mp_pck, "networking");

config_map = flb_upstream_get_config_map(ins->config);
msgpack_pack_array(&mp_pck, mk_list_size(config_map));
mk_list_foreach(head, config_map) {
m = mk_list_entry(head, struct flb_config_map, _head);
pack_config_map_entry(&mp_pck, m);
}
flb_config_map_destroy(config_map);
}

if (ins->p->flags & (FLB_IO_TLS | FLB_IO_OPT_TLS)) {
flb_mp_map_header_append(&mh);
pack_str(&mp_pck, "network_tls");

config_map = flb_tls_get_config_map(ins->config);
msgpack_pack_array(&mp_pck, mk_list_size(config_map));

/* Adjust 'tls' default value based on plugin type" */
m = mk_list_entry_first(config_map, struct flb_config_map, _head);
if (ins->p->flags & FLB_IO_TLS) {
m->value.val.boolean = FLB_TRUE;
}
else if (ins->p->flags & FLB_IO_OPT_TLS) {
m->value.val.boolean = FLB_FALSE;
}
mk_list_foreach(head, config_map) {
m = mk_list_entry(head, struct flb_config_map, _head);
pack_config_map_entry(&mp_pck, m);
Expand Down
20 changes: 15 additions & 5 deletions src/flb_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <fluent-bit/flb_metrics.h>
#include <fluent-bit/flb_storage.h>
#include <fluent-bit/flb_downstream.h>
#include <fluent-bit/flb_upstream.h>
#include <fluent-bit/flb_plugin.h>
#include <fluent-bit/flb_kv.h>
#include <fluent-bit/flb_hash_table.h>
Expand Down Expand Up @@ -853,11 +854,20 @@ int flb_input_net_property_check(struct flb_input_instance *ins,
{
int ret = 0;

/* Get Downstream net_setup configmap */
ins->net_config_map = flb_downstream_get_config_map(config);
if (!ins->net_config_map) {
flb_input_instance_destroy(ins);
return -1;
/* Get Downstream or Upstream net_setup configmap */
if (ins->p->flags & FLB_INPUT_NET_SERVER) {
ins->net_config_map = flb_downstream_get_config_map(config);
if (!ins->net_config_map) {
flb_input_instance_destroy(ins);
return -1;
}
}
else if (ins->p->flags & FLB_INPUT_NET) {
ins->net_config_map = flb_upstream_get_config_map(config);
if (!ins->net_config_map) {
flb_input_instance_destroy(ins);
return -1;
}
}

/*
Expand Down
Loading