Skip to content

fix(collector): only declare hostPath volumes when needed (LOG-9713) - #3385

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:release-6.6from
vparfonov:log9713
Aug 4, 2026
Merged

fix(collector): only declare hostPath volumes when needed (LOG-9713)#3385
openshift-merge-bot[bot] merged 1 commit into
openshift:release-6.6from
vparfonov:log9713

Conversation

@vparfonov

Copy link
Copy Markdown
Contributor

Description

Only declare hostPath volumes when their input sources are configured.

The collector pod spec unconditionally declares hostPath volumes for audit API, journal and OVN logs even when those inputs are not enabled.

This fix moves the volume declarations inside the same input-source conditions that control the volumeMounts, so app-only collectors don't declare unnecessary hostPath access.

/cc @Clee2691
/assign @jcantrill

Links

Move hostPath volume declarations for audit, journal, OVN, and API server
logs inside the same input-source conditions that already control the
volumeMounts. This prevents unnecessary hostPath access on collectors

Signed-off-by: Vitalii Parfonov <vparfono@redhat.com>
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e410ff3a-28bc-4119-b271-3e40c4c31671

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@openshift-ci
openshift-ci Bot requested review from cahartma and jcantrill August 4, 2026 11:42
@qodo-for-rh-openshift

qodo-for-rh-openshift Bot commented Aug 4, 2026

Copy link
Copy Markdown

PR Summary by Qodo

fix(collector): gate hostPath volumes on enabled inputs (LOG-9713)

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Stop declaring hostPath volumes for disabled collector input sources.
• Align volume declarations with existing volumeMount gating conditions.
• Extend daemonset pod spec test to exercise input-driven volume behavior.
Diagram

graph TD
A["ClusterLogForwarderSpec.inputs"] --> B["internalobs.Inputs()"] --> C1["Container inputs enabled"] --> F["HostPath volume(s)"] --> D["podSpec.volumes"] --> E["Collector DaemonSet Pod"]
A --> B --> C2["Journal enabled"] --> F --> D --> E
A --> B --> C3["Audit enabled"] --> F --> D --> E
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Derive volumes from volumeMount plan
  • ➕ Prevents future drift between mount gating and volume gating
  • ➕ Centralizes enablement logic in one place (mount planning)
  • ➖ Requires refactoring PodSpec assembly order and/or exposing mount plan data
  • ➖ More invasive change than needed for this bug fix
2. Central mapping table for input→(volumes,mounts)
  • ➕ Reduces repeated conditional blocks and keeps sources consistent
  • ➕ Easier to add new sources without duplicating patterns
  • ➖ Slightly more indirection for a small set of sources
  • ➖ May require more extensive test rewrites to validate mapping behavior

Recommendation: The PR’s approach (moving hostPath volume declarations under the same input-source conditions) is the right minimal fix for reducing unnecessary hostPath access. If this area continues to grow, consider a follow-up refactor to generate both volumes and mounts from a shared input→resource mapping to avoid divergence.

Files changed (2) +38 / -10

Bug fix (1) +33 / -10
collector.goConditionally add hostPath volumes only for enabled inputs +33/-10

Conditionally add hostPath volumes only for enabled inputs

• Replaces unconditional hostPath volume declarations in the daemonset PodSpec with per-input checks via internalobs.Inputs(). HostPath volumes for container logs, journal, and each audit source are appended only when the corresponding input is enabled, reducing unnecessary host filesystem access.

internal/collector/collector.go

Tests (1) +5 / -0
collector_test.goAdd explicit Inputs to daemonset pod spec test fixture +5/-0

Add explicit Inputs to daemonset pod spec test fixture

• Updates the daemonset PodSpec test setup to include application, infrastructure, and audit inputs. This exercises the new input-driven volume behavior and prevents regressions in volume gating.

internal/collector/collector_test.go

@qodo-for-rh-openshift

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

@jcantrill jcantrill left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 4, 2026
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jcantrill, vparfonov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 4, 2026
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@vparfonov: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot
openshift-merge-bot Bot merged commit f313863 into openshift:release-6.6 Aug 4, 2026
9 checks passed
@vparfonov
vparfonov deleted the log9713 branch August 4, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release/6.6

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants