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

Replace grpcio with tonic #2112

Merged
merged 24 commits into from
Jun 24, 2021

Conversation

Jake-Shadle
Copy link
Contributor

/kind feature

What this PR does / Why we need it:
This PR replaces the Rust SDK's use of grpcio with tonic.

Which issue(s) this PR fixes:
Closes #1300

Special notes for your reviewer:
I'll leave inline review comments on the changes themselves, and comment in #1300 on why tonic is preferred.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: e23f165b-9168-455e-bcfd-5ef07ce18926

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

sdks/rust/Cargo.toml Show resolved Hide resolved
async-stream = "0.3"
http = "0.2"
prost = "0.7"
thiserror = "1.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This replaces error-chain, which has seen declining usage in the rust ecosystem due to its fairly confusing and heavy approach to errors. That being said, the current error usage is extremely minimal, and we could get rid of thiserror as well and just use a custom error, since it's only used to wrap grpc status messages anyways since the sdk protocol doesn't have its own error types at all.

Comment on lines +30 to +33
[dependencies.tokio]
version = "1.0"
default-features = false
features = ["sync", "time"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tonic is built on top of tokio which is (basically) the standard async runtime in the rust ecosystem.

Comment on lines +35 to +42
[dependencies.tonic]
version = "0.4"
default-features = false
features = [
"codegen",
"transport",
"prost",
]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tonic is a rust native GRPC stack built on top of tokio.

Comment on lines +44 to +50
[build-dependencies.tonic-build]
version = "0.4"
default-features = false
features = [
"prost",
"transport",
]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The common practice for tonic is to build the protocol buffers at build time, rather than checking the generated code into source, unlike the previous implementation. I can change this if needed.

sdks/rust/src/sdk.rs Outdated Show resolved Hide resolved
sdks/rust/src/sdk.rs Show resolved Hide resolved
sdks/rust/src/sdk.rs Outdated Show resolved Hide resolved
Comment on lines 90 to 100
pub fn ready(&self) -> Result<()> {
let req = sdk::Empty::default_instance();
let res = self.client.ready(req).map(|_| ())?;
Ok(res)
#[inline]
pub async fn ready(&mut self) -> Result<()> {
Ok(self.client.ready(empty()).await.map(|_| ())?)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just as with the Alpha client, tonic is async only, so just removed all of the sync methods.

sdks/rust/src/sdk.rs Outdated Show resolved Hide resolved
@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 4deaee5a-ab75-4a45-a3f6-267b1a6fa3d8

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 5db92ab6-cdf7-441a-8d17-0832201b6943

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 17301a23-5de1-4a9e-8a35-fae22c11f071

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: fb6e3535-f9a8-4d41-9c71-53a7a3b15637

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 9ae4e7dc-9c64-4a1d-957c-67921f6ab46d

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@Jake-Shadle
Copy link
Contributor Author

/assign @markmandel

@roberthbailey
Copy link
Member

It looks like the sdk conformance tests for rust are failing:

includes/sdk.mk:145: recipe for target 'run-sdk-conformance-no-build' failed
make[2]: *** [run-sdk-conformance-no-build] Error 1

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 0531b236-0c14-4d51-a7d7-9f8b1c73f7a9

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2112/head:pr_2112 && git checkout pr_2112
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.15.0-c254850

@sawagh sawagh added the feature-freeze-do-not-merge Only eligible to be merged once we are out of feature freeze (next full release) label Jun 1, 2021
@sawagh sawagh removed the feature-freeze-do-not-merge Only eligible to be merged once we are out of feature freeze (next full release) label Jun 9, 2021
@roberthbailey roberthbailey requested review from markmandel and removed request for roberthbailey and pooneh-m June 10, 2021 06:28
sdks/rust/src/sdk.rs Outdated Show resolved Hide resolved
sdks/rust/src/sdk.rs Outdated Show resolved Hide resolved
Copy link
Member

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

Thanks for the work! This overall looks like an improvement!

My only concern is that this breaks backward compatibility with the previous SDK -- how concerned are we about this? I'm not sure how many users of the Rust SDK we actually have, so it may be a non issue.

@Jake-Shadle
Copy link
Contributor Author

I considered API breakage not super important since the crate has never been published so no API compatibility promises had been made, though I tried not to go too crazy.

@markmandel
Copy link
Member

I considered API breakage not super important since the crate has never been published so no API compatibility promises had been made, though I tried not to go too crazy.

Yeah, I figure it's probably fine. Also you can always STILL use the previously published code, it doesn't stop working.

@roberthbailey do you have any thoughts on the backward compatibility side of things? I think it's fine, but just want to cover all bases.

@roberthbailey
Copy link
Member

@roberthbailey do you have any thoughts on the backward compatibility side of things? I think it's fine, but just want to cover all bases.

The only compatibility issues is between the game server and the sdk, which would be caught at compile time. The SDK <-> sidecar should remain the same, so this should be compatible across older and newer Agones releases.

Since you don't need to adopt a new SDK for a new agones release (unless it has new features that you need) I don't see any issues requiring folks to make some changes to their code to adopt a new sdk version. This is actually pretty similar to the process we go through when upgrading client-go .... older versions should work just fine with the k8s apiserver, but when we want the newer code, we pull it in and sometimes need to make changes to our code so that it still compiles and works with the updated libraries.

@markmandel
Copy link
Member

Since you don't need to adopt a new SDK for a new agones release (unless it has new features that you need) I don't see any issues requiring folks to make some changes to their code to adopt a new sdk version. This is actually pretty similar to the process we go through when upgrading client-go .... older versions should work just fine with the k8s apiserver, but when we want the newer code, we pull it in and sometimes need to make changes to our code so that it still compiles and works with the updated libraries.

Well said! I concur!

So there are some comments above for review - but to add an extra item, we should also update https://agones.dev/site/docs/guides/client-sdks/rust/ to include new documentation for the new SDK.

https://agones.dev/site/docs/contribute/#at-the-page-level feature shortcodes gives you the tools to be able to hide the new documentation until the next release as well.

The logs from CD runs are incredibly hard to read since they are just
intermixed with all tests, so I prefixed all of the print messages from
the rust example so I can actually read the output more easily.
documentation
Removed the auto health check task since that actually made health
checking meaningless since it's _supposed_ to be sent by the application
itself when it working properly, not automatically
This method should be better than the previous test/examples as the
health check will actually be canceled if the task/thread the health
check is owned by is canceled for any reason
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 48c95b18-c87c-4f58-a44d-5393e299fda1

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2112/head:pr_2112 && git checkout pr_2112
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.16.0-ed847f3

@Jake-Shadle
Copy link
Contributor Author

Sorry, I'm in CET so I rebased just before heading to bed, hopefully you can look at it relatively early your time to get it in, I will only be semi-available tomorrow since it's Midsommar.

@markmandel markmandel added kind/breaking Breaking change area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc labels Jun 24, 2021
@markmandel markmandel merged commit 3d88bef into googleforgames:main Jun 24, 2021
@roberthbailey roberthbailey added this to the 1.16.0 milestone Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc cla: yes kind/breaking Breaking change size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Review Rust gRPC ecosystem for Rust SDK
6 participants