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

C# SDK Cleanup & Nuget Package #1596

Merged
merged 13 commits into from
Jun 6, 2020
Merged

Conversation

rcreasey
Copy link
Collaborator

What type of PR is this?
/kind bug
/kind cleanup
/kind documentation
/kind feature

What this PR does / Why we need it:
Updates the C# SDK with the following:

  • Adds stubs for Nuget package publishing.
  • Updates the gRPC requirement to 2.28 due to timeout issues.
  • Adds an Interface to easily implement mock testing.
  • Removes the "baked-in" health checks and requires explicit Health pings on instanced clients.
  • Changes console output to use Microsoft logging classes.
  • Ran the code through a linter.

Which issue(s) this PR fixes:

Closes #1583

Special notes for your reviewer:
This will still require additional work on the Google side to provide necessary credentials to get the nuget package pushed to official repositories.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@rcreasey rcreasey changed the title Csharp nuget C# SDK Cleanup & Nuget Package May 29, 2020
@rcreasey
Copy link
Collaborator Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@rcreasey
Copy link
Collaborator Author

rcreasey commented May 29, 2020

To build this as a nuget package the command is straight forward:

dotnet pack csharp-sdk.csproj --configuration Release --include-source --output ./pkgs /p:Version=1.0.4
dotnet nuget push /Users/rcreasey/projects/public/agones/sdks/csharp/sdk/pkgs/AgonesSDK.1.0.4.symbols.nupkg <nuget repository credentials>

For further details: https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package-dotnet-cli

I've tested this internally on our private Nuget repositories and have been running sdk integrated game servers for the last two weeks.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: be26b4c7-6889-49b8-a213-d5dff5318608

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 2e597929-8cfb-48ca-8d6b-c1fb1e52b672

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

@markmandel
Copy link
Member

Looking at the logs, it looks like make run-sdk-command COMMAND=test SDK_FOLDER=csharp is failing (this might take a while to build, just letting you know)

Something in the SDK tests isn't working.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 6c575c63-ef77-42c8-978d-e46e1c9074b6

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/GoogleCloudPlatform/agones.git pull/1596/head:pr_1596 && git checkout pr_1596
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.7.0-16cd38f

@markmandel markmandel requested a review from pooneh-m May 29, 2020 19:03
@markmandel
Copy link
Member

A couple of quick questions:

Just to confirm, is this a breaking change in the SDK? I.e will old integrations still work with this when they upgrade, or will people need to change the code?

Updates the gRPC requirement to 2.28 due to timeout issues.

Can you expand more on this? Maybe this is something we should upgrade across the board.

@markmandel
Copy link
Member

Updates the gRPC requirement to 2.28 due to timeout issues.

Are there any issues with the generated code output? Doesn't look like there are, as the generated code wasn't touched, but just wanted to be sure.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 7471aa09-7604-4e47-bd1a-c4eadba4037a

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/GoogleCloudPlatform/agones.git pull/1596/head:pr_1596 && git checkout pr_1596
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.7.0-39ca617

@rcreasey
Copy link
Collaborator Author

rcreasey commented May 29, 2020

There should be no breaking changes to the gRPC update; there was an issue with our unit tests starting before the agones api endpoint was available (we're packing the dev server as a fixture and delayed the startup to test) and the stream connection wasn't attempting a retry properly. Instead, it was failing an exception in the grpc library with:

System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (111): Connection refused 127.0.0.1:9357

Updating it to the 2.28 release seemed to fix the issue (which was the stable release at the time we were testing).

No agones code gen required.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: ee5cf4b5-ba97-4b17-9ee0-194ea2749a8d

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/GoogleCloudPlatform/agones.git pull/1596/head:pr_1596 && git checkout pr_1596
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.7.0-fe8edb8

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 32677196-7c4d-4933-86ab-8125097f2404

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

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 664c52a8-f626-4cd8-a0b4-57d6364edc72

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/GoogleCloudPlatform/agones.git pull/1596/head:pr_1596 && git checkout pr_1596
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.7.0-6a8111c

@markmandel
Copy link
Member

@pooneh-m since you are our resident C# expert, would you mind taking a look at these changes?

@markmandel markmandel added area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc kind/feature New features for Agones labels Jun 1, 2020
sdks/csharp/sdk/AgonesSDK.cs Show resolved Hide resolved
}
catch (RpcException ex)
{
Console.Error.WriteLine(ex.Message);
//Should I rethrow the exception?
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is change in the behavior. I agree that this is how it should have been handled originally, but may break a customer use-case that is already depending on this behavior.
@markmandel would it be ok to suddenly throw exception GetGameServerAsync()? How other SDKs are handling this?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think it's reasonable to throw an exception here. I'm also assuming that in C#, exception throwing is the appropriate way to deal with errorrs?

For example, Go returns an error

The only maybe interesting part, is - do we want to throw the GRPC exception, or do we want to wrap it in our own exception type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, I forgot about this. Yeah, I figured surfacing the exception would be better than just sinking it like it was previously doing. Typically, libraries shouldn't do this and should surface it to the consuming callsite.

As for whether or not to make a custom AgonesException to wrap it in, I'll leave it up to you. I'm fine with handling a gRPC exception in my code.

Copy link
Contributor

Choose a reason for hiding this comment

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

If there is no dependency to this SDK that this change would break them, it looks good to me. I don't think we need to wrap the exception.

@pooneh-m
Copy link
Contributor

pooneh-m commented Jun 4, 2020

Thanks @rcreasey for the changes and for the fix.

@roberthbailey roberthbailey removed their request for review June 4, 2020 23:27
sdks/csharp/sdk/AgonesSDK.cs Outdated Show resolved Hide resolved
@rcreasey rcreasey requested a review from pooneh-m June 5, 2020 19:22
Copy link
Contributor

@pooneh-m pooneh-m 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 changes. The proposed change to RequestTimeoutSec looks good to me.

}
catch (RpcException ex)
{
Console.Error.WriteLine(ex.Message);
//Should I rethrow the exception?
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

If there is no dependency to this SDK that this change would break them, it looks good to me. I don't think we need to wrap the exception.

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pooneh-m, rcreasey

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-robot
Copy link

New changes are detected. LGTM label has been removed.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: ff2ec003-2944-4e98-a0ae-feb1aae11a83

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: c34abefd-1cf8-4d9a-86ca-1f8c40fb42db

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: e7488cd1-5ff9-4e44-a144-73a4fc2ac660

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

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 85824577-0585-4658-b19b-1b812b23f7e8

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/GoogleCloudPlatform/agones.git pull/1596/head:pr_1596 && git checkout pr_1596
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.7.0-94b8803

@pooneh-m pooneh-m merged commit 2486f54 into googleforgames:master Jun 6, 2020
@markmandel markmandel added this to the 1.7.0 milestone Jun 8, 2020
ilkercelikyilmaz pushed a commit to ilkercelikyilmaz/agones that referenced this pull request Oct 23, 2020
* C# SDK refactoring; preparing for a nuget package

* Updating c# sdk documentation

* Fixing csharp sdk tests.

* Updating nuget version

* Updating project version as well

* Version matching the nuspec file.

* Update sdks/csharp/sdk/AgonesSDK.cs

* Properly renaming the RequestTimeout property to RequestTimeoutSec
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 kind/feature New features for Agones size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HealthCheckLoop Never invoked in C# SDK
7 participants