Skip to content

Commit 0e2ea84

Browse files
committed
fix(fluentd): propagate sidecarContainers to the configcheck pod
Motivation: FluentdSpec.SidecarContainers is added to the Fluentd StatefulSet pod but was never propagated to the transient fluentd-configcheck-* pod that dry-runs the rendered config before rollout. Users who need a sidecar to run before the aggregator starts (e.g. to refresh a GeoIP database via extraVolumes, as reported) only got it on the StatefulSet, not on the config check. Approach: Mirror the existing statefulset.go pattern in containerCheckPod (pkg/resources/fluentd/appconfigmap.go): append fluentdSpec.SidecarContainers to the check pod's container list when non-empty. The fluentd container that other code paths index at Containers[0] (e.g. the TLS volume mount) is unaffected since sidecars are appended after it. Validation: - go build ./... and go vet ./pkg/resources/fluentd/... pass. - Added TestNewCheckPodSidecarContainers to appconfigmap_test.go, which asserts the configcheck pod's container list contains a configured sidecar. Confirmed it fails without the fix (stashing only appconfigmap.go reproduces the reported bug) and passes with it: go test ./pkg/resources/fluentd/... -run TestNewCheckPod -v - make lint reports 0 issues across all three modules. - make test passes across the full suite with no failures. - make license-check fails, but identically on unmodified master (verified via git stash), so it is a pre-existing environment issue unrelated to this change. User-visible behaviour of the main Fluentd StatefulSet is unchanged; this only fixes the config check pod, whose config validation previously ran without any configured sidecars. Report: #2103 Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
1 parent 04e6f77 commit 0e2ea84

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

pkg/resources/fluentd/appconfigmap.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ func (r *Reconciler) containerCheckPod(fluentdSpec v1beta1.FluentdSpec) []corev1
430430
},
431431
}
432432

433+
if len(fluentdSpec.SidecarContainers) != 0 {
434+
container = append(container, fluentdSpec.SidecarContainers...)
435+
}
436+
433437
return container
434438
}
435439

pkg/resources/fluentd/appconfigmap_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,23 @@ func TestNewCheckPodDNSSettingsMatchStatefulSet(t *testing.T) {
122122
assert.Equal(t, sts.Spec.Template.Spec.DNSPolicy, checkPod.Spec.DNSPolicy)
123123
assert.Equal(t, sts.Spec.Template.Spec.DNSConfig, checkPod.Spec.DNSConfig)
124124
}
125+
126+
// TestNewCheckPodSidecarContainers pins the configcheck pod to carry the same
127+
// sidecarContainers as the aggregator StatefulSet, since a sidecar that only
128+
// mutates shared config (e.g. refreshing a GeoIP database via extraVolumes)
129+
// needs to run before the check as well, or the check validates against stale
130+
// input.
131+
func TestNewCheckPodSidecarContainers(t *testing.T) {
132+
sidecar := corev1.Container{
133+
Name: "fluentd-sidecar",
134+
Image: "busybox:1.37",
135+
}
136+
spec := &v1beta1.FluentdSpec{
137+
SidecarContainers: []corev1.Container{sidecar},
138+
}
139+
r := newCheckPodReconciler(t, spec)
140+
141+
checkPod := r.newCheckPod("deadbeef", *r.fluentdSpec)
142+
143+
assert.Contains(t, checkPod.Spec.Containers, sidecar)
144+
}

0 commit comments

Comments
 (0)