Repository navigation
fix(fluentd): propagate dnsPolicy to the configcheck pod - #2285
Merged
csatib02 merged 1 commit intoJul 27, 2026
Merged
Conversation
The configcheck pod copied dnsConfig from the Fluentd spec but not dnsPolicy, so it always ran with the API server default of ClusterFirst while the aggregator it validates ran with the configured policy. The two are not independent. With dnsPolicy: None a pod resolves only through dnsConfig, while ClusterFirst merges dnsConfig on top of cluster DNS. A configcheck pod that resolves names differently from the aggregator can pass or fail for reasons the aggregator will not reproduce, which is the opposite of what the check is for. Copy dnsPolicy alongside dnsConfig, as the aggregator StatefulSet already does. An unset dnsPolicy stays unset, so existing installations are unaffected. Refs kube-logging#2228 Signed-off-by: Vyncint Ng <[email protected]>
csatib02
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
newCheckPodcopiesdnsConfigfrom the Fluentd spec into the configcheck pod, but notdnsPolicy:The aggregator StatefulSet, a few files over in
statefulset.go, sets both:So the configcheck pod always ran with the API server default of
ClusterFirst, while the aggregator it is meant to validate ran with whatever policy the user configured.These two fields are not independent. With
dnsPolicy: Nonea pod resolves only throughdnsConfig; withClusterFirstthednsConfigis merged on top of cluster DNS. A configcheck pod that resolves names differently from the aggregator can pass or fail for reasons the aggregator will not reproduce, which is the opposite of what the check is for. The same applies toDefaultandClusterFirstWithHostNet.The fix is one line: copy
dnsPolicyalongsidednsConfig.Deliberately left alone, to keep this narrow — happy to fold either in if you would rather:
topologySpreadConstraintsis also not propagated, but that looks intentional. The function already stripspodAntiAffinitywith the comment "pod anti-affinity has been disabled to avoid blocking configcheck pods accidentally", and aDoNotSchedulespread constraint would block a configcheck pod in exactly the same way.terminationGracePeriodSecondsis not propagated either, but configcheck pods arerestartPolicy: Neverand short-lived, so it has no practical effect.Link to the issue in case of a bug fix.
Refs #2228
That issue reports the configcheck pod missing parts of the configured pod spec. It names
podSecurityContextspecifically, and I should be upfront thatpodSecurityContextis not the problem on current master —newCheckPoddoes setSecurityContext: fluentdSpec.Security.PodSecurityContext, and I verified it lands on the pod. The report was filed against 6.2.2.dnsPolicyis a real instance of the same class of gap, so this PR fixes that one rather than closing the issue. I have left a note there with the details.Testing details
Manual - verified on a kind cluster (v1.33.1), A/B against the released operator.
Loggingwithspec.fluentd.dnsPolicy: Noneplus a customdnsConfig:dnsPolicy: NonednsPolicy: ClusterFirstdnsPolicy: NonednsPolicy: NonednsConfigwas identical in all four cases, which is what makes the mismatch matter. TheLoggingresource was deleted and recreated between the two runs so the configcheck result was not served fromstatus.configCheckResults— I confirmed the "after" pod had a new UID and acreationTimestamplater than the operator rollout. The configcheck still completed (status.configCheckResults: {"893225a7": true}) and the aggregator came up, so propagating the policy does not break the check.Unit tests - added
pkg/resources/fluentd/appconfigmap_test.go.TestNewCheckPodDNSSettingscovers unset,Nonewith adnsConfig,ClusterFirstWithHostNetandDefault;TestNewCheckPodDNSSettingsMatchStatefulSetasserts the configcheck pod and the aggregator pod template agree, so the two cannot drift apart again.As a negative control I reverted the one-line fix and confirmed the new tests fail with
expected: "None", actual: "". TheUnsetcase passes either way by design — it is the boundary case that pins the no-change-for-existing-users behaviour.go test ./pkg/resources/...,make lint(0 issues in both modules) andmake generateall clean;make generateproduces no diff beyond the two files in this PR.Any backward incompatible change? If so, please explain.
No.
dnsPolicyis not defaulted anywhere in the API, so an installation that does not setspec.fluentd.dnsPolicyleaves the field empty and the API server continues to applyClusterFirstto the configcheck pod exactly as before. Only installations that explicitly set a policy see a change, and for them the new behaviour is the one they asked for.