Skip to content

Add readiness_probe to all service plugins, enabling service dependencies (#2915) - #2917

Merged
mikeland73 merged 1 commit into
jetify-com:mainfrom
jefft:jefft/plugin_readiness_probes-fix-2915
Sep 13, 2026
Merged

mikeland73 merged 1 commit into
jetify-com:mainfrom
jefft:jefft/plugin_readiness_probes-fix-2915

Conversation

@jefft

@jefft jefft commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds readiness_probe to mariadb, mysql, redis, valkey (using native CLI
ping commands), and apache, nginx (using http_get probes). PostgreSQL
already had one (pg_isready).

This enables consumers to use condition: process_healthy in their
depends_on configuration, ensuring downstream services do not start
until their dependencies are actually accepting connections.

Fixes (along with #2916) #2915

How was it tested?

First build a devbox with a working #2909 isolated #2906 mariadb plugin (unless those have been merged), plus this PR:

cd /tmp
git clone git@github.com:jetify-com/devbox.git devbox-2915
direnv allow /tmp/devbox-2915
cd devbox-2915
git remote add jefft git@github.com:jefft/devbox.git
git fetch jefft
git checkout -b merge-plugin-fixes main
git merge --no-edit jefft/jefft/nginx-plugin-fix-2908
git merge --no-edit jefft/jefft/mysql-plugin-ignore-etc-mysql
git merge --no-edit jefft/jefft/plugin_readiness_probes-fix-2915
devbox run build

Then to illustrate scripts waiting for their services to come up:

cat > /tmp/testhealth.sh <<'EOF'
#!/bin/bash -eu

if [[ -d /tmp/testhealth ]]; then
        ( cd /tmp/testhealth && devbox services down >/dev/null 2>&1 || : )
  rm -r /tmp/testhealth
fi
mkdir /tmp/testhealth
cd /tmp/testhealth

cat > devbox.json <<'EOF2'
{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/main/.schema/devbox.schema.json",
  "packages": [
    "mariadb@latest",
    "apache@latest",
    "nginx@latest",
    "redis@latest",
    "valkey@latest"
  ],
  "env": { 
    "HTTPD_PORT": "11101",
    "NGINX_WEB_PORT": "11102",
    "VALKEY_PORT": "11103"
  },
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}
EOF2
devbox services ls   # create devbox.d/* dirs

echo "port = $(( 10000 + RANDOM % 50000))" >> devbox.d/mariadb/my.cnf
cat > my_database_using_app <<'EOF2'
#!/bin/bash
# Connect to MariaDBD via unix socket as root.
sudo mariadb --show-warnings -u root --socket "$MYSQL_UNIX_PORT" -e "select 1;"
EOF2
chmod +x ./my_database_using_app

cat > process-compose.yml <<'EOF2'
version: "0.5"

processes:

  mariadb_tester:
    depends_on:
      mariadb:
        condition: process_healthy
    command: ./my_database_using_app

  apache_tester:
    depends_on:
      apache:
        condition: process_healthy
    command: curl http://localhost:11101

  nginx_tester:
    depends_on:
      nginx:
        condition: process_healthy
    command: curl http://localhost:11102

  valkey_tester:
    depends_on:
      valkey:
        condition: process_healthy
    command: valkey-cli -p $VALKEY_PORT ping

EOF2
which devbox
devbox services up
EOF

# Put our compiled version of devbox ahead of others in PATH
PATH=/tmp/devbox-2915/dist:$PATH bash /tmp/testhealth.sh

The *_tester dependent services now work, coming up (after a delay) as Completed::

jturner@jturner-desktop:/tmp/testhealth$ devbox services ls
Services running in process-compose:
PID            NAME                  NAMESPACE        STATUS           AGE        HEALTH        RESTARTS        EXIT CODE
1982981        mariadb_logs          default          Running          5s         -             0               0
1982980        redis                 default          Running          5s         Ready         0               0
1982983        apache                default          Running          5s         Ready         0               0
1982984        apache-access         default          Running          5s         -             0               0
1983151        mariadb_tester        default          Completed        0s         -             0               0
1983126        apache_tester         default          Completed        0s         -             0               0
1983127        valkey_tester         default          Completed        0s         -             0               0
1982982        nginx                 default          Running          5s         Ready         0               0
1982978        nginx-error           default          Running          5s         -             0               0
1982974        nginx-access          default          Running          5s         -             0               0
1982977        valkey                default          Running          5s         Ready         0               0
1982976        apache-error          default          Running          5s         -             0               0
1983125        nginx_tester          default          Completed        0s         -             0               0
1982973        mariadb               default          Running          5s         Ready         0               0
devbox_dependent_services.webm

Community Contribution License

All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.

By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.

…pendencies (jetify-com#2915)

Adds readiness_probe to mariadb, mysql, redis, valkey (using native CLI
ping commands), and apache, nginx (using http_get probes).  PostgreSQL
already had one (pg_isready).

This enables consumers to use `condition: process_healthy` in their
depends_on configuration, ensuring downstream services do not start
until their dependencies are actually accepting connections.

Fixes jetify-com#2915
@jefft
jefft force-pushed the jefft/plugin_readiness_probes-fix-2915 branch from 33593c1 to 5e4c2db Compare July 16, 2026 06:43
@mikeland73

Copy link
Copy Markdown
Collaborator

@claude ptal

@claude

claude Bot commented Sep 13, 2026

Copy link
Copy Markdown

Claude finished @mikeland73's task in 2m 33s —— View job


Claude finished reviewing this PR

Todo list:

  • Read trigger comment and gather context
  • Review changed files (readiness_probe additions in all 7 plugins)
  • Check probe config correctness per process-compose/service (mariadb, mysql, redis, valkey, apache, nginx, postgresql)
  • Post review feedback

Review

Small, focused change — adds readiness_probe blocks to the 6 service plugins that lacked one (postgresql already had pg_isready). I traced each probe against the corresponding env vars/plugin defaults to check they'll actually resolve:

  • mariadb/mysql (plugins/mariadb/process-compose.yaml:11-14, plugins/mysql/process-compose.yaml:14-17): mariadb-admin ping / mysqladmin ping are run with no explicit socket flag, but both plugins export MYSQL_UNIX_PORT (plugins/mariadb.json:9, plugins/mysql.json:9), which is the standard libmysqlclient env var for the default socket path, and mysqld/mariadbd are wrapped to listen on exactly that socket (plugins/mysql/flake.nix:18). So the bare command should correctly find the right instance without needing -h/--socket args.
  • redis/valkey (plugins/redis/process-compose.yaml, plugins/valkey/process-compose.yaml): redis-cli -p $REDIS_PORT ping / valkey-cli -p $VALKEY_PORT ping — straightforward, ports are already used the same way in the command: field just above. Also nice incidental fix: both files were missing a trailing newline before this PR; that's now fixed as a side effect.
  • apache/nginx (plugins/apache/process-compose.yaml:14-19, plugins/nginx/process-compose.yaml:11-16): http_get probes against ${HTTPD_PORT} / ${NGINX_WEB_PORT}, both of which have plugin-level defaults (plugins/apacheHttpd.json:10, plugins/nginx.json env block) and match the vars used elsewhere in the same files. Confirmed via the PR's own test run (video/output in the description) that these come up Ready and dependent _tester processes reliably wait and complete.
  • postgresql (plugins/postgresql/process-compose.yaml:11-14): just adds initial_delay_seconds: 2 to the existing pg_isready probe — YAML nesting is correct (sibling of exec:, not nested inside it).
  • Indentation/YAML structure checked on all 7 files — readiness_probe is correctly nested as a sibling of availability/command at the process level in every case.

Nothing blocking. Two very minor, non-blocking observations if you want to polish further (not required for merge):

  1. initial_delay_seconds is inconsistent across services (1s for the two http_get probes, 2s for the exec-based SQL/postgres probes, unset/0 for redis and valkey). Likely intentional given different startup costs, but worth a one-line comment if it's deliberate so future editors don't "fix" it into uniformity.
  2. None of the new probes set explicit period_seconds/failure_threshold/timeout_seconds, relying on process-compose defaults — fine given this mirrors the existing postgresql probe, just flagging in case you want tighter control over how long a dependent service waits before giving up.

Overall this looks correct, well-scoped, and the author already validated it end-to-end with a live devbox services up run showing dependent services correctly blocking on process_healthy. LGTM.

@mikeland73
mikeland73 merged commit 384c0d3 into jetify-com:main Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants