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

If the user has specified cluster autoscaling behavior for their gameserver then don't overwrite it #2754

Merged

Conversation

roberthbailey
Copy link
Member

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:
This change allows the object metadata annotation that controls the cluster autoscaler behavior to be passed along through the pod template to the game server pod. Previously, the annotation was always set by Agones, which would override any attempt by a user to set this annotation.

This change allows game servers to mark themselves as being able to be preempted and removed by the cluster autoscaler, which allows the cluster autoscaler to compact nodes when there is space to downsize a cluster.

Which issue(s) this PR fixes:

Closes #2747

Special notes for your reviewer:

pod.ObjectMeta.Annotations["cluster-autoscaler.kubernetes.io/safe-to-evict"] = "false"
// (and evict the Pod in the process). Only set the value if it has not already
// been configured in the pod template (to not override user specified behavior).
if _, exists := pod.ObjectMeta.Annotations["cluster-autoscaler.kubernetes.io/safe-to-evict"]; !exists {
Copy link
Member

Choose a reason for hiding this comment

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

Should "cluster-autoscaler.kubernetes.io/safe-to-evict" be a const? Might make it a bit easier to read.

As a possible other simplification (suggesting a possible const):

if  _, exists := pod.ObjectMeta.Annotations[safeToEvicAnnotation]; !exists && gs.Spec.Scheduling == apis.Packed {
   pod.ObjectMeta.Annotations[safeToEvicAnnotation] = "false"
}

Make it one line? WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

I like that. I picked a name for the constant that was a bit longer but more closely matched the name used by the cluster autoscaler implementation (although they used "Key" instead of "Annotation" as the last part of their name which I found less descriptive).

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: e9390570-9b03-4c9a-9a3c-95858df11f11

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/2754/head:pr_2754 && git checkout pr_2754
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.tag=1.27.0-2432ccd-amd64

@roberthbailey roberthbailey force-pushed the autoscaler-annotation branch 2 times, most recently from 99c9a11 to b4ef919 Compare September 29, 2022 06:41
@google-oss-prow google-oss-prow bot added size/L and removed size/M labels Sep 29, 2022
@roberthbailey roberthbailey marked this pull request as ready for review September 29, 2022 06:41
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: fd9af2f2-0507-4cea-bb19-c86f072c13d2

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/2754/head:pr_2754 && git checkout pr_2754
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.tag=1.27.0-99c9a11-amd64

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 6d9ea271-937d-458a-a3ba-0293a4fa8a86

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/2754/head:pr_2754 && git checkout pr_2754
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.tag=1.27.0-b4ef919-amd64

gameplay by adding the annotation [`"cluster-autoscaler.kubernetes.io/safe-to-evict": "false"`](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#what-types-of-pods-can-prevent-ca-from-removing-a-node)
to the backing Pod.

However, if a gameserver can tolerate being evicted (generally in combination with setting an appropriate graceful termination period
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
However, if a gameserver can tolerate being evicted (generally in combination with setting an appropriate graceful termination period
However, if a gameserver can tolerate [being evicted](https://kubernetes.io/docs/concepts/scheduling-eviction/api-eviction/#how-api-initiated-eviction-works) (generally in combination with setting an appropriate graceful termination period

Nit: Linking back to K8s documentation so that "eviction" is clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 4a32c280-fa71-4d7a-852a-ad0149c1effa

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/2754/head:pr_2754 && git checkout pr_2754
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.tag=1.27.0-a754f31-amd64

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: markmandel, roberthbailey

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:
  • OWNERS [markmandel,roberthbailey]

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

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 2a2c0c73-586a-4ef5-84d3-9012f62e4a94

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/2754/head:pr_2754 && git checkout pr_2754
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.tag=1.27.0-cdccd6b-amd64

@roberthbailey roberthbailey merged commit acf760b into googleforgames:main Sep 30, 2022
@mangalpalli mangalpalli added this to the 1.27.0 milestone Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved kind/cleanup Refactoring code, fixing up documentation, etc lgtm size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow cluster autoscaler to scale down game server pods
4 participants