-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add check-services command to verify service runtime status #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: releases/v20.1
Are you sure you want to change the base?
Conversation
Adds a new `check-services` command to bentoctl that verifies whether Bento services are running and displays their status. Changes: - Add CheckServices subcommand to entry.py - Implement check_services_status() with JSON parsing of docker compose ps - Handle both single services and "all" services check - Display colored output (green=running, red=not running) - Exit with error code if services are not running Also includes: - Add init-garage command for Garage object storage initialization - Update BENTO_USER_EXCLUDED_SERVICES to include garage instead of minio This command is useful for quickly checking the health of the Bento platform without inspecting docker containers directly.
6e6ecd0 to
af12f8c
Compare
Renames the check-services command to 'status' for better usability and removes its dependency on the mode system. The status command now uses the base compose configuration to check running containers, making it work independently of whether services are in local or prebuilt mode. Changes: - Rename check-services command to status - Remove 'status' alias from mode command to avoid conflicts - Simplify status checking by removing mode-specific compose args - Status now consistently reports runtime state across all modes
|
Can the checks be async? Also,
|
Convert status checking to use asyncio for concurrent execution when checking multiple services. This significantly improves performance of 'bentoctl status all' by checking all services in parallel instead of sequentially. Changes: - Add asyncio import - Convert _get_service_runtime_state() to async using create_subprocess_exec - Convert _print_service_runtime_state() to async - Use asyncio.gather() to run all service checks concurrently - Improve error handling to avoid SystemExit in async tasks - Return errors as values instead of calling exit() in async functions - Use return_exceptions=True in gather() for graceful error handling
Filter service status checks to only include services that are actually configured in the current compose setup, avoiding false errors for profile-based services like adminer and elasticvue that may not be enabled. Changes: - Add _get_configured_services() to query docker compose config --services - Use configured services list instead of DOCKER_COMPOSE_SERVICES constant - Eliminates errors for services that aren't supposed to be running
gsfk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't find these services:
gohan
public
beacon
keycloak
Use the same compose setup (with files and profiles) for both config --services and ps commands. This ensures that all configured services including profile-based and dev services (adminer, elasticvue) can be properly checked. Previously _get_service_runtime_state used basic c.COMPOSE while _get_configured_services used _get_compose_with_files, causing mismatches where services appeared in the config but couldn't be found when checking their status. Changes: - Update _get_service_runtime_state to use _get_compose_with_files - Ensures gohan, beacon, public, auth, adminer, elasticvue are all checked
Improve status command to differentiate between different health states using color-coded output, while optimizing performance by fetching all service statuses in a single docker compose ps call. Health status colors: - Green: running and healthy (or no healthcheck) - Yellow: running but health check in progress (health: starting) - Red: not running OR unhealthy Exit codes remain unchanged - only exit 1 if services are not running, not for unhealthy services. Performance improvement: - Previously: N async docker compose ps calls (one per service) - Now: 1 synchronous docker compose ps call for all services - Removed asyncio dependency Changes: - Add _parse_health_status() to extract health status from Docker output - Add _fetch_all_service_statuses() to get all statuses in one call - Add _print_service_status() for color-coded status display - Update get_services_status() to use single ps call approach - Parse "(healthy)", "(health: starting)", "(unhealthy)" from status text - Remove asyncio import and async functions
Sort services alphabetically when displaying status to make it easier to find specific services in the output, especially when checking all services with 'bentoctl status all'.
|
can we get one extra character in the container names?
|
gsfk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well, thanks. We could probably update some of the docker health checks (some of them can't tell if an app has crashed) but that's outside the scope of this pr.
non-blocking: define a constant for max container name length instead of the current magic number (19).
| @@ -0,0 +1,18 @@ | |||
| metadata_dir = "/var/lib/garage/meta" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this supposed to be committed?
| DEV_MODE = MODE == "dev" | ||
|
|
||
| SERVICE_LITERAL_ALL: str = "all" | ||
| MAX_SERVICE_CHAR_LEN: int = 19 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a comment explaining where this comes from and what it needs to be set to
| fh.init_cbioportal() | ||
|
|
||
|
|
||
| class InitGarage(SubCommand): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm
| try: | ||
| parsed = json.loads(stdout_str) | ||
| except json.JSONDecodeError: | ||
| entries = [_load_entry(line) for line in stdout_str.splitlines() if line.strip()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is another occurrence of this same type of comprehension (albeit formatted differently) on line 530 - the split by newline + if strip. this could maybe be moved into a little generator file-private function helper, or at least both lines should consistently use splitlines
Adds a new
statuscommand to bentoctl that verifies whether Bento services are running and displays their status. Previously it was an alias formodecommand, which now it is not.Changes:
Also includes:
This command is useful for quickly checking the health of the Bento platform without inspecting docker containers directly.