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

add metadata to agones webhook autoscaler request #3957

Merged

Conversation

swermin
Copy link
Contributor

@swermin swermin commented Aug 20, 2024

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
/kind release

What this PR does / Why we need it:
This PR extends the webhook autoscaler with metadata, so that the the service retrieving the request can use the lables/annotations to do the calculation

Which issue(s) this PR fixes:
Closes #3951

Special notes for your reviewer:

Copy link

google-cla bot commented Aug 20, 2024

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.

@github-actions github-actions bot added kind/feature New features for Agones size/S labels Aug 20, 2024
@agones-bot
Copy link
Collaborator

Build Failed 😭

Build Id: 5ade9d2e-d20e-4cad-b76b-697960ab7ff0

Status: FAILURE

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

@swermin swermin force-pushed the feature/extend-webhook-autoscaler branch from a970b12 to 9ec84ce Compare August 24, 2024 18:32
Copy link
Collaborator

@igooch igooch 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. Could you please also add unit and e2e tests?

@gongmax
Copy link
Collaborator

gongmax commented Sep 19, 2024

@swermin kindly ping on this, could you resolve the conflicts and address the above comments?

@swermin
Copy link
Contributor Author

swermin commented Sep 20, 2024

Yes ofc! I have unit tests ready and just left with the e2e tests. I’ll push the current changes and focus on the e2e tests today and this weekend if needed!

@swermin swermin force-pushed the feature/extend-webhook-autoscaler branch from 9ec84ce to f56ba00 Compare September 22, 2024 19:28
@agones-bot
Copy link
Collaborator

Build Failed 😭

Build Id: 166b3f1b-5297-4b2a-bc9b-3b0ec925abe5

Status: FAILURE

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

@agones-bot
Copy link
Collaborator

Build Failed 😭

Build Id: 984531ec-7bcc-4fa4-bf36-089d5719a947

Status: FAILURE

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

@swermin
Copy link
Contributor Author

swermin commented Sep 24, 2024

@igooch do you have any good suggestions on how to do the e2e tests for this?
Current default webhook autoscaler is using the example image to test the scaling. I feel like adding support in that image feels a bit weird but I have no good idea on how to add something

@swermin swermin force-pushed the feature/extend-webhook-autoscaler branch from b9ab8fd to 8d0c86a Compare September 24, 2024 18:05
@agones-bot
Copy link
Collaborator

Build Failed 😭

Build Id: 0ef393db-4a59-403f-8729-4a86e54fb6d3

Status: FAILURE

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

@igooch
Copy link
Collaborator

igooch commented Oct 8, 2024

I just got back from being out of office, so I'm still catching up.

For the e2e tests, do you need to make changes to examples/autoscaler-webhook/main.go? Depending on the test you may be able to simply add MetaData to the default similar to https://github.com/googleforgames/agones/blob/c26f7371980418b56b816b13d265c9cc9d092f32/test/e2e/fleetautoscaler_test.go#L549C14-L549C38. If you do need to make changes to the examples/autoscaler-webhook/main.go, then a maintainer will need to build and push a new example autoscaler webhook image with the changes. That being said, it looks like the unit test is failing.

From the most recent build:

        	Test:       	TestApplyWebhookPolicyWithMetadata
        	            	actual  : 5
        	            	expected: 11
        	Error:      	Not equal: 
        	Error Trace:	/go/src/agones.dev/agones/pkg/fleetautoscalers/fleetautoscalers_test.go:618
    fleetautoscalers_test.go:618: 
--- FAIL: TestApplyWebhookPolicyWithMetadata (0.01s)

You'll need to run ~/agones/build$ make gen-crd-code to generate the deepcopy for pkg/apis/autoscaling/v1/fleetautoscaler.go, but even with that the test is still failing, so there's another issue going on.

@swermin swermin force-pushed the feature/extend-webhook-autoscaler branch from 8d0c86a to 9e74cc5 Compare October 21, 2024 19:04
@agones-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 00518f36-9edb-49bc-8c2a-b755dd8f48d1

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/3957/head:pr_3957 && git checkout pr_3957
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.45.0-dev-9e74cc5

@igooch
Copy link
Collaborator

igooch commented Dec 13, 2024

/gcbrun

@agones-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: eb8ecbc4-2d69-463d-befa-65337072b6f2

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/3957/head:pr_3957 && git checkout pr_3957
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.46.0-dev-2b8baf3

@@ -374,6 +374,8 @@ type FleetAutoscaleRequest struct {
Namespace string `json:"namespace"`
// The Fleet's status values
Status v1.FleetStatus `json:"status"`
// Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Super late to this party, but new additions will need a feature shortcode. See https://agones.dev/site/docs/contribute/#within-a-page for an example.

Also an addition here: https://github.com/googleforgames/agones/blob/main/site/content/en/docs/Guides/feature-stages.md?plain=1#L41 (also feature shortcode - may need to copy the whole table).

This is because docs get published intermediately, so we need to hold back documentation on unreleased features.

@markmandel
Copy link
Collaborator

Added a note on the issue as well, but my suggestion is that we let this PR through as is (with the above docs changes), and then follow up with e2e test PR.

@swermin
Copy link
Contributor Author

swermin commented Feb 3, 2025

Added a note on the issue as well, but my suggestion is that we let this PR through as is (with the above docs changes), and then follow up with e2e test PR.

Biggest problem with the e2e test is that I need to specify a version of the container to use. So there is no way for me to do the change without having to do two different PRs (at least what I know of)

I tried multiple different ways of getting a e2e test in without having to separate the builds but I cannot seem to find a solution :(

@swermin swermin force-pushed the feature/extend-webhook-autoscaler branch 2 times, most recently from 0c9b515 to 315d70d Compare February 3, 2025 23:44
@swermin swermin requested a review from markmandel February 5, 2025 12:54
@@ -37,7 +37,8 @@ The current set of `alpha` and `beta` feature gates:
| [Rolling Update Fixes](https://github.com/googleforgames/agones/issues/3688) | `RollingUpdateFix` | Disabled | `Alpha` | 1.41.0 |
| [Multiple dynamic port ranges](https://github.com/googleforgames/agones/issues/1911) | `PortRanges` | Disabled | `Alpha` | 1.41.0 |
| [Port Policy None](https://github.com/googleforgames/agones/issues/3804) | `PortPolicyNone` | Disabled | `Alpha` | 1.41.0 |
| [Scheduled Fleet Autoscaling](https://github.com/googleforgames/agones/issues/3008) | `ScheduledAutoscaler` | Disabled | `Alpha` | 1.43.0 |
| [Scheduled Fleet Autoscaling](https://github.com/googleforgames/agones/issues/3951) | `ScheduledAutoscaler` | Disabled | `Alpha` | 1.43.0 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

feature shortcode here too please, and I think this will be good to go 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I missed that one, good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the feature gate here, how to I test it in a good way? You did mention that it may require me copying the whole table

@markmandel
Copy link
Collaborator

/gcbrun

@agones-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 5c7f95bc-ac04-420a-86c9-1cac805cf8f8

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/3957/head:pr_3957 && git checkout pr_3957
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.47.0-dev-b1d60cf

@@ -316,6 +316,8 @@ type FleetAutoscaleRequest struct {
Namespace string `json:"namespace"`
// The Fleet's status values
Status agonesv1.FleetStatus `json:"status"`
// Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata.
MetaData *metav1.ObjectMeta `json:"metadata,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤔 I'm looking at this again, and wondering if this should be all the ObjectMeta - which is a lot, and we copy a chunk of it here already (Name and Namespace for example) - so we are also duplicating some effort.

Should it just be labels and annotations? Do we need everything?

Admittedly, in the ticket it says "metadata" but in my head I thought of it as "labels and annotations" and didn't clarify.

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.

My initial thought was to just do labels and annotations, but it was ”easier” to add the whole metadata.
Now that you raising it it makes more sense to just have labels and annotations.
I’ll update this PR accordingly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While the object is still called MetaData we only ever copy over annotations, labels, and name. Do you want it to be more explicit in that the fields should be called Annotations and Labels?

if runtime.FeatureEnabled(runtime.FeatureFleetAutoscaleRequestMetaData) {
	faReq.Request.MetaData = &metav1.ObjectMeta{
		Name:        f.ObjectMeta.Name,
		Labels:      f.ObjectMeta.Labels,
		Annotations: f.ObjectMeta.Annotations,
	}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I knew that I did think of the whole metadata copying and the object itself being too big

Copy link
Collaborator

Choose a reason for hiding this comment

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

While the object is still called MetaData we only ever copy over annotations, labels, and name. Do you want it to be more explicit in that the fields should be called Annotations and Labels?

if runtime.FeatureEnabled(runtime.FeatureFleetAutoscaleRequestMetaData) {
	faReq.Request.MetaData = &metav1.ObjectMeta{
		Name:        f.ObjectMeta.Name,
		Labels:      f.ObjectMeta.Labels,
		Annotations: f.ObjectMeta.Annotations,
	}
}

Yeah - I think this is the way to go (Only having labels and Annotations on the Request struct, not the full ObjectMeta):

  1. We control then what is sent.
  2. People aren't wondering why the rest of ObjectMeta isn't populated anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a fair point, I’ve updated the code to reflect this

@swermin swermin force-pushed the feature/extend-webhook-autoscaler branch from b0aedbf to b819b17 Compare February 17, 2025 18:55
@@ -38,6 +38,9 @@ The current set of `alpha` and `beta` feature gates:
| [Multiple dynamic port ranges](https://github.com/googleforgames/agones/issues/1911) | `PortRanges` | Disabled | `Alpha` | 1.41.0 |
| [Port Policy None](https://github.com/googleforgames/agones/issues/3804) | `PortPolicyNone` | Disabled | `Alpha` | 1.41.0 |
| [Scheduled Fleet Autoscaling](https://github.com/googleforgames/agones/issues/3008) | `ScheduledAutoscaler` | Disabled | `Alpha` | 1.43.0 |
{{% feature publishVersion="1.48.0" %}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mid table items tend to render badly, you may need to copy the whole table. But I'll run it and we can see what it looks like in preview.

(make site-server will give you a local version if you would like to try it).

Copy link
Collaborator

Choose a reason for hiding this comment

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

image

https://1d43bbe-dot-preview-dot-agones-images.appspot.com/site/docs/guides/feature-stages/#feature-gates

Going to have to copy the whole block, but otherwise, I think this is good to go.

@markmandel
Copy link
Collaborator

/gcbrun

Thanks for your patience!

@agones-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: a29b3a1f-88f6-411f-ab57-37b08c7ad17a

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/3957/head:pr_3957 && git checkout pr_3957
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.48.0-dev-1d43bbe

@markmandel
Copy link
Collaborator

/gcbrun

@agones-bot
Copy link
Collaborator

Build Failed 😭

Build Id: 2e11f722-e322-4bd7-a76f-9579725cdde2

Status: FAILURE

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

@swermin
Copy link
Contributor Author

swermin commented Feb 24, 2025

I don’t understand why the build failed 🧐

@markmandel
Copy link
Collaborator

Looks like a flake in https://console.cloud.google.com/cloud-build/builds/2e11f722-e322-4bd7-a76f-9579725cdde2;step=26?project=agones-images submit-upgrade-test-cloud-build. @igooch you might want to look into that.

@agones-bot
Copy link
Collaborator

Build Failed 😭

Build Id: 50a3d4db-0e7a-438c-be30-3af541ecb9ad

Status: FAILURE

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

@igooch
Copy link
Collaborator

igooch commented Feb 24, 2025

We're looking into how to pipe through relevant logs to the build output without spamming the build output file. It looks like the issue was a failure to pull the build image:

2025/02/24 17:01:25 sdk-client-test on  sdk-client-test-dm5x8 has failed. Latest event: message Failed to pull image "us-docker.pkg.dev/agones-images/ci/sdk-client-test:1.42.0": rpc error: code = DeadlineExceeded desc = failed to pull and unpack image "us-docker.pkg.dev/agones-images/ci/sdk-client-test:1.42.0": failed to resolve reference "us-docker.pkg.dev/agones-images/ci/sdk-client-test:1.42.0": failed to do request: Head "https://us-docker.pkg.dev/v2/agones-images/ci/sdk-client-test/manifests/1.42.0": dial tcp 74.125.195.82:443: i/o timeout

But the image exists:

Screenshot 2025-02-24 at 10 56 53 AM

And can be pulled using docker:

me@me:~$ docker pull us-docker.pkg.dev/agones-images/ci/sdk-client-test:1.42.0
1.42.0: Pulling from agones-images/ci/sdk-client-test
688513194d7a: Already exists
bfb59b82a9b6: Already exists
efa9d1d5d3a2: Already exists
a62778643d56: Already exists
7c12895b777b: Already exists
3214acf345c0: Already exists
5664b15f108b: Already exists
0bab15eea81d: Already exists
4aa0ea1413d3: Already exists
da7816fa955e: Already exists
9aee425378d2: Already exists
daf4059f7961: Pull complete
Digest: sha256:60811eb6965ded7236dc76bea020d4a84250ecab7a3ca483c237207712bb97e2
Status: Downloaded newer image for us-docker.pkg.dev/agones-images/ci/sdk-client-test:1.42.0
us-docker.pkg.dev/agones-images/ci/sdk-client-test:1.42.0

So this looks to be a flake, although an odd one.

@igooch
Copy link
Collaborator

igooch commented Feb 24, 2025

/gcbrun

@agones-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: c5cbe07f-f6fd-47dd-92f1-a94e63d056a5

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/3957/head:pr_3957 && git checkout pr_3957
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.48.0-dev-de9f9f2

@markmandel markmandel merged commit 1e7a8e4 into googleforgames:main Feb 24, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New features for Agones size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend Webhook autoscaler to send fleet metadata with the request
5 participants