Repository navigation
fix(cli): a pass that outlasts the wait is not an unreachable greffer - #133
Conversation
`requests.ReadTimeout` is a `RequestException`, so the generic handler announced "cannot reach the local greffer API" for the one case where we demonstrably DID reach it: the request was accepted and the pass is running inside the greffer, holding the pass lock, on a deadline that is the client's and cancels nothing. It is the large or degraded fleet that hits this, which is precisely when an operator can least afford a wrong answer. A manager that accepts connections and then stalls costs 30s per instance in _mint alone, so ~61 due instances already exceed the 1800s wait -- and the operator was then sent hunting a down greffer while the renewal they asked for was proceeding normally. Now: ReadTimeout reports the truth (still running, a retry will say "already running" until it finishes, the outcome lands in the log as cert_renewal_tick) and exits 3, because "we stopped watching" is neither success nor failure and a wrapping script has to tell all three apart. Connect failures keep the old message -- never having reached it is a different fact and must not be laundered into "still running". --timeout makes the wait overridable, so a fleet that legitimately needs longer does not have to patch the CLI. It is a WAIT, not a budget: the help text says so, because the whole defect was mistaking one for the other.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5be24ae86f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "--timeout", | ||
| type=int, | ||
| metavar="SECONDS", | ||
| default=_RENEW_TIMEOUT_SECONDS, |
There was a problem hiding this comment.
Reject non-positive renewal timeouts
When an operator supplies --timeout 0 or a negative value, argparse accepts it, but requests/urllib3 raises a ValueError while constructing the timeout before any I/O occurs. Because the exception handlers only catch RequestException, the CLI emits a traceback instead of treating this as bad usage and returning the documented exit code 2; validate that the value is positive during argument parsing.
Useful? React with 👍 / 👎.
The flag added in the previous commit accepted `--timeout 0` and negatives.
requests raises ValueError while BUILDING the timeout, before any I/O, and
ValueError is not a RequestException -- so it escaped both handlers and the
operator got a traceback where this command documents exit 2.
Verified rather than assumed: requests.post(..., timeout=0) raises
ValueError("Attempted to set connect timeout to 0, ..."), and
isinstance(exc, requests.RequestException) is False.
Checked in the function rather than through an argparse `type=`, to match
the --force guard above it and keep main() returning its exit code instead
of raising SystemExit -- which is also what lets the tests assert on the
return value the way every other case here does.
Reported by Codex on greffer#133 (P2).
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d4f29b41a3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| timeout=_RENEW_TIMEOUT_SECONDS, | ||
| timeout=args.timeout, | ||
| ) | ||
| except requests.ReadTimeout: |
There was a problem hiding this comment.
Report a read timeout as an unknown outcome
When the local API stalls before dispatching this endpoint, or finishes the pass just as the response times out, ReadTimeout only establishes that the client received no response in time; it does not prove that the request was accepted or that a pass remains in progress. This branch therefore misleadingly promises that the pass is continuing and that a retry will return already running, although the retry may instead start a new pass. Keep the distinct exit code, but describe the outcome as indeterminate rather than definitely still running.
Useful? React with 👍 / 👎.
The previous commit swapped one overconfident claim for another. A ReadTimeout establishes exactly one thing: no response arrived in time. It does not establish that the request was dispatched, nor that a pass is running now -- the greffer may have stalled before reaching the endpoint, or finished the pass just as we gave up. So "the pass is continuing inside it, a retry will report already running" was wrong in the same way "cannot reach the local greffer" was wrong, just pointing the other direction. And it was the more dangerous wrongness: an operator who believed it would retry expecting a 409 and could instead start a SECOND pass over the fleet. The message now says UNKNOWN and enumerates the three real possibilities -- still running, finished, never started -- keeps the one thing that IS true (this deadline is the client's and cancels nothing), and names the trap: read cert_renewal_tick before retrying, because a retry against a finished pass starts a new one. _EXIT_STILL_RUNNING is renamed _EXIT_OUTCOME_UNKNOWN, since the name asserted the same false certainty. Reported by Codex on greffer#133 (P2), and it is the third time in this session that a fix of mine needed a follow-up review to catch what the fix itself introduced.
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Codex P2 from #131, deferred at the time because the two fixes it proposed —
raise the timeout, or expose async completion — were a design call rather than
a bug fix. This is the third option: stop lying about what happened.
requests.ReadTimeoutis aRequestException, so the generic handlerannounced "cannot reach the local greffer API" for the one case where we
demonstrably did reach it. The request was accepted; the pass is running
inside the greffer holding the pass lock; the deadline is the client's and
cancels nothing.
It is the large or degraded fleet that hits this, which is exactly when a wrong
answer costs most. A manager that accepts connections and then stalls burns 30s
per instance in
_mintalone, so ~61 due instances already exceed the 1800swait — and the operator was sent hunting a down greffer while the renewal they
asked for proceeded normally.
What changes
ReadTimeoutreports the truth and exits 3: still running, a retrywill answer "already running" until it finishes, and the outcome lands in the
log as
cert_renewal_tick. "We stopped watching" is neither success norfailure, and a wrapping script has to tell all three apart.
different fact and must not be laundered into "still running".
--timeoutmakes the wait overridable, so a fleet that legitimately needslonger doesn't have to patch the CLI. It is a wait, not a budget — the help
text says so explicitly, since mistaking one for the other was the whole
defect.
Not done here
An async-completion endpoint (submit → poll) is the other half of Codex's
suggestion and remains open. It is a real addition to the control API and worth
deciding on its own merits; this change makes the current synchronous shape
honest rather than pretending the problem is gone.
Three tests, each mutation-verified: dropping the
ReadTimeoutbranch andignoring
--timeouteach fail one. 143 pass across the renewal + CLI suites.Note
app/cli.pycarries one pre-existingE402(theall_migrationsimportbelow the constants) — present on main, untouched here; the new constant is
placed after it so the diff doesn't straddle it.