carlos / platform Public

Start health check follows redirects, so a force_ssl app never becomes healthy Issue closed

Claimed by claude~paul@keymail.dev 3 weeks ago

Found while moving Tito Pro (Rails) onto Tito's staging CARLOS (v0.34.11, fleet classic, app bae/tito-pro), 2026-11-10.

What happens

waitHealthy (internal/activator/backend_exec.go) does GET http://carlos/ over the instance socket with socketClient, an http.Client with no CheckRedirect. Go's client follows redirects by default.

Pro has config.force_ssl = true and no host authorization, so it answers 301 Location: https://carlos/. The client follows the redirect and starts a TLS handshake on the plain unix socket. Puma logs about 470 lines of HTTP parse error, malformed request ... Are you trying to open an SSL connection to a non-SSL Puma?, and the wake fails:

activator: wake tito-pro.bae.staging.platform.tito.io: start ...: instance not healthy within 2m0s: Get "https://carlos/": http: server gave HTTP response to HTTPS client

The generation is then stopped, and the always-on instance restarts, so it crash-loops (g17→g20 on box-1). The rollout also reports "the copy on the box did not match the release". That message is misleading, because the build is fine.

Over the same socket, Host: tito-pro.bae.staging.platform.tito.io returns 301 without X-Forwarded-Proto and 200 with X-Forwarded-Proto: https.

Tito Classic and Billing, which also use force_ssl, pass only by accident: their Rails host authorization returns 403 for Host: carlos before the SSL redirect runs.

waitHealthyAddr / waitHealthyAddrCtx (internal/activator/backend_unit.go) use a plain http.Client too, so the TCP path has the same behaviour.

Ask

  • Don't follow redirects in the health checks (CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }), so a 3xx counts as healthy under the documented "under 500" rule.
  • Probably also send X-Forwarded-Proto: https on the check, as the edge does on real requests, so apps take their normal path.
  • If socketClient is shared with anything that should follow redirects, give the health check its own client.
  • Ideally, report a health-check failure as a health-check failure, not as "the copy on the box did not match the release".

Why it matters

Every Rails app with force_ssl and no host authorization (the Rails default) fails to start as a rootfs app. Tito Pro on CARLOS is blocked on this. Tito chose to wait for a platform fix rather than add assume_ssl app-side.

Tracking on the Tito side: Linear PRO-6933.

Taken on branch health-check-no-redirects-845, commit ea91f292.

  • Both probes (waitHealthy on the socket, waitHealthyAddr on TCP) no longer follow redirects, so a 3xx counts as healthy under the "under 500" rule. They also send X-Forwarded-Proto: https, as the edge does on real requests. socketClient itself is unchanged: nextDue and the tests keep it.
  • The "copy on the box did not match the release" message had a separate cause. reasonWord (internal/rollout/events.go) matched the substring staging inside the host tito-pro.bae.staging.platform.tito.io. It now drops dotted names (hosts, addresses, versions) before it reads the text. Names inside paths are kept.
  • Tests reproduce the #845 error before the fix and pass after it.

The claim-wake probes in internal/host already use ErrUseLastResponse, so they are left alone. Astra review running; merge after CI. Reaching Tito's staging needs a release and roll.

Merged as 965e26f, not released. Tito Pro needs a release containing it, rolled to Tito's staging CARLOS (now v0.34.11). After that, the force_ssl app should wake with no change on the app side.

Released in v0.34.42 (published 2026-11-10 20:11Z; apt v0.34.42-1). Tito's staging CARLOS can update to it. CARLOS dev and flagship roll it later, on the release owner's schedule.

Correction: do not roll v0.34.42 to Tito's staging yet.

platform-c5 found #854, and I checked the code. Every release from v0.34.34 to v0.34.42 kills any nested unit instance whose hostname is over 40 bytes.

  • provision.InstanceID turns a host that long into _<22 bytes>-<16 hex>.
  • instancectl.UnitFamily (internal/instancectl/identity.go) checks that ID with execsandbox.ValidID, which requires a letter or digit first.
  • So ValidateStartIdentity returns EXEC-SANDBOX-MISMATCH, and the activator kills the unit it just started without logging why.

Tito Pro's host (37 bytes) would start, but imgproxy, billing and classic (over 40 bytes) would die. The fix is on fix-rootfs-jit-kill-854. Roll Tito's staging only to a release that carries it.

Superseding my v0.34.42 note: Tito's staging can update to v0.34.43. It carries the #845 fix and the #854 fix, so hosts over 40 bytes start again. It's live on CARLOS dev canary and flagship. Do not use any release from v0.34.34 to v0.34.42.