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 simple-game-server to use context substitute for the infinite loop #3050

Merged
merged 3 commits into from
Apr 4, 2023
Merged

Fix simple-game-server to use context substitute for the infinite loop #3050

merged 3 commits into from
Apr 4, 2023

Conversation

oniku-2929
Copy link
Contributor

…op at main (#2208).

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:
for reducing simple game server cpu usage.
#2208

Which issue(s) this PR fixes:

Closes

Special notes for your reviewer:

@google-cla
Copy link

google-cla bot commented Mar 29, 2023

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

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: e260f53e-830d-4103-9036-5c5a13d46019

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/3050/head:pr_3050 && git checkout pr_3050
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.31.0-44fd452-amd64

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 hacking on this!

@@ -36,7 +36,8 @@ import (

// main starts a UDP or TCP server
func main() {
go doSignal()
sigCtx, sigCancel := context.WithCancel(context.Background())
Copy link
Member

Choose a reason for hiding this comment

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

Rather than keeping doSignal, could we simplify and remove that function, and instead do:

ctx := signals.NewSigKillContext()

And make a minor change to the section below (line 125) of:

	<-ctx.Done()
	os.Exit(0)

and we don' t need to worry about wrapping contexts or anything like that.

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@markmandel
I agree with that.
I'll fix it.

But var ctx is already used at the below lines to manage health context.

ctx, cancel := context.WithCancel(context.Background())
go doHealth(s, ctx)

So should we use sigCtx to manage signal context like the one below?

func main() {
	sigCtx := signals.NewSigKillContext()

        ~~~//other tasks
        
        <-sigCtx.Done()
	os.Exit(0)
}
//doSignal is erased.

Or should we rename ctx which is used to go doHealth(s, ctx) like healthCtx then keep using ctx on main like that?

func main() {
	ctx := signals.NewSigKillContext()

        ~~~
        healthCtx, cancel := context.WithCancel(context.Background())
	go doHealth(s, healthCtx)
        ~~~
        
        <-ctx.Done()
	os.Exit(0)
}
//doSignal is erased.

Copy link
Member

Choose a reason for hiding this comment

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

Or should we rename ctx which is used to go doHealth(s, ctx) like healthCtx then keep using ctx on main like that?

Either way, I don't mind. I'll leave the decision up to you 🤗

@markmandel
Copy link
Member

Also looking at the CLA failure - looks like you signed with your github account - this one doesn't have your CLA signed. But it looks like your personal email has signed the CLA, so we'll need you to rebase down commits with your personal email please.

@oniku-2929
Copy link
Contributor Author

oniku-2929 commented Mar 30, 2023

@markmandel

looking at the CLA failure

I'm sorry about that.

But it looks like your personal email has signed the CLA, so we'll need you to rebase down commits with your personal email please.

I just resigned my CLA on my GitHub account which was signed on my commit.
Can I fix the failure with that?

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: f99684ec-a166-45d6-957a-62f2368fd847

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/3050/head:pr_3050 && git checkout pr_3050
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.31.0-58043f4-amd64

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 2d0369fd-2428-4199-8963-0f5bf1527d82

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

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 this is great.

You will need to resolve the CLA issue. The best bet is to Git rebase your PR down to a single commit, and make sure the author is your gmail account, and force push it over the top of this branch.

You can see which accounts are passing and which aren't here: https://github.com/googleforgames/agones/pull/3050/checks?check_run_id=12403813562

These may be useful:

@markmandel
Copy link
Member

Also you can ignore the Agones bot failure, it's just being flaky.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 0cd09d02-bced-4097-958a-a7dfbaa0e472

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/3050/head:pr_3050 && git checkout pr_3050
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.31.0-2b872cc-amd64

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 60fef5ef-1693-4431-8bbf-262ac37d6c4f

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/3050/head:pr_3050 && git checkout pr_3050
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.31.0-db092ed-amd64

@oniku-2929
Copy link
Contributor Author

@markmandel

These may be useful:
https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
https://stackoverflow.com/questions/3042437/how-to-change-the-commit-author-for-a-single-commit

Thanks for providing the information.
I fixed my branch history by squashing my commits and dropping unrelated merges from the base branch.

It seems to pass the CLA check.

@google-oss-prow google-oss-prow bot added the lgtm label Apr 3, 2023
@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: markmandel, oniku-2929

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

@markmandel
Copy link
Member

Lovely!

@google-oss-prow
Copy link

New changes are detected. LGTM label has been removed.

@google-oss-prow google-oss-prow bot removed the lgtm label Apr 4, 2023
@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 04a4be1b-becf-44ad-b3d9-4a9a6e346f8b

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

@markmandel markmandel enabled auto-merge (squash) April 4, 2023 15:00
@zmerlynn zmerlynn changed the title Fix simaple-game-server to use context substitute for the infinite lo… Fix simple-game-server to use context substitute for the infinite lo… Apr 4, 2023
@zmerlynn zmerlynn changed the title Fix simple-game-server to use context substitute for the infinite lo… Fix simple-game-server to use context substitute for the infinite loop Apr 4, 2023
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 31254eb8-a3f9-40a0-93df-e32e65601889

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/3050/head:pr_3050 && git checkout pr_3050
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.31.0-569a380-amd64

@markmandel markmandel merged commit cc21505 into googleforgames:main Apr 4, 2023
@oniku-2929 oniku-2929 deleted the issue/2208 branch April 4, 2023 23:51
@Kalaiselvi84 Kalaiselvi84 added the kind/bug These are bugs. label Apr 10, 2023
@Kalaiselvi84 Kalaiselvi84 added this to the 1.31.0 milestone Apr 10, 2023
Kalaiselvi84 pushed a commit to Kalaiselvi84/agones that referenced this pull request Apr 11, 2023
…op at main (googleforgames#2208). (googleforgames#3050)

Co-authored-by: oniku2929 <o29n1ku2ku@gmail.com>
Co-authored-by: Mark Mandel <markmandel@google.com>
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.

4 participants