Skip to content

Commit 16b0438

Browse files
authored
Fix wrong protocol break handle logic (#182)
1 parent 1641294 commit 16b0438

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

pkg/accesslog/collector/protocols/http2.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (r *HTTP2Protocol) Analyze(connection *PartitionConnection, helper *Analyze
136136

137137
// if the protocol break, then stop the loop and notify the caller to skip analyze all data(just sending the detail)
138138
if protocolBreak {
139-
http2Log.Warnf("the HTTP/2 protocol break, maybe not tracing the connection from beginning, skip all data analyze in this connection, "+
139+
http2Log.Debugf("the HTTP/2 protocol break, maybe not tracing the connection from beginning, skip all data analyze in this connection, "+
140140
"connection ID: %d", http2Metrics.ConnectionID)
141141
helper.ProtocolBreak = true
142142
r.analyzer.OnProtocolBreak(connection, http2Metrics)
@@ -231,7 +231,7 @@ func (r *HTTP2Protocol) validateIsStreamOpenTooLong(connection *PartitionConnect
231231
return
232232
}
233233
if time.Since(host.Time(socketBuffer.StartTime())) > maxHTTP2StreamingTime {
234-
http2Log.Infof("detect the HTTP/2 stream is too long, split the stream, connection ID: %d, stream ID: %d, headers: %v",
234+
http2Log.Debugf("detect the HTTP/2 stream is too long, split the stream, connection ID: %d, stream ID: %d, headers: %v",
235235
metrics.ConnectionID, id, streaming.ReqHeader)
236236

237237
_ = r.analyzer.HandleWholeStream(connection, streaming)

pkg/accesslog/common/connection.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ func (c *ConnectionManager) Find(event events.Event) *ConnectionInfo {
244244
c.connections.Set(connectionKey, connection)
245245
if log.Enable(logrus.DebugLevel) {
246246
log.Debugf("building flushing connection, connection ID: %d, randomID: %d, role: %s, local: %s:%d, remote: %s:%d, "+
247-
"local address: %s, remote address: %s",
247+
"local address: %s, remote address: %s, protocol: %s",
248248
e.GetConnectionID(), e.GetRandomID(), socket.Role, socket.SrcIP, socket.SrcPort, socket.DestIP, socket.DestPort,
249-
localAddress.String(), remoteAddress.String())
249+
localAddress.String(), remoteAddress.String(), connection.RPCConnection.Protocol.String())
250250
}
251251
c.connectionPostHandle(connection, event)
252252
return connection
@@ -620,6 +620,18 @@ func (c *ConnectionManager) OnBuildConnectionLogFinished() {
620620
}
621621

622622
func (c *ConnectionManager) SkipAllDataAnalyzeAndDowngradeProtocol(conID, ranID uint64) {
623+
// setting connection protocol is break
624+
connectionKey := fmt.Sprintf("%d_%d", conID, ranID)
625+
data, exist := c.connections.Get(connectionKey)
626+
if exist {
627+
connection := data.(*ConnectionInfo)
628+
connection.ProtocolBreak = true
629+
} else {
630+
// setting to the protocol break map for encase the runner not starting building logs
631+
c.connectionProtocolBreakMap.Set(connectionKey, true, time.Minute)
632+
}
633+
634+
// setting the connection skip data upload
623635
var activateConn ActiveConnection
624636
if err := c.activeConnectionMap.Lookup(conID, &activateConn); err != nil {
625637
if errors.Is(err, ebpf.ErrKeyNotExist) {
@@ -637,16 +649,6 @@ func (c *ConnectionManager) SkipAllDataAnalyzeAndDowngradeProtocol(conID, ranID
637649
if err := c.activeConnectionMap.Update(conID, activateConn, ebpf.UpdateAny); err != nil {
638650
log.Warnf("failed to update the active connection: %d-%d", conID, ranID)
639651
}
640-
641-
connectionKey := fmt.Sprintf("%d_%d", conID, ranID)
642-
data, exist := c.connections.Get(connectionKey)
643-
if exist {
644-
connection := data.(*ConnectionInfo)
645-
connection.ProtocolBreak = true
646-
} else {
647-
// setting to the protocol break map for encase the runner not starting building logs
648-
c.connectionProtocolBreakMap.Set(connectionKey, true, time.Minute)
649-
}
650652
}
651653

652654
func getSocketPairFromConnectEvent(event events.Event) (*events.SocketConnectEvent, *ip.SocketPair) {

0 commit comments

Comments
 (0)