Fix: handle connection errors gracefully and add comprehensive tests#13
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #12 where kdm show runners crashed on Kubernetes connection errors. It wraps the show commands in try/catch and uses Promise.allSettled so a failure in one backend (Docker or Kubernetes) no longer aborts the whole command. It also adds Vitest-based unit tests for several commands and a CI workflow to run them on PRs.
Changes:
- Graceful error handling in
showContainers,showPods, andshowRunners(usingPromise.allSettled), plus safer error-message extraction in the Docker/Kubernetes fetchers. - New Vitest unit tests for
show,watch,logs,health, andconfigcommands. - New GitHub Actions workflow that runs
npm teston PRs againstmain/masterusing Node 20.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/commands/show.ts | Exports show subcommands and adds try/catch + Promise.allSettled for graceful failure handling. |
| src/docker/containers.ts | Uses safer instanceof Error check when formatting the error message. |
| src/kubernetes/pods.ts | Same safer error-message extraction as Docker side. |
| src/tests/show.test.ts | Tests that showRunners/showPods handle backend failures without crashing. |
| src/tests/watch.test.ts | Tests that the watch command registers and clears the screen / renders dashboard. |
| src/tests/logs.test.ts | Tests logs command registration and logger.info invocation. |
| src/tests/health.test.ts | Tests health command registration and logger.info invocation. |
| src/tests/config.test.ts | Tests config set/list/clear subcommands including integer parsing for alert_cooldown. |
| .github/workflows/test.yml | Adds CI workflow to run npm test with Node 20 on PRs to main/master. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fixes #12. This PR introduces graceful error handling when Kubernetes or Docker APIs are unreachable, adds unit tests for all commands, sets up a CI workflow, and adds an interactive 'kdm config setup' command for notification services using @vr_patel/tui.