Skip to content

Commit 6978331

Browse files
authored
Merge pull request #1886 from kube-logging/force-hotreload-grace
feat: force HotReload after grace period instead of blocking indefinitely
2 parents 5c1871b + bdd86f7 commit 6978331

File tree

11 files changed

+68
-28
lines changed

11 files changed

+68
-28
lines changed

charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_fluentbitagents.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,8 @@ spec:
14801480
flush:
14811481
format: int32
14821482
type: integer
1483+
forceHotReloadAfterGrace:
1484+
type: boolean
14831485
forwardOptions:
14841486
properties:
14851487
Require_ack_response:

charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_loggings.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,8 @@ spec:
23252325
flush:
23262326
format: int32
23272327
type: integer
2328+
forceHotReloadAfterGrace:
2329+
type: boolean
23282330
forwardOptions:
23292331
properties:
23302332
Require_ack_response:

charts/logging-operator/crds/logging.banzaicloud.io_fluentbitagents.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,8 @@ spec:
14771477
flush:
14781478
format: int32
14791479
type: integer
1480+
forceHotReloadAfterGrace:
1481+
type: boolean
14801482
forwardOptions:
14811483
properties:
14821484
Require_ack_response:

charts/logging-operator/crds/logging.banzaicloud.io_loggings.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,6 +2322,8 @@ spec:
23222322
flush:
23232323
format: int32
23242324
type: integer
2325+
forceHotReloadAfterGrace:
2326+
type: boolean
23252327
forwardOptions:
23262328
properties:
23272329
Require_ack_response:

config/crd/bases/logging.banzaicloud.io_fluentbitagents.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,8 @@ spec:
14771477
flush:
14781478
format: int32
14791479
type: integer
1480+
forceHotReloadAfterGrace:
1481+
type: boolean
14801482
forwardOptions:
14811483
properties:
14821484
Require_ack_response:

config/crd/bases/logging.banzaicloud.io_loggings.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,6 +2322,8 @@ spec:
23222322
flush:
23232323
format: int32
23242324
type: integer
2325+
forceHotReloadAfterGrace:
2326+
type: boolean
23252327
forwardOptions:
23262328
properties:
23272329
Require_ack_response:

config/samples/multitenant-routing/logging/tenant-infra-logging.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ metadata:
1111
tenant: infra
1212
spec:
1313
loggingRef: infra
14-
fluentd: {}
14+
fluentd:
15+
metrics: {}
1516
controlNamespace: infra
1617
---
1718
apiVersion: logging.banzaicloud.io/v1beta1
@@ -49,8 +50,12 @@ metadata:
4950
name: infra
5051
spec:
5152
loggingRef: infra
53+
# this is required to reload even if there are pending tasks in one of the queues
54+
# requires grace to be set, which is 5 by default
55+
forceHotReloadAfterGrace: true
5256
inputTail:
5357
storage.type: filesystem
58+
storage.pause_on_chunks_overlimit: "off"
5459
positiondb:
5560
hostPath:
5661
path: ""
@@ -59,7 +64,15 @@ spec:
5964
path: ""
6065
network:
6166
connectTimeout: 2
67+
keepaliveMaxRecycle: 20
6268
metrics: {}
69+
bufferStorage:
70+
storage.max_chunks_up: 10
71+
forwardOptions:
72+
storage.total_limit_size: 50MB
73+
image:
74+
tag: 3.1.10-debug
75+
configHotReload: {}
6376
---
6477
apiVersion: logging.banzaicloud.io/v1beta1
6578
kind: LoggingRoute

docs/configuration/crds/v1beta1/fluentbit_types.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ Set the flush time in seconds.nanoseconds. The engine loop uses a Flush timeout
128128

129129
Default: 1
130130

131+
### forceHotReloadAfterGrace (bool, optional) {#fluentbitspec-forcehotreloadaftergrace}
132+
133+
HotReload pauses all inputs and waits until they finish. In certain situations this is unacceptable, for example if an output is down for a longer time. An undocumented option called "Hot_Reload.Ensure_Thread_Safety Off" can be used at the [SERVICE] config to force hotreload after the grace period. Please note that it might result in a SIGSEGV, but worst case kubelet will restart the container. See https://github.com/fluent/fluent-bit/pull/7509
134+
135+
131136
### forwardOptions (*ForwardOptions, optional) {#fluentbitspec-forwardoptions}
132137

133138

pkg/resources/fluentbit/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ var fluentBitConfigTemplate = `
2626
[SERVICE]
2727
Flush {{ .Flush }}
2828
Grace {{ .Grace }}
29+
{{- if .ForceHotReloadAfterGrace }}
30+
Hot_Reload.Ensure_Thread_Safety off
31+
{{- end }}
2932
Daemon Off
3033
Log_Level {{ .LogLevel }}
3134
Parsers_File {{ .DefaultParsers }}

pkg/resources/fluentbit/configsecret.go

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,25 @@ type fluentBitConfig struct {
6464
Port int32
6565
Path string
6666
}
67-
Flush int32
68-
Grace int32
69-
LogLevel string
70-
EnabledIPv6 bool
71-
CoroStackSize int32
72-
Output map[string]string
73-
Input fluentbitInputConfig
74-
Inputs []fluentbitInputConfigWithTenant
75-
DisableKubernetesFilter bool
76-
KubernetesFilter map[string]string
77-
AwsFilter map[string]string
78-
BufferStorage map[string]string
79-
FilterModify []v1beta1.FilterModify
80-
FluentForwardOutput *fluentForwardOutputConfig
81-
SyslogNGOutput *syslogNGOutputConfig
82-
DefaultParsers string
83-
CustomParsers string
84-
HealthCheck *v1beta1.HealthCheck
67+
Flush int32
68+
Grace int32
69+
LogLevel string
70+
EnabledIPv6 bool
71+
CoroStackSize int32
72+
Output map[string]string
73+
ForceHotReloadAfterGrace bool
74+
Input fluentbitInputConfig
75+
Inputs []fluentbitInputConfigWithTenant
76+
DisableKubernetesFilter bool
77+
KubernetesFilter map[string]string
78+
AwsFilter map[string]string
79+
BufferStorage map[string]string
80+
FilterModify []v1beta1.FilterModify
81+
FluentForwardOutput *fluentForwardOutputConfig
82+
SyslogNGOutput *syslogNGOutputConfig
83+
DefaultParsers string
84+
CustomParsers string
85+
HealthCheck *v1beta1.HealthCheck
8586
}
8687

8788
type fluentForwardOutputConfig struct {
@@ -214,15 +215,16 @@ func (r *Reconciler) configSecret() (runtime.Object, reconciler.DesiredState, er
214215
}
215216

216217
input := fluentBitConfig{
217-
Flush: r.fluentbitSpec.Flush,
218-
Grace: r.fluentbitSpec.Grace,
219-
LogLevel: r.fluentbitSpec.LogLevel,
220-
EnabledIPv6: r.fluentbitSpec.EnabledIPv6,
221-
CoroStackSize: r.fluentbitSpec.CoroStackSize,
222-
Namespace: r.Logging.Spec.ControlNamespace,
223-
DisableKubernetesFilter: disableKubernetesFilter,
224-
FilterModify: r.fluentbitSpec.FilterModify,
225-
HealthCheck: r.fluentbitSpec.HealthCheck,
218+
Flush: r.fluentbitSpec.Flush,
219+
Grace: r.fluentbitSpec.Grace,
220+
ForceHotReloadAfterGrace: r.fluentbitSpec.ForceHotReloadAfterGrace,
221+
LogLevel: r.fluentbitSpec.LogLevel,
222+
EnabledIPv6: r.fluentbitSpec.EnabledIPv6,
223+
CoroStackSize: r.fluentbitSpec.CoroStackSize,
224+
Namespace: r.Logging.Spec.ControlNamespace,
225+
DisableKubernetesFilter: disableKubernetesFilter,
226+
FilterModify: r.fluentbitSpec.FilterModify,
227+
HealthCheck: r.fluentbitSpec.HealthCheck,
226228
}
227229

228230
input.DefaultParsers = fmt.Sprintf("%s/%s", StockConfigPath, "parsers.conf")

0 commit comments

Comments
 (0)