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

GraceTermination when GameServer get deleted #3141

Merged
merged 2 commits into from May 11, 2023

Conversation

qizichao-dm
Copy link
Contributor

What type of PR is this?

Uncomment only one /kind <> line, press enter to put that in a new line, and remove leading whitespace from that line:

/kind breaking

/kind bug

/kind cleanup
/kind documentation
/kind feature
/kind hotfix

What this PR does / Why we need it:
Current SDKGracefulTermination implementation uses gsStateChannel which get updated in sendGameServerUpdate. However, when GameServer gets deleted (e.g. when fleet updates), sendGameServerUpdate will not be triggered because updateState() will skip update in this case (gs.IsBeingDeleted() returns true). Therefore SDK server will blocks even SDK.Shutdown() has been called.

This PR solves the issue by explicitly updating gsStateChannel when

  • GS is being deleted
  • Current SDK server state is Shutdown
  • State of GS is not Shutdown.

Which issue(s) this PR fixes:

Closes #

Special notes for your reviewer:

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 1fa68d38-e847-40bf-bee1-fa9f19b9ac04

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 788d61e7-4308-4d5f-9d7d-b4fbfbe60c7a

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: e5618895-80e0-44f7-82a3-e2d4ea62af87

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

@zmerlynn zmerlynn self-assigned this May 8, 2023

// Explicitly update gsStateChannel if current state is Shutdown since sendGameServerUpdate will not triggered.
if runtime.FeatureEnabled(runtime.FeatureSDKGracefulTermination) {
if s.gsState == agonesv1.GameServerStateShutdown && gs.Status.State != agonesv1.GameServerStateShutdown {
Copy link
Collaborator

Choose a reason for hiding this comment

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

LGTM, I think. Idiomatically this should all be the same if, i.e.:

if runtime.FeatureEnabled(runtime.FeatureSDKGracefulTermination) && s.gsState == agonesv1.GameServerStateShutdown && gs.Status.State != agonesv1.GameServerStateShutdown

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

@zmerlynn zmerlynn 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 contribution!

@aimuz
Copy link
Collaborator

aimuz commented May 9, 2023

I'm glad someone solved this problem

@google-oss-prow google-oss-prow bot added size/XS and removed size/S labels May 9, 2023
@qizichao-dm qizichao-dm requested a review from zmerlynn May 9, 2023 03:32
@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 03b9c684-c69c-41a9-b760-f6e9d08f6f09

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 37c4b061-2273-44c9-9771-9b41afa388b9

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 17986985-5d40-48e0-8d4b-e696327b6387

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

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: bc163ac8-2166-498d-9e9c-aa9837c14c4f

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/3141/head:pr_3141 && git checkout pr_3141
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.32.0-09fcc93-amd64

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 6775f5bf-e772-4905-a648-feb9c91f226e

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/3141/head:pr_3141 && git checkout pr_3141
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.32.0-75220a9-amd64

@google-oss-prow google-oss-prow bot added the lgtm label May 11, 2023
@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: qizichao-dm, zmerlynn
Once this PR has been reviewed and has the lgtm label, please assign markmandel for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@zmerlynn zmerlynn merged commit 83d77cb into googleforgames:main May 11, 2023
2 checks passed
igooch pushed a commit to igooch/agones that referenced this pull request May 15, 2023
Current SDKGracefulTermination implementation uses gsStateChannel which get updated in sendGameServerUpdate. However, when GameServer gets deleted (e.g. when fleet updates), sendGameServerUpdate will not be triggered because updateState() will skip update in this case (gs.IsBeingDeleted() returns true). Therefore SDK server will blocks even SDK.Shutdown() has been called.

This PR solves the issue by explicitly updating gsStateChannel when

* GS is being deleted
* Current SDK server state is Shutdown
* State of GS is not Shutdown.
zmerlynn added a commit to zmerlynn/agones that referenced this pull request May 16, 2023
@Kalaiselvi84 Kalaiselvi84 added the kind/bug These are bugs. label May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants