diff --git a/build/Makefile b/build/Makefile index 59448844af..1a5bdeaaf4 100644 --- a/build/Makefile +++ b/build/Makefile @@ -70,7 +70,7 @@ GS_TEST_IMAGE ?= us-docker.pkg.dev/agones-images/examples/simple-game-server:0.3 BETA_FEATURE_GATES ?= "AutopilotPassthroughPort=true&CountsAndLists=true&DisableResyncOnSDKServer=true" # Enable all alpha feature gates. Keep in sync with `false` (alpha) entries in pkg/util/runtime/features.go:featureDefaults -ALPHA_FEATURE_GATES ?= "PlayerAllocationFilter=true&PlayerTracking=true&RollingUpdateFix=true&PortRanges=true&PortPolicyNone=true&Example=true" +ALPHA_FEATURE_GATES ?= "FleetAutoscaleRequestMetaData=true&PlayerAllocationFilter=true&PlayerTracking=true&RollingUpdateFix=true&PortRanges=true&PortPolicyNone=true&Example=true" # Build with Windows support WITH_WINDOWS=1 diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 73fe392ea8..7c93ab44b0 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -274,7 +274,7 @@ steps: declare -A versionsAndRegions=( [1.28]=us-west1 [1.29]=europe-west1 [1.30]=asia-east1 ) # Keep in sync with (the inverse of) pkg/util/runtime/features.go:featureDefaults - featureWithGate="PlayerAllocationFilter=true&PlayerTracking=true&CountsAndLists=false&RollingUpdateFix=true&PortRanges=true&PortPolicyNone=true&DisableResyncOnSDKServer=false&AutopilotPassthroughPort=false&Example=true" + featureWithGate="FleetAutoscaleRequestMetaData=true&PlayerAllocationFilter=true&PlayerTracking=true&CountsAndLists=false&RollingUpdateFix=true&PortRanges=true&PortPolicyNone=true&DisableResyncOnSDKServer=false&AutopilotPassthroughPort=false&Example=true" featureWithoutGate="" # Use this if specific feature gates can only be supported on specific Kubernetes versions. diff --git a/install/helm/agones/defaultfeaturegates.yaml b/install/helm/agones/defaultfeaturegates.yaml index 38ab7703ad..3b1dcf38b0 100644 --- a/install/helm/agones/defaultfeaturegates.yaml +++ b/install/helm/agones/defaultfeaturegates.yaml @@ -20,6 +20,7 @@ CountsAndLists: true DisableResyncOnSDKServer: true # Alpha features +FleetAutoscaleRequestMetaData: false GKEAutopilotExtendedDurationPods: false PlayerAllocationFilter: false PlayerTracking: false diff --git a/pkg/apis/autoscaling/v1/fleetautoscaler.go b/pkg/apis/autoscaling/v1/fleetautoscaler.go index 14e96c4447..c4972cb73d 100644 --- a/pkg/apis/autoscaling/v1/fleetautoscaler.go +++ b/pkg/apis/autoscaling/v1/fleetautoscaler.go @@ -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"` } // FleetAutoscaleResponse defines the response of webhook autoscaler endpoint diff --git a/pkg/fleetautoscalers/fleetautoscalers.go b/pkg/fleetautoscalers/fleetautoscalers.go index 8663be99ad..9b29913544 100644 --- a/pkg/fleetautoscalers/fleetautoscalers.go +++ b/pkg/fleetautoscalers/fleetautoscalers.go @@ -30,6 +30,7 @@ import ( "github.com/pkg/errors" "github.com/robfig/cron/v3" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/uuid" @@ -172,6 +173,14 @@ func applyWebhookPolicy(w *autoscalingv1.WebhookPolicy, f *agonesv1.Fleet) (repl Response: nil, } + if runtime.FeatureEnabled(runtime.FeatureFleetAutoscaleRequestMetaData) { + faReq.Request.MetaData = &metav1.ObjectMeta{ + Name: f.ObjectMeta.Name, + Labels: f.ObjectMeta.Labels, + Annotations: f.ObjectMeta.Annotations, + } + } + b, err := json.Marshal(faReq) if err != nil { return 0, false, err diff --git a/pkg/util/runtime/features.go b/pkg/util/runtime/features.go index b32551b74a..dd723f6074 100644 --- a/pkg/util/runtime/features.go +++ b/pkg/util/runtime/features.go @@ -44,9 +44,12 @@ const ( //////////////// // Alpha features + // FeatureFleetAutoscaleRequestMetaData is a feature flag that enables/disables fleet metadata on webhook autoscaler request. + FeatureFleetAutoscaleRequestMetaData Feature = "FleetAutoscaleRequestMetaData" + // FeatureGKEAutopilotExtendedDurationPods enables the use of Extended Duration pods // when Agones is running on Autopilot. Available on 1.28+ only. - FeatureGKEAutopilotExtendedDurationPods = "GKEAutopilotExtendedDurationPods" + FeatureGKEAutopilotExtendedDurationPods Feature = "GKEAutopilotExtendedDurationPods" // FeaturePlayerAllocationFilter is a feature flag that enables the ability for Allocations to filter based on // player capacity. @@ -133,6 +136,7 @@ var ( FeatureDisableResyncOnSDKServer: true, // Alpha features + FeatureFleetAutoscaleRequestMetaData: false, FeatureGKEAutopilotExtendedDurationPods: false, FeaturePlayerAllocationFilter: false, FeaturePlayerTracking: false, diff --git a/site/content/en/docs/Reference/fleetautoscaler.md b/site/content/en/docs/Reference/fleetautoscaler.md index d0e06d82a7..5aab6e7cfb 100644 --- a/site/content/en/docs/Reference/fleetautoscaler.md +++ b/site/content/en/docs/Reference/fleetautoscaler.md @@ -254,6 +254,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. + MetaData *metav1.ObjectMeta `json:"metadata,omitempty"` } type FleetAutoscaleResponse struct {