Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: grpc issue (UNAUTHENTICATED errors against Cloud Spanner emulator in v1.45.0) #5224

Conversation

HannahShiSFB
Copy link
Contributor

fix of grpc/grpc#29233, which is caused by grpc/grpc#25586 which removed insecure channel.

Regardless whether Spanner connects to emulator or production server, gax-php always create a CredentialsWrapper (https://github.com/googleapis/gax-php/blob/v1.12.0/src/GapicClientTrait.php#L434) and add it to callstack (https://github.com/googleapis/gax-php/blob/v1.12.0/src/GapicClientTrait.php#L610).
When creating gRPC calls, GrpcTransport calls CredentialsWrapper (https://github.com/googleapis/gax-php/blob/v1.12.0/src/Transport/GrpcTransport.php#L258-L259) to setup a callback for auth token, which requires secure level to be equal or higher than GRPC_PRIVACY_AND_INTEGRITY which doesn’t work on an insecure channel.

Spanner/src/Connection/Grpc.php Outdated Show resolved Hide resolved
@HannahShiSFB HannahShiSFB force-pushed the UNAUTHENTICATED-errors-against-Cloud-Spanner branch from 76bbf39 to 0db265d Compare April 21, 2022 23:41
@saranshdhingra saranshdhingra changed the title fix grpc issue (UNAUTHENTICATED errors against Cloud Spanner emulator in v1.45.0) fix: grpc issue (UNAUTHENTICATED errors against Cloud Spanner emulator in v1.45.0) Apr 25, 2022
@saranshdhingra
Copy link
Contributor

Hi @HannahShiSFB
I went ahead and fixed some linting issues, to speed the process.
(Just an FYI)

@fqqdk
Copy link

fqqdk commented Apr 27, 2022

There is this part, where the array union operator is replaced with array_merge(), in Spanner/src/Connection/Grpc.php ie:

$grpcConfig = array_merge(
    $grpcConfig,
    $this->emulatorGapicConfig($config['emulatorHost'])
);

A similar change is also needed in vendor/google/cloud-pubsub/src/Connection/Grpc.php (line 118) (and maybe in other Grpc Connection classes)

@bshaffer
Copy link
Contributor

That's a good catch, otherwise behavior could change for some implementations!

@HannahShiSFB
Copy link
Contributor Author

There is this part, where the array union operator is replaced with array_merge(), in Spanner/src/Connection/Grpc.php ie:

$grpcConfig = array_merge(
    $grpcConfig,
    $this->emulatorGapicConfig($config['emulatorHost'])
);

A similar change is also needed in vendor/google/cloud-pubsub/src/Connection/Grpc.php (line 118) (and maybe in other Grpc Connection classes)

There are 5 emulators in google cloud: Spanner, Firestore, PubSub, Datastore, BigTable. They all have the same issue.
Spanner and BigTable have been fixed by this PR. After testing, I'll fix the other 3.

@jmleroux
Copy link

jmleroux commented May 2, 2022

Hello guys,
Is there any update about this PR? We are looking at it because it is blocking us from using the Firestore emulator.
We would be glad to help if needed. 😉

@bshaffer bshaffer merged commit e4caaa7 into googleapis:main May 2, 2022
@bshaffer
Copy link
Contributor

bshaffer commented May 2, 2022

Hi @jmleroux !

The changes here only effect Spanner. We will need to make additional changes for them to be added to Firestore, PubSub, Datastore, and BigTable. However, this can be done at any time (the changes here will not effect existing behavior).

EDIT: I've added the changes for the other relevant packages in #5250

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.

6 participants