Skip to content

Add ERR_TUN_ACTIVE_TIMEOUT squid code for tunnel timeouts#12786

Merged
bryancall merged 4 commits intoapache:masterfrom
bryancall:add-tunnel-timeout-squid-code
Apr 13, 2026
Merged

Add ERR_TUN_ACTIVE_TIMEOUT squid code for tunnel timeouts#12786
bryancall merged 4 commits intoapache:masterfrom
bryancall:add-tunnel-timeout-squid-code

Conversation

@bryancall
Copy link
Copy Markdown
Contributor

@bryancall bryancall commented Jan 6, 2026

Problem

CONNECT tunnel timeouts were invisible in access logs -- only visible via DEBUG tags. Operators had no way to distinguish tunnel timeouts from other error conditions in log analysis.

Changes

  • Add ERR_TUN_ACTIVE_TIMEOUT squid code -- new SquidLogCode enum value ('T') and string mapping in Log.cc so access logs show crc=ERR_TUN_ACTIVE_TIMEOUT for timed-out CONNECT tunnels.
  • Set squid code on tunnel timeout -- in tunnel_handler_ssl_producer() and tunnel_handler_ssl_consumer(), set the code on VC_EVENT_ACTIVE_TIMEOUT.
  • Update traffic_logstats -- add the new code to both switch statements so tunnel timeouts count in the errors bucket instead of falling through.
  • Add autest -- tunnel_active_timeout.test.py with a Python CONNECT client that holds a tunnel idle to trigger the timeout, then verifies the log entry.

Testing

  • Autest: tunnel_active_timeout validates log output
  • CI (all 15 checks green)

Add new SquidLogCode to identify when CONNECT tunnels time out due to
active timeout. This makes tunnel timeouts visible in access logs via
the crc (cache result code) field.

Previously, tunnel timeouts were not distinguishable in logs - users
could only see them in DEBUG logs. Now the access log will show
crc=ERR_TUN_ACTIVE_TIMEOUT for timed-out tunnels.

Includes autotest to verify the squid code is logged correctly.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new squid log code ERR_TUN_ACTIVE_TIMEOUT to identify when CONNECT tunnels time out due to active timeout, making these events visible in access logs via the crc (cache result code) field.

Key Changes:

  • Add ERR_TUN_ACTIVE_TIMEOUT = 'T' enum value for tunnel active timeouts
  • Set the squid code in SSL tunnel handlers when VC_EVENT_ACTIVE_TIMEOUT occurs
  • Include comprehensive test coverage to verify the logging behavior

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
include/proxy/hdrs/HTTP.h Adds new ERR_TUN_ACTIVE_TIMEOUT enum value to SquidLogCode
src/proxy/http/HttpSM.cc Sets the squid code in SSL tunnel producer and consumer handlers on active timeout events
src/proxy/logging/Log.cc Updates the log field alias table to include the new squid code string mapping
tests/gold_tests/timeout/tunnel_timeout_client.py Provides test client that establishes CONNECT tunnel and holds it idle to trigger timeout
tests/gold_tests/timeout/tunnel_active_timeout.test.py Test case that verifies ERR_TUN_ACTIVE_TIMEOUT is logged for tunnel timeouts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/gold_tests/timeout/tunnel_timeout_client.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add proxy.config.log.max_secs_per_buffer=1 to force log flush
- Add delay test run to wait for log file to be written
- Remove unused 'import time' from client script
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/gold_tests/timeout/tunnel_timeout_client.py Outdated
@bryancall bryancall requested a review from masaori335 January 12, 2026 23:01
@bryancall
Copy link
Copy Markdown
Contributor Author

@bryancall make sure this change doesn't brake traffic_logstats

Add ERR_TUN_ACTIVE_TIMEOUT to both switch statements in logstats.cc
so tunnel timeouts are correctly counted in the errors bucket instead
of silently falling through the default case.

Clean up tunnel_timeout_client.py: remove unused time import and use
socket context manager instead of manual try/finally/close.
@bryancall
Copy link
Copy Markdown
Contributor Author

[approve ci autest 0 autest 1 rocky]

@bryancall bryancall merged commit 2baa396 into apache:master Apr 13, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this to For v10.2.0 in ATS v10.2.x Apr 13, 2026
@cmcfarlen cmcfarlen moved this from For v10.2.0 to Picked v10.2.0 in ATS v10.2.x Apr 15, 2026
@cmcfarlen
Copy link
Copy Markdown
Contributor

Cherry-picked to 10.2.x

cmcfarlen pushed a commit that referenced this pull request Apr 15, 2026
* Add ERR_TUN_ACTIVE_TIMEOUT squid code ('T') so CONNECT
  tunnel timeouts are visible in access logs via the crc
  field instead of only in DEBUG output.
* Set the code in tunnel_handler_ssl_producer() and
  tunnel_handler_ssl_consumer() on VC_EVENT_ACTIVE_TIMEOUT.
* Add the code to traffic_logstats switch statements so
  tunnel timeouts count in the errors bucket.
* Add autest with Python CONNECT client that triggers a
  tunnel timeout and verifies the log entry.

(cherry picked from commit 2baa396)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Picked v10.2.0

Development

Successfully merging this pull request may close these issues.

4 participants