peerUpdate is work scheduled in response to a new peer->binding. We need to find out all the other peers that share a tunnel with the indicated peer, and then schedule a mapping update on each, so that they can find out about the new binding.
(peers []uuid.UUID)
| 1078 | // other peers that share a tunnel with the indicated peer, and then schedule a mapping update on |
| 1079 | // each, so that they can find out about the new binding. |
| 1080 | func (q *querier) peerUpdate(peers []uuid.UUID) error { |
| 1081 | q.logger.Debug(q.ctx, "batch querying peers that share tunnels", |
| 1082 | slog.F("num_peers", len(peers))) |
| 1083 | others, err := q.store.GetTailnetTunnelPeerIDsBatch(q.ctx, peers) |
| 1084 | if err != nil && !xerrors.Is(err, sql.ErrNoRows) { |
| 1085 | return xerrors.Errorf("get tunnel peer IDs batch: %w", err) |
| 1086 | } |
| 1087 | q.logger.Debug(q.ctx, "batch queried tunnel peers", |
| 1088 | slog.F("num_results", len(others))) |
| 1089 | q.mu.Lock() |
| 1090 | for _, other := range others { |
| 1091 | mk := mKey(other.PeerID) |
| 1092 | if _, ok := q.mappers[mk]; ok { |
| 1093 | q.mappingQ.enqueue(mk) |
| 1094 | } |
| 1095 | } |
| 1096 | q.mu.Unlock() |
| 1097 | return nil |
| 1098 | } |
| 1099 | |
| 1100 | // mappingQuery queries the database for all the mappings that the given peers should know about, |
| 1101 | // that is, all the peers that it shares a tunnel with and their current node mappings (if they |
no test coverage detected