Skip to content

ci: local environment checks health before creating assets#2220

Merged
bosbaber merged 4 commits into
mainfrom
stephan/int1-671
Jul 3, 2026
Merged

ci: local environment checks health before creating assets#2220
bosbaber merged 4 commits into
mainfrom
stephan/int1-671

Conversation

@bosbaber

@bosbaber bosbaber commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

TL;DR - Makes the local environment setup script more robust

The local environment scripts would sometimes cause silent failures thereby confusing users in cases where the database would take a long time to start. For some reason this used to be an issue especially in Mac environments.

This PR adds better error handling and health checks to mitigate these types of problems in the future.


Generated description

This pull request makes several improvements to the local development environment, focusing on more robust service readiness checks, better handling of service dependencies, and improved reliability of the Rafiki setup process. The changes ensure that dependent services only start after Postgres and Redis are fully ready, preventing startup failures and race conditions. The Rafiki setup script is enhanced to probe the admin GraphQL API for true readiness, and several configuration options are made tunable for slow environments. Additionally, minor fixes and improvements are included for asset pagination and cleaning scripts.

Service Readiness and Dependency Handling:

  • Added healthcheck sections to postgres (local/postgres.yaml) and redis (local/redis.yaml) services to ensure they are actually ready before dependents start. This prevents race conditions where services attempt to connect before the database or cache is initialized. [1] [2]
  • Updated depends_on in local/rafiki.yaml so that Rafiki services wait for Postgres and Redis to be healthy before starting, using Docker Compose's condition: service_healthy. This avoids migration and seeding failures during container startup. [1] [2]

Rafiki Setup Script Improvements:

  • The setup script now probes the admin GraphQL API with a signed request to ensure it is fully ready (not just /healthz), preventing transient authentication errors during setup. Readiness parameters are now configurable via environment variables for flexibility on slower systems. [1] [2] [3] [4]
  • Changed default endpoint URLs from localhost to 127.0.0.1 to avoid IPv6 resolution issues in Node 18+ that can cause connection failures with Docker's published ports.

Other Fixes and Improvements:

  • Capped asset pagination in the setup script to 100 (from 200) to match Rafiki's enforced limit and avoid pagination errors.
  • Enhanced the clean script in package.json to also bring down and reset local Docker services, ensuring a more thorough cleanup.

@bosbaber bosbaber self-assigned this Jul 2, 2026
@bosbaber bosbaber marked this pull request as draft July 2, 2026 14:24
@bosbaber bosbaber requested a review from Copilot July 2, 2026 14:25

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.

Pull request overview

This PR improves the reliability of the local Rafiki dev environment by adding explicit readiness gating before the setup script performs authenticated admin GraphQL operations (tenant/assets/liquidity). This reduces flaky first-run behavior (notably when Postgres/Redis take longer to become usable) and avoids known pagination limits when listing assets.

Changes:

  • Switch local Rafiki setup defaults from localhost to 127.0.0.1 to avoid IPv6 localhost resolution issues on Node 18+.
  • Add configurable readiness polling and a new “admin GraphQL is answering signed requests” probe before creating/ensuring assets.
  • Add Docker Compose healthchecks for Postgres/Redis and gate Rafiki containers on those checks; align asset pagination first with Rafiki’s cap.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
local/scripts/rafiki-setup.js Adds readiness configuration, admin-API readiness probe, safer defaults for endpoints, and reduces asset list pagination to 100.
local/redis.yaml Adds a Redis container healthcheck to support health-based dependency gating.
local/rafiki.yaml Updates depends_on to wait for Postgres/Redis to be healthy before starting Rafiki services.
local/postgres.yaml Adds a Postgres healthcheck to prevent dependent services from starting before DB is accepting connections.

Comment thread local/scripts/rafiki-setup.js Outdated
MihaiAndrei98 and others added 2 commits July 3, 2026 11:48
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@bosbaber bosbaber requested review from MihaiAndrei98 and Tymmmy July 3, 2026 09:12
@bosbaber bosbaber marked this pull request as ready for review July 3, 2026 09:13
@bosbaber bosbaber merged commit 9dc69de into main Jul 3, 2026
14 checks passed
@bosbaber bosbaber deleted the stephan/int1-671 branch July 3, 2026 09:22
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.

3 participants