Commit Graph
2 Commits
  • fix(runtime): reset node inbound traffic by node-side id (#6717)
    * fix(runtime): reset node inbound traffic by node-side id
    
    Remote.ResetInboundTraffic posted to the master's inbound id (ib.Id),
    while every other node-side inbound call resolves the id assigned by the
    node from the tag. The reset therefore hit an unrelated inbound or failed
    silently (warning only), so the panel reported success either way.
    
    Resolve the id through resolveRemoteID(ctx, ib.Tag) and fail before
    posting when the tag cannot be resolved.
    
    Fixes #6713
    
    * fix(job): list the inbound on the periodic-reset fake nodes
    
    Remote.ResetInboundTraffic now resolves the node-side id from the tag via
    panel/api/inbounds/list before posting resetTraffic. The fake nodes in
    periodic_traffic_reset_nodes_test.go answered that list with no obj, so the
    tag never resolved, no reset reached a node, and
    TestPeriodicResetReachesInboundNodesConcurrently failed (green on main, red
    after merging the node-side-id fix). Each fake node now lists the inbound it
    hosts, so the test again measures concurrent resets against a node shaped
    like a real one.
    
    ---------
    
    Co-authored-by: Кот <kot@zeroclaw.local>
    Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com>
  • fix(traffic): make a client reset reach every counter enforcing its quota
    Invariant: a client traffic reset zeroes every counter that enforces the
    client's quota - the master's, each hosting node's, and the local MTProto
    sidecar's. A node cuts a client on its own local counters, and the master
    adopts that verdict when both judged the same limits (#4917).
    
    Node counters: ResetClientTraffic tried the node once and dropped a
    failure ("nothing replays a reset"); BulkResetTraffic,
    ResetAllClientTraffics and ClientService.ResetAllTraffics never told the
    node at all. The node kept its pre-reset usage, switched the client off
    again on its next tick, and the master latched that - a client shown at
    zero usage stayed disabled.
    
    Every reset path now queues a node_pending_resets row per hosting node in
    its own transaction. It is delivered right after commit (per-client
    endpoint up to the push threshold, bulkResetTraffic above) and replayed by
    the node sync ahead of its snapshot, and dropped only once the node
    accepted it. While one is owed, the merge takes only that client's usage
    from the node, not its enable or limits. Deliveries to a node are
    serialized so a reset is not sent twice.
    
    Sidecar quota: BulkResetTraffic, ClientService.ResetAllTraffics and
    auto-renew zeroed the panel counters but not mtg's own quota counter, so
    the sidecar kept refusing a renewed or reset MTProto client. They now
    reset it too, scoped to the affected clients.