Skip to content

fix: Decrease log level for directpath warnings outside GCE#4139

Merged
lqiu96 merged 1 commit intogoogleapis:mainfrom
nimf:polite_log
Mar 17, 2026
Merged

fix: Decrease log level for directpath warnings outside GCE#4139
lqiu96 merged 1 commit intogoogleapis:mainfrom
nimf:polite_log

Conversation

@nimf
Copy link
Contributor

@nimf nimf commented Mar 13, 2026

Directpath is not available outside of GCE. When a Cloud service client has Directpath enabled, the users with clients outside of GCE receive this warning and it's not actionable.

@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Mar 13, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the logging behavior for DirectPath misconfigurations within the InstantiatingGrpcChannelProvider. The primary goal is to reduce noise by ensuring that warnings related to DirectPath's operational environment or credential requirements are only displayed when relevant, specifically when running on Google Compute Engine. This change improves the clarity and actionability of logged messages for developers.

Highlights

  • Refined DirectPath Misconfiguration Logging: The logDirectPathMisconfig method was updated to prevent logging warnings about DirectPath unavailability when the application is not running within a Google Compute Engine (GCE) environment.
  • Conditional Credential Warning: The warning for incorrect DirectPath credentials (ComputeEngineCredentials) is now only issued if the application is detected to be running on GCE, making the warning more contextually relevant.
  • Test Case Adjustment: A test case specifically for DirectPathMisconfigNotOnGCE was removed, and the DirectPathMisconfigWrongCredential test was updated to reflect the new GCE-dependent logging logic.
Changelog
  • gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
    • Modified logDirectPathMisconfig to return early if DirectPath XDS is not enabled.
    • Removed the warning for DirectPath unavailability when not on GCE.
    • Updated the credential misconfiguration warning to only trigger if isOnComputeEngine() is true.
  • gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java
    • Removed the testLogDirectPathMisconfigNotOnGCE test method.
    • Modified testLogDirectPathMisconfigWrongCredential to conditionally assert log messages only when isOnComputeEngine() is true.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the DirectPath misconfiguration logging to avoid warning about its unavailability when not running on a GCE environment. The changes in the production code look good and improve clarity. However, a test was modified in a way that removes the cleanup logic for a TransportChannel, which could lead to resource leaks. I've added a comment to address this in the test file.

@nimf
Copy link
Contributor Author

nimf commented Mar 13, 2026

@lqiu96 can I get a gcbrun on this, please?

@lqiu96
Copy link
Member

lqiu96 commented Mar 13, 2026

/gcbrun

@lqiu96
Copy link
Member

lqiu96 commented Mar 13, 2026

/gcbrun

@lqiu96
Copy link
Member

lqiu96 commented Mar 16, 2026

Showcase Error:

Error:  Failures: 
Error:    ITLongRunningOperation.testHttpJson_LROUnsuccessfulResponse_exceedsTotalTimeout_throwsDeadlineExceededException:187 Unexpected exception type thrown, expected: <java.util.concurrent.CancellationException> but was: <java.util.concurrent.ExecutionException>

Flaky showcase test. I will re-run showcase tests

@lqiu96
Copy link
Member

lqiu96 commented Mar 16, 2026

/gcbrun

@lqiu96
Copy link
Member

lqiu96 commented Mar 16, 2026

Upper bounds CI failure is known issue. Looks like Wes has a PR to try and address it: #4143

.contains(
"DirectPath is misconfigured. The DirectPath XDS option was set, but the attemptDirectPath option was not. Please set both the attemptDirectPath and attemptDirectPathXds options.");

if (InstantiatingGrpcChannelProvider.isOnComputeEngine()) {
Copy link
Member

@lqiu96 lqiu96 Mar 16, 2026

Choose a reason for hiding this comment

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

is it possible to use mockito-inline to mock this static method? IIUC, otherwise we're always skipping this in the test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I just kept it as it was in these tests. I thought the tests run in different environments.

Copy link
Member

Choose a reason for hiding this comment

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

We don't have dedicated tests to run on different environments (GCE) or tests to hit DirectPath.

I think we indirectly test these when we run the GraalVM checks (via Cloud Build) as they also run the unit tests. On second though, we probably do need to keep this check.

Copy link
Member

@lqiu96 lqiu96 left a comment

Choose a reason for hiding this comment

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

@blakeli0 Second pair of eyes for this PR

@blakeli0
Copy link
Contributor

When a Cloud service client has Directpath enabled, the users with clients outside of GCE receive this warning and it's not actionable.

I guess users outside of GCE should create a different client without direct path enabled? Are they trying to use the same client configuration for both GCE and non-GCE?

@igorbernstein2
Copy link
Contributor

When a Cloud service client has Directpath enabled, the users with clients outside of GCE receive this warning and it's not actionable.

I guess users outside of GCE should create a different client without direct path enabled? Are they trying to use the same client configuration for both GCE and non-GCE?

we don’t want to have a different client for directpath/cloudpath. And we don’t want our end users to know anything about directpath…it’s supposed to be an implementation detail

@nimf nimf changed the title fix: Do not warn directpath unavailability outside GCE fix: Decrease log level for directpath warnings outside GCE Mar 17, 2026
@nimf nimf force-pushed the polite_log branch 6 times, most recently from e359aa4 to d785023 Compare March 17, 2026 07:18
@blakeli0
Copy link
Contributor

/gcbrun

@lqiu96 lqiu96 merged commit c9651e7 into googleapis:main Mar 17, 2026
51 checks passed
lqiu96 pushed a commit that referenced this pull request Mar 17, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>2.68.0</summary>

##
[2.68.0](v2.67.0...v2.68.0)
(2026-03-17)


### Features

* Add client request duration metric.
([#4132](#4132))
([6a76397](6a76397))
* Add more attributes to golden signals metrics.
([#4135](#4135))
([59d0624](59d0624))
* **gax-httpjson:** add HttpJsonErrorParser utility
([#4137](#4137))
([a1b7565](a1b7565))
* **generator:** add extra allowed modules that will not be removed from
the monorepo if they are present
([#4124](#4124))
([774fe6e](774fe6e))
* **o11y:** introduce `gcp.client.repo` and `gcp.client.artifact`
attributes
([#4120](#4120))
([105f644](105f644))
* **o11y:** Introduce `rpc.system.name` and `rpc.method` in gRPC
([#4121](#4121))
([7ab6d2e](7ab6d2e))
* **o11y:** introduce server.port attribute
([#4128](#4128))
([56aa343](56aa343))


### Bug Fixes

* add null checks for ApiTracerFactory in ClientContext
([#4122](#4122))
([4b3dbe2](4b3dbe2))
* Decrease log level for directpath warnings outside GCE
([#4139](#4139))
([c9651e7](c9651e7))
* **gax-grpc:** add pick_first fallback to direct path service config
([#4143](#4143))
([b150fe9](b150fe9))
* Populate method level attributes in metrics recording
([#4149](#4149))
([7b7e6c9](7b7e6c9))
* suppress warnings in generated projects for non-idiomatic durations
([#4119](#4119))
([4206e6e](4206e6e))
* Use ServiceName + MethodName as the regex for Otel
([#2543](#2543))
([b9ae73f](b9ae73f))


### Documentation

* **hermetic_build:** fix config field name in readme
([#4130](#4130))
([a0c8f67](a0c8f67))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants