Skip to content

Conversation

@SanjeevLakhwani
Copy link
Contributor

@SanjeevLakhwani SanjeevLakhwani commented Dec 10, 2025

Adds a new status command to bentoctl that verifies whether Bento services are running and displays their status. Previously it was an alias for mode command, which now it is not.

Changes:

  • Add Status subcommand to entry.py
  • 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.

@SanjeevLakhwani SanjeevLakhwani marked this pull request as draft December 10, 2025 19:42
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.
@SanjeevLakhwani SanjeevLakhwani force-pushed the feat/check-services-command branch from 6e6ecd0 to af12f8c Compare December 10, 2025 20:07
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
@gsfk
Copy link
Member

gsfk commented Dec 11, 2025

Can the checks be async? Also, status is puzzled by adminer:

Failed to check status for adminer: no such service: adminer

@SanjeevLakhwani SanjeevLakhwani requested a review from gsfk December 15, 2025 15:56
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
Copy link
Member

@gsfk gsfk left a 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
@SanjeevLakhwani SanjeevLakhwani requested a review from gsfk December 15, 2025 19:10
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'.
@gsfk
Copy link
Member

gsfk commented Dec 17, 2025

can we get one extra character in the container names?

gohan-elasticsearc running

Copy link
Member

@gsfk gsfk left a 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).

@SanjeevLakhwani SanjeevLakhwani marked this pull request as ready for review January 5, 2026 14:26
@@ -0,0 +1,18 @@
metadata_dir = "/var/lib/garage/meta"
Copy link
Member

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
Copy link
Member

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):
Copy link
Member

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()]
Copy link
Member

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

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.

4 participants