Skip to content

feat(health): add skip_initial_history flag to periodic log collector. False by default#3694

Merged
mkoci merged 1 commit into
NVIDIA:mainfrom
cdraman:HAAS-171
Jul 20, 2026
Merged

feat(health): add skip_initial_history flag to periodic log collector. False by default#3694
mkoci merged 1 commit into
NVIDIA:mainfrom
cdraman:HAAS-171

Conversation

@cdraman

@cdraman cdraman commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

When forge-hw-health runs in periodic log collection mode, the first poll against a LogService with no saved cursor drains the full entry history. For clusters that have accumulated thousands of historical entries including past XID faults or CPER records, this creates noise on startup and makes it hard to distinguish pre-existing events from new real-time faults.

Add skip_initial_history to collectors.logs.periodic (and the auto-mode fallback config). When true, the collector fetches all current entries on the first encounter of an unseen LogService, records the highest entry ID as the cursor, and discards the entries without emitting them. Subsequent polls collect only new entries from that point forward, matching the real-time-only behavior of SSE mode.

skip_initial_history is set to false by default and hence there is no change in behavior

Related issues

Closes #3636

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Additional Notes

Validated against a BMC with 4 GPU XID log services containing historical XID 149 entries:

  • Current (skip_initial_history=false): collector drained all historical entries on first poll, emitting existing XID events.
  • With the changes (skip_initial_history=true): collector logged skip_initial_history: anchored at current log position for all 4 services, emitting zero historical log events.

@cdraman
cdraman requested a review from a team as a code owner July 17, 2026 20:52
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e2abeffb-50e4-49c0-b791-ea0ff257e412

📥 Commits

Reviewing files that changed from the base of the PR and between 4d87ce4 and 558b1d1.

📒 Files selected for processing (4)
  • crates/health/example/config.example.toml
  • crates/health/src/collectors/logs/periodic.rs
  • crates/health/src/config.rs
  • crates/health/src/discovery/spawn.rs
🚧 Files skipped from review as they are similar to previous changes (4)
  • crates/health/src/discovery/spawn.rs
  • crates/health/example/config.example.toml
  • crates/health/src/collectors/logs/periodic.rs
  • crates/health/src/config.rs

Summary by CodeRabbit

  • New Features
    • Added a skip_initial_history setting for periodic and automatic log collection.
    • When enabled, the first time a log source is seen with no saved state, the collector anchors at the highest available numeric entry ID and skips emitting existing history; later polls emit only new entries.
    • Applies consistently to periodic collection and auto-mode fallback/downgrade paths.
  • Documentation
    • Updated the configuration example and inline docs describing the new behavior (disabled by default).

Walkthrough

Adds skip_initial_history to periodic log configuration, propagates it through collector startup, and anchors first-seen log services at their highest parseable entry ID without emitting historical records when enabled.

Changes

Periodic log history handling

Layer / File(s) Summary
Configuration contracts and examples
crates/health/src/config.rs, crates/health/example/config.example.toml
Adds skip_initial_history with a default of false, and documents it for periodic collection and auto-mode fallback.
Collector option propagation
crates/health/src/collectors/logs/periodic.rs, crates/health/src/discovery/spawn.rs
Passes the option from periodic configuration into LogsCollector.
Initial history anchoring
crates/health/src/collectors/logs/periodic.rs
On first observation of an untracked LogService, stores the highest parseable entry ID and skips existing records when enabled; unit tests cover anchor selection cases.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PeriodicLogConfig
  participant LogsCollector
  participant LogService
  participant PersistentState

  PeriodicLogConfig->>LogsCollector: provide skip_initial_history
  LogsCollector->>LogService: fetch entries
  LogsCollector->>PersistentState: persist highest parseable entry ID
  LogsCollector-->>LogService: emit no historical records on first poll
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the new skip_initial_history flag and its default behavior.
Description check ✅ Passed The description is directly related to the periodic log collector change and its intended behavior.
Linked Issues check ✅ Passed The changes satisfy #3636 by adding the defaulted config flag and skipping initial history on first encounter.
Out of Scope Changes check ✅ Passed No clear out-of-scope changes are present; the config example, propagation, and tests all support the requested feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/health/src/collectors/logs/periodic.rs`:
- Around line 331-364: Update the skip_initial_history initialization flow
around last_seen_ids so services are durably marked initialized even when
all_entries is empty or contains no parseable numeric IDs; distinguish this
marker from a missing last_seen_id so subsequent entries are collected rather
than discarded as initial history. Add table-driven coverage for empty,
non-parseable, and numeric initial histories, preserving the existing numeric
anchor behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bcb88826-4d76-49fc-8281-f0300655f4db

📥 Commits

Reviewing files that changed from the base of the PR and between 0dae3ca and 96a5876.

📒 Files selected for processing (4)
  • crates/health/example/config.example.toml
  • crates/health/src/collectors/logs/periodic.rs
  • crates/health/src/config.rs
  • crates/health/src/discovery/spawn.rs

Comment thread crates/health/src/collectors/logs/periodic.rs
@github-actions

Copy link
Copy Markdown

When `forge-hw-health` runs in periodic log collection mode, the first
poll against a LogService with no saved cursor drains the full entry
history. For clusters that have accumulated thousands of historical
entries — including past XID faults or CPER records — this creates
noise on startup and makes it hard to distinguish pre-existing events
from new real-time faults.

Add `skip_initial_history` to `collectors.logs.periodic` (and the
auto-mode fallback config). When `true`, the collector fetches all
current entries on the first encounter of an unseen LogService, records
the highest entry ID as the cursor, and discards the entries without
emitting them. Subsequent polls collect only new entries from that
point forward, matching the real-time-only behaviour of SSE mode.

For services that are empty or have no parseable numeric entry IDs on
first encounter, the collector inserts a sentinel value of -1. This
ensures the service is marked as seen so subsequent polls correctly
collect new entries rather than re-entering the initial-history path.
Real Redfish entry IDs are non-negative, so -1 is safe and passes all
new entries through.

Closes NVIDIA#3636

## Related issues
Closes NVIDIA#3636

## Type of Change
- [x] **Add** - New feature or capability
- [ ] **Change** - Changes in existing functionality
- [ ] **Fix** - Bug fixes
- [ ] **Remove** - Removed features or deprecated functionality
- [ ] **Internal** - Internal changes (refactoring, tests, docs, etc.)

## Breaking Changes
- [ ] **This PR contains breaking changes**

## Testing
- [x] Unit tests added/updated
- [ ] Integration tests added/updated
- [x] Manual testing performed
- [ ] No testing required (docs, internal refactor, etc.)

## Additional Notes
Validated on `vr-nvl72-ts2-l11-032-c01` (10.71.23.88). Journal services
suppressed via `exclude_services = ["Journal"]` (19 active services, 2 excluded).

- **skip_initial_history=false (baseline)**: collector drained full log
  history on first poll, emitting historical XID events and producing PHRs.
- **skip_initial_history=true**: collector logged
  `skip_initial_history: anchored at current log position` for all 19
  services, emitting zero historical log events. Empty services (e.g.
  EventLog, FDR) received `anchor_id=-1` sentinel and were correctly
  handled on the next poll.

Signed-off-by: Dasa Chandramouli <dchandramoul@nvidia.com>
@mkoci
mkoci merged commit 10f4279 into NVIDIA:main Jul 20, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(health): add skip_initial_history flag to periodic log collector

3 participants