Skip to content

fix(health): force alert notifications on health command#156

Merged
utkarsh232005 merged 4 commits into
KDM-cli:mainfrom
utkarsh232005:bugfix/health-check-cooldown-bypass
Jun 11, 2026
Merged

fix(health): force alert notifications on health command#156
utkarsh232005 merged 4 commits into
KDM-cli:mainfrom
utkarsh232005:bugfix/health-check-cooldown-bypass

Conversation

@utkarsh232005

@utkarsh232005 utkarsh232005 commented Jun 11, 2026

Copy link
Copy Markdown
Member

This PR updates the alerts module and the health command so that manual executions of kdm health bypass the usual cooldown tracker and always trigger notification alerts immediately.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a force option to alert triggering, allowing immediate alert dispatch even when cooldown is active.
    • Health checks now support forcing alerts to bypass cooldown restrictions.
  • Tests

    • Added comprehensive test coverage for alert cooldown behavior, including verification of suppression and force override functionality.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@utkarsh232005, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 4 minutes and 35 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 43804f06-00f8-4b67-bb57-9808e9d3884c

📥 Commits

Reviewing files that changed from the base of the PR and between 04b7489 and 7e2fb5e.

📒 Files selected for processing (2)
  • src/__tests__/alerts.test.ts
  • src/commands/health.ts

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (2)
Validation error: Invalid input: expected string, received undefined at "reviews.path_instructions[3].path"; Invalid input: expected string, received undefined at "reviews.path_instructions[3].instructions"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

This PR adds a cooldown force-override capability to the alert system. The triggerAlert function now accepts an optional force flag to bypass cooldown suppression. The feature propagates through container and pod status retrieval functions, and the health command invokes checks with force-alert enabled to ensure status-check alerts trigger regardless of cooldown state.

Changes

Alert Cooldown Force Override

Layer / File(s) Summary
Alert cooldown force override
src/monitor/alerts.ts, src/__tests__/alerts.test.ts
triggerAlert signature extended to accept options?: { force?: boolean }. Cooldown bypass logic now checks options.force to skip suppression. Tests verify initial trigger, cooldown suppression, and force: true bypass behavior.
Propagating force alert through container/pod retrieval
src/docker/containers.ts, src/kubernetes/pods.ts
getRunningContainers and getRunningPods now accept options?: { forceAlert?: boolean } and forward it to all triggerAlert calls (restarting, exited/failed containers, and failed pods).
Health command integration and testing
src/commands/health.ts, src/__tests__/health.test.ts
fetchHealthRows accepts and forwards forceAlert option to retrieval functions. Both watch mode and one-time health checks call fetchHealthRows with { forceAlert: true }. Health test assertions verify the option propagation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A cooldown that bends to the will so strong,
Force-true alerts sing their urgent song,
Through containers, pods, and health checks they flow,
Each layer coordinating a swift override show,
Tests mock and verify the bounce-back's just right! 💫

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: enabling forced alert notifications when the health command runs, which matches the PR's core objective of bypassing cooldown for manual health checks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/commands/health.ts 90.00% 0 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@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 `@src/__tests__/alerts.test.ts`:
- Around line 29-35: The test sets global.fetch at module scope via mockFetch
and never restores it; change the setup to use vi.stubGlobal('fetch', mockFetch)
instead of assigning global.fetch and add cleanup in afterEach by calling
vi.unstubAllGlobals() (or afterAll if preferred) so mocks don't leak between
tests; update references around mockFetch, the describe('alerts monitoring')
block, and beforeEach/afterEach accordingly.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f0460242-1f2e-4db9-a016-6fdda1074c0c

📥 Commits

Reviewing files that changed from the base of the PR and between 0b1be13 and 04b7489.

📒 Files selected for processing (6)
  • src/__tests__/alerts.test.ts
  • src/__tests__/health.test.ts
  • src/commands/health.ts
  • src/docker/containers.ts
  • src/kubernetes/pods.ts
  • src/monitor/alerts.ts

Comment thread src/__tests__/alerts.test.ts
codescene-delta-analysis[bot]

This comment was marked as outdated.

@utkarsh232005 utkarsh232005 merged commit 0974cf6 into KDM-cli:main Jun 11, 2026
4 of 5 checks passed

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Health Improved (1 files improve in Code Health)

Our agent can fix these. Install it.

Gates Passed
3 Quality Gates Passed

View Improvements
File Code Health Impact Categories Improved
health.ts 8.37 → 8.55 Complex Method, Bumpy Road Ahead

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant