Skip to content

fix: Varnish VCL no longer crashes with multiple projects (v1.18.3)#131

Open
jakwinkler wants to merge 1 commit into
mainfrom
fix/varnish-vcl-multiproject-v2
Open

fix: Varnish VCL no longer crashes with multiple projects (v1.18.3)#131
jakwinkler wants to merge 1 commit into
mainfrom
fix/varnish-vcl-multiproject-v2

Conversation

@jakwinkler

Copy link
Copy Markdown
Contributor

Supersedes #127 — that PR patched the probe only in lib/templates/varnish/default.vcl.tmpl, but the template actually rendered at runtime is the //go:embed-ed internal/varnish/templates/default.vcl.tmpl, so the probe stayed broken. This PR fixes both copies and is rebased on current main (v1.18.2).

What's wrong

With 2+ registered projects the shared magebox-varnish container crash-loops → 502 / 503:

  1. Unused backends → fatal compile error. buildVCLConfig emitted one backend per project, but the template only ever references DefaultBackend (set req.backend_hint = {{.DefaultBackend}}). Varnish 7.x treats a defined-but-unused backend as a fatal error (Unused backend <name>) → VCL won't compile → crash-loop → 502. Every backend was identical (host.docker.internal:8080) anyway; Nginx already routes per project by Host.
  2. Wrong health probe. Template used HEAD / expecting 301; Magento returns 302 → backend sick → 503. BackendConfig.ProbeURL (/health_check.php) was ignored.

Recurs on every magebox start / restart.

Fix

  • buildVCLConfig → a single magento backend, always.
  • Both templates (internal/varnish/templates/ and lib/templates/varnish/) probe GET /health_check.php expecting 200.
  • Removed the dead sanitizeName helper + its test, and the comment-only range block in vcl_recv.
  • Regression test asserts exactly one backend, no per-project backends, and the probe.

VERSION → 1.18.3, CHANGELOG updated. go test ./... green, go vet clean.

🤖 Generated with Claude Code

buildVCLConfig emitted one backend per project but the template only
referenced DefaultBackend, so Varnish 7.x aborted on the first unused
backend and crash-looped (502). The probe also used HEAD / expecting 301
while Magento returns 302 (503). Emit a single 'magento' backend (Nginx
routes per project by Host) and probe GET /health_check.php expecting 200.

Fixes both the embedded template (internal/varnish/templates) and the lib
copy. Supersedes #127 (which patched only the unused lib template).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

📦 PR build artifacts

Built from e051df8view run. Artifacts expire in 14 days.

Note: artifact download links require being signed in to GitHub with access to this repository.

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.

1 participant