fix(cmd): retry a rejected reload and tighten the drain lifecycle

Review findings on the standalone config reload:

- A rejected config is now retried on every check, because the cause can
  be outside the file, such as a secret file that is not mounted yet.
  Each distinct error is logged once. A read error and a build error are
  tracked apart, so one does not hide the other.
- A closed generation stops its drain timer, so the timer no longer
  holds the old gateway in memory until it fires.
- closeCurrent marks the generation retired before it closes, so a late
  request does not run on a closed gateway.
- -reload-drain-timeout must be positive. A zero value closed running
  requests at once.
- The listen-error path waits for the reloader before the close, the
  same as the signal path. The reloader does not build after ctx ends.
This commit is contained in:
2026-11-26 16:30:20 +00:00
parent 86520acc2f
commit 60029a047e
4 changed files with 130 additions and 36 deletions
+4 -2
View File
@@ -173,11 +173,13 @@ When the content changes, it builds a new gateway from the file. If that
succeeds, new requests go to the new gateway at once. Requests already
running finish on the old gateway, which then closes. A replaced gateway
that still has requests after `-reload-drain-timeout` closes anyway.
`-reload-drain-timeout` must be positive.
- **A bad file changes nothing.** A file that does not parse, has an
unknown key or fails validation is logged at error level. The old
gateway keeps serving. The binary tries again only when the content
changes, or on `SIGHUP`.
gateway keeps serving. The binary tries again on every check, because
the cause can be outside the file, such as a secret file that is not
mounted yet. It logs each distinct error once.
- **`SIGHUP` always rebuilds**, even when the content is unchanged. Use it
after you rotate a secret that a `file:/path` reference reads.
- **The check compares content, not timestamps.** A Kubernetes `ConfigMap`