Skip to content

fix(puppetdb): reset circuit breaker failures on success while closed - #62

Merged
alvagante merged 1 commit into
mainfrom
alvagante/circuitbreaker-failurecount-never-resets-during
Sep 24, 2026
Merged

alvagante merged 1 commit into
mainfrom
alvagante/circuitbreaker-failurecount-never-resets-during

Conversation

@alvagante

Copy link
Copy Markdown
Member

Summary

  • Reset failureCount on success while the circuit is closed so only consecutive failures trip the breaker (fixes spurious trips on long-running instances).
  • Log the actual error message in PuppetDB environment/OS-family grouping catch blocks.
  • Add unit tests for consecutive-trip, success-clears-streak, and open rejection.

Closes #59

Test plan

  • cd backend && npx vitest run test/unit/integrations/CircuitBreaker.test.ts
  • Confirm a healthy PuppetDB no longer opens the breaker after sparse intermittent failures interleaved with successes
  • Confirm grouping query failures now include error.message in the warn log

Made with Cursor

LifetimeCount accumulated for the process lifetime while closed, so sparse
failures on long-running instances tripped the breaker even when PuppetDB
was healthy. Clear the streak on success, and log grouping query errors.

Closes #59

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI lite review requested due to automatic review settings September 24, 2026 16:56

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

Remaining feedback is limited to non-blocking test coverage nits.

Review effort: Lite
Findings: None

What changed in this PR

Fixes PuppetDB circuit-breaker failure streak handling and improves grouping-query error diagnostics.

Changes:

  • Reset closed-state failures after successful requests.
  • Log underlying grouping-query errors.
  • Add circuit-breaker unit tests.
File Summary
backend/​test/​unit/​integrations/​CircuitBreaker.test.ts Tests failure thresholds, reset behavior, and open rejection.
backend/​src/​integrations/​puppetdb/​PuppetDBService.ts Logs grouping-query error details.
backend/​src/​integrations/​puppetdb/​CircuitBreaker.ts Clears consecutive failures after success.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@alvagante
alvagante merged commit 53f8d45 into main Sep 24, 2026
13 checks passed
@alvagante
alvagante deleted the alvagante/circuitbreaker-failurecount-never-resets-during branch September 24, 2026 17:08
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.

CircuitBreaker: failureCount never resets during normal (closed) operation, causing spurious trips on long-running instances

2 participants