Repository navigation
Refuse new inbound calls while shutting down - #1003
JakeHedman wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1003 +/- ##
==========================================
+ Coverage 65.25% 71.94% +6.69%
==========================================
Files 51 48 -3
Lines 6588 9400 +2812
==========================================
+ Hits 4299 6763 +2464
- Misses 1915 2128 +213
- Partials 374 509 +135 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| // the sender can retry on another server. Re-INVITEs were handled above. | ||
| // The retry of a challenged INVITE is not a new call either: its call | ||
| // record is open, and the normal path below closes it. | ||
| if cm.mon.Health() == stats.HealthStopped && !cm.challengePending(cc.ID()) { |
There was a problem hiding this comment.
🟨 Unbound challenge bypasses shutdown admission
During shutdown, processInvite lets an unrelated INVITE through when its To-tag matches a pending challenge. newInbound accepts the supplied tag without checking that it belongs to that Call-ID and From-tag. A peer can start a new call on an otherwise authorized trunk while the server drains.
Was this helpful? React with 👍 or 👎 to provide feedback.
On SIGTERM the service waits for its calls to end, but it kept accepting new inbound INVITEs while it waited. A busy server could stay up until it was killed, and the calls still up at that point were dropped. A stopping service now answers 503 to an INVITE that would start a call, so that the sender can retry on another server. An INVITE that would get a new digest challenge is refused in the same way. An INVITE with valid credentials answers a challenge that was already sent, and is accepted. Re-INVITEs of calls in progress are not affected. The refusal is not stored in the rejected-INVITE cache. A cached answer is replayed before re-INVITEs and retries with credentials are recognized.
deb2768 to
df88b2d
Compare
On SIGTERM the service waits for its calls to end, but it keeps accepting new inbound INVITEs while it waits. A busy server may never empty, and the calls still up when the process is killed are dropped. Outbound already refuses new calls in this state (
createSIPParticipantchecksHealth()). Inbound did not.With this change, a stopping service answers 503 to an INVITE that would start a call, so the sender can retry on another server.
The check runs after the auth lookup, in two places:
AuthAccept: the INVITE is refused.AuthPassword: an INVITE that would get a new 407 is refused. An INVITE with valid credentials is accepted. The nonce is bound to the Call-ID and lives 30 s, so valid credentials answer a challenge that was already sent.Every other auth result is rejected or dropped as before. Re-INVITEs of calls in progress return before the auth lookup and are not affected.
Notes for review:
HealthStoppedonly.HealthUnderLoaddoes not refuse calls.hide_inbound_portis respected: only a sender that matched a trunk gets the 503.RespondAndDrop, so it is not stored in the rejected-INVITE cache. That cache is read before the re-INVITE check, so a cached 503 would also answer a later re-INVITE or a retry with credentials for the same Call-ID and From tag. The cost is that a sender that retries at the stopping server gets a new auth lookup and call record each time.server_errorwith the reasonshutting-down, the same class as calls ended by shutdown. Say if you preferindeterminate.TestInboundShutdowncovers, on a stopping service: a new INVITE, a new INVITE on a password trunk, an inbound re-INVITE, an outbound re-INVITE, and an INVITE that was challenged before the shutdown (a repeat without credentials is refused, the retry with credentials is accepted).This is the change asked for in #962, which was folded into #963. #770 has an INVITE check together with an OPTIONS change. This PR is only the INVITE part, on current main.