[PR #6219] [MERGED] fix(nodes): log the inbound the node snapshot removes centrally #6181

Closed
opened 2026-11-02 04:06:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6219
Author: @n0ctal
Created: 8/15/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @MHSanaei

Base: main ← Head: upstream-log-node-sweep


📝 Commits (1)

  • 5106cb2 fix(nodes): log the inbound the node snapshot removes centrally

📊 Changes

2 files changed (+53 additions, -0 deletions)

View changed files

📝 internal/web/service/inbound_node.go (+3 -0)
➕ internal/web/service/inbound_node_sweep_log_test.go (+50 -0)

📄 Description

Summary

The node-snapshot orphan sweep removes a central inbound and the traffic history of every client attached to it, and writes nothing to the log. This adds one warning naming the node, tag, id and port.

Why

When a node stops reporting an inbound, the master deletes the central row, its client_traffics rows and the per-node baselines. That is the correct behaviour — but it is invisible.

The practical consequence is that two very different situations look identical from the outside: an inbound that was created and then swept, and an inbound that never reached the node at all. Both end as "the inbound I just added is gone", with an empty log either way. Working out which one happened currently means reading setRemoteTraffic and reasoning about snapTags.

Every neighbouring branch in this function already logs — adoption conflicts, tag collisions, failed central creates. The one branch that destroys data is the quiet one.

Scope

  • internal/web/service/inbound_node.go: one logger.Warningf before the sweep deletes, after the existing dirty / empty-snapshot / kept-tag / unmanaged-tag guards, so it fires only when a removal actually follows.

No behaviour change, no new condition — the same rows are deleted as before.

Validation

  • New TestNodeSnapshotSweepLogsRemovedInbound drives a real snapshot that reports one of two node inbounds, asserts the other is actually swept (so the log assertion cannot pass vacuously), and then requires the tag and id to appear in the warning log.
  • Mutation-checked: with the log line removed the test fails with sweep removed inbound "in-31777" (id 1) without naming it in the log.
  • go build ./internal/..., go vet, golangci-lint run (0 issues), internal/web/service tests and make gen-check all clean.

Risk

Low. One log line on a path that already runs; nothing else changes. On a node that legitimately drops several inbounds at once this adds one warning per inbound — that seemed preferable to a summary line, since the point is to name exactly what was removed.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6219 **Author:** [@n0ctal](https://github.com/n0ctal) **Created:** 8/15/2026 **Status:** ✅ Merged **Merged:** 8/16/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `upstream-log-node-sweep` --- ### 📝 Commits (1) - [`5106cb2`](https://github.com/MHSanaei/3x-ui/commit/5106cb29cefe7f8a76b7eb185205b97f2dfcaf97) fix(nodes): log the inbound the node snapshot removes centrally ### 📊 Changes **2 files changed** (+53 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/inbound_node.go` (+3 -0) ➕ `internal/web/service/inbound_node_sweep_log_test.go` (+50 -0) </details> ### 📄 Description ## Summary The node-snapshot orphan sweep removes a central inbound and the traffic history of every client attached to it, and writes nothing to the log. This adds one warning naming the node, tag, id and port. ## Why When a node stops reporting an inbound, the master deletes the central row, its `client_traffics` rows and the per-node baselines. That is the correct behaviour — but it is invisible. The practical consequence is that two very different situations look identical from the outside: an inbound that was created and then swept, and an inbound that never reached the node at all. Both end as "the inbound I just added is gone", with an empty log either way. Working out which one happened currently means reading `setRemoteTraffic` and reasoning about `snapTags`. Every neighbouring branch in this function already logs — adoption conflicts, tag collisions, failed central creates. The one branch that destroys data is the quiet one. ## Scope - `internal/web/service/inbound_node.go`: one `logger.Warningf` before the sweep deletes, after the existing `dirty` / empty-snapshot / kept-tag / unmanaged-tag guards, so it fires only when a removal actually follows. No behaviour change, no new condition — the same rows are deleted as before. ## Validation - New `TestNodeSnapshotSweepLogsRemovedInbound` drives a real snapshot that reports one of two node inbounds, asserts the other is actually swept (so the log assertion cannot pass vacuously), and then requires the tag and id to appear in the warning log. - Mutation-checked: with the log line removed the test fails with `sweep removed inbound "in-31777" (id 1) without naming it in the log`. - `go build ./internal/...`, `go vet`, `golangci-lint run` (0 issues), `internal/web/service` tests and `make gen-check` all clean. ## Risk Low. One log line on a path that already runs; nothing else changes. On a node that legitimately drops several inbounds at once this adds one warning per inbound — that seemed preferable to a summary line, since the point is to name exactly what was removed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:56 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6181
No description provided.