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

Make Alpha & Beta CRD declaration consistent. #2982

Merged
merged 2 commits into from
Feb 23, 2023

Conversation

markmandel
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:

We realised that with the CRD schema application being hidden behind a feature flag in the helm CRD yaml, then if the feature flag was turned off, an end user wouldn't get a validation error since the values passed in would be pruned by the K8s control plane.

To make thins consistent across Alpha CRD values:

  • Alpha & Beta schemas are always available within the CRD definitions.
  • Validation checks are in place for the feature flag (no change needed)
  • Alpha & Beta CRD values are pointers, so they can be nullable (this required a change in Eviction handling and ApiHooks interface)
  • Some general cleanup of comments and descriptions in the schema.

Which issue(s) this PR fixes:

Special notes for your reviewer:

@markmandel markmandel added the kind/cleanup Refactoring code, fixing up documentation, etc label Feb 18, 2023
pkg/apis/agones/v1/apihooksfake.go Show resolved Hide resolved
@@ -293,7 +293,7 @@ type GameServerStatus struct {
// +optional
Players *PlayerStatus `json:"players"`
// (Alpha, SafeToEvict feature flag) Eviction specifies the eviction tolerance of the GameServer.
Eviction Eviction `json:"eviction,omitempty"`
Eviction *Eviction `json:"eviction,omitempty"`
Copy link
Member Author

Choose a reason for hiding this comment

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

@zmerlynn just noting I made this a pointer to be consistent with all other Alpha/Beta properties added to a CRD.

(I can't find the best practice doc I originally referenced for this approach.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I saw that the others were but actually didn't understand why. It makes sense if they're nullable, but this field doesn't need to be nullable, I don't think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Aha, found the reference I was looking for:
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#optional-vs-required

Having it be a non pointer means that if the feature flag is off, there is still some kind of data stored in etcd (probably a lot of empty strings, since that's the default). Whereas if it's a pointer, there is nothing to serialise/deserialise.

Copy link
Member Author

@markmandel markmandel Feb 21, 2023

Choose a reason for hiding this comment

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

Actually, this is an optional field no -- I mean, the end user doesn't have to set it? So we should probably mark it as such.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I was just about to point out that by those conventions, we should add the +optional as well. But the concept LGTM - will give this a more thorough review in a bit (catching up).

Copy link
Member Author

Choose a reason for hiding this comment

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

All good - no rush. I'll add in the +optional here as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I approved but would like to see this before it goes in. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 1fd9f5dd-abe3-48b1-bc24-55855a00a87e

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

@google-oss-prow google-oss-prow bot added the lgtm label Feb 22, 2023
@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

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

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

We realised that with the CRD schema application being hidden behind a
feature flag in the helm CRD yaml, then if the feature flag was turned
off, an end user wouldn't get a validation error since the values passed
in would be pruned by the K8s control plane.

To make thins consistent across Alpha CRD values:

* Alpha & Beta schemas are always available within the CRD definitions.
* Validation checks are in place for the feature flag (no change needed)
* Alpha & Beta CRD values are pointers, so they can be nullable (this
required a change in Eviction handling and ApiHooks interface)
* Some general cleanup of comments and descriptions in the schema.
@google-oss-prow
Copy link

New changes are detected. LGTM label has been removed.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 692c3738-2383-4a5c-a0f9-8a008844d935

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

@markmandel
Copy link
Member Author

Oh no, too many concurrent builds, never became the older PR in queue.

Finished Step #21 - "e2e-wait-to-become-leader"
ERROR
ERROR: build step 21 "gcr.io/cloud-builders/gcloud" failed: context deadline exceeded

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: b8c07c90-8488-423f-9a3b-e2f0be3888ba

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/2982/head:pr_2982 && git checkout pr_2982
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.30.0-39f8c83-amd64

@markmandel markmandel enabled auto-merge (squash) February 23, 2023 17:16
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 3f5c0caf-078c-4d77-ab3b-149237dbdded

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/2982/head:pr_2982 && git checkout pr_2982
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.30.0-1d10617-amd64

@markmandel markmandel merged commit ba0ddbb into googleforgames:main Feb 23, 2023
@markmandel markmandel deleted the cleanup/remove-schema-skip branch February 23, 2023 18:43
@Kalaiselvi84 Kalaiselvi84 added this to the 1.30.0 milestone Feb 28, 2023
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 size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants