Skip to content

Fix OM gRPC open connection metric - #12132

Open
fat-catTW wants to merge 1 commit into
apache:masterfrom
fat-catTW:HDDS-17888-fix-grpc-open-connection-metric
Open

fat-catTW wants to merge 1 commit into
apache:masterfrom
fat-catTW:HDDS-17888-fix-grpc-open-connection-metric

Conversation

@fat-catTW

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

OM's S3 gRPC server counts active client connections through a transport filter. A TCP health check, port scan, or failed TLS handshake can terminate before the transport becomes ready. The filter previously decremented the connection count anyway, which caused NumOpenClientConnections to become negative.

This change decrements the count only when transportTerminated receives non-null attributes. It also changes NumOpenClientConnections from MutableCounterLong to MutableGaugeLong, so Prometheus exports it as a gauge rather than a counter. Regression tests cover both termination-before-ready and the normal ready-to-terminated lifecycle.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-17888

How was this patch tested?

mvn -pl :hdds-server-framework -am test \
  -Dtest=TestGrpcMetrics \
  -Dsurefire.failIfNoSpecifiedTests=false \
  -DskipShade -DskipRecon

Copilot AI balanced review requested due to automatic review settings November 23, 2026 08:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the connection-accounting and metric-reporting changes.

No open issues 🎉

What changed in this PR

This PR fixes connection accounting in OM’s S3 gRPC server so connections that terminate before becoming ready do not drive the open-connection metric below zero.

Changes:

  • Skip decrementing the connection count when termination attributes are null.
  • Change NumOpenClientConnections to a gauge for correct Prometheus reporting.
  • Add regression tests for early termination, the normal connection lifecycle, and the metric type.
File Description
hadoop-hdds/​framework/​src/​test/​java/​org/​apache/​hadoop/​ozone/​grpc/​metrics/​TestGrpcMetrics.java Tests gauge publication and connection lifecycle accounting.
hadoop-hdds/​framework/​src/​main/​java/​org/​apache/​hadoop/​ozone/​grpc/​metrics/​GrpcMetricsServerTransportFilter.java Guards decrements against termination before readiness.
hadoop-hdds/​framework/​src/​main/​java/​org/​apache/​hadoop/​ozone/​grpc/​metrics/​GrpcMetrics.java Uses MutableGaugeLong for the active connection count.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants