Skip to content

Commit

Permalink
Merge branch 'main' into bugfixes/delays-awaiting-pod-ips
Browse files Browse the repository at this point in the history
  • Loading branch information
lacroixthomas authored Mar 4, 2025
2 parents f55f2e1 + 0cb8e22 commit 37dcef7
Show file tree
Hide file tree
Showing 13 changed files with 233 additions and 14 deletions.
13 changes: 6 additions & 7 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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&GKEAutopilotExtendedDurationPods=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&ScheduledAutoscaler=true&Example=true"
ALPHA_FEATURE_GATES ?= "PlayerAllocationFilter=true&FleetAutoscaleRequestMetaData=true&PlayerTracking=true&RollingUpdateFix=true&PortRanges=true&PortPolicyNone=true&ScheduledAutoscaler=true&Example=true"

# Build with Windows support
WITH_WINDOWS=1
Expand Down Expand Up @@ -514,9 +514,8 @@ build-required-src-dist:
# According to the docker documentation, to build the images for ARM64 arch CPU
# we would need to use buildx command which uses builder https://docs.docker.com/desktop/multi-arch/
# We primarily need this for M1 Macs, see: https://medium.com/geekculture/docker-build-with-mac-m1-d668c802ab96
# Making this command optional (using - as prefix) because it will fail once built for the first time, so we ignore failures.
create-arm64-builder:
-docker buildx create --name $(BUILDX_ARM64_BUILDER)
docker buildx use $(BUILDX_ARM64_BUILDER) || docker buildx create --name $(BUILDX_ARM64_BUILDER) --use

# Build the image for the gameserver controller
build-controller-image: build-controller-image-amd64
Expand Down Expand Up @@ -570,8 +569,8 @@ build-agones-sdk-binary-windows: $(ensure-build-image)
$(GO_BUILD_WINDOWS_AMD64) \
-o $(go_build_base_path)/cmd/sdk-server/bin/sdk-server.windows.amd64.exe $(go_rebuild_flags) $(go_version_flags) $(agones_package)/cmd/sdk-server

ensure-windows-buildx-%:
-docker buildx create --name=$(BUILDX_WINDOWS_BUILDER)-$*
ensure-windows-buildx:
docker buildx use $(BUILDX_WINDOWS_BUILDER) || docker buildx create --platform windows/amd64 --name $(BUILDX_WINDOWS_BUILDER) --use

# Build the image for the gameserver extensions
build-extensions-image: build-extensions-image-amd64
Expand Down Expand Up @@ -618,8 +617,8 @@ build-agones-sdk-image-windows: build-agones-sdk-binary
build-agones-sdk-image-windows: $(foreach winver, $(WINDOWS_VERSIONS), build-agones-sdk-image-windows-$(winver))

# Build the image for the gameserver sidecar and SDK binaries
build-agones-sdk-image-windows-%: $(ensure-build-image) build-agones-sdk-binary build-licenses build-required-src-dist ensure-windows-buildx-%
docker buildx build --platform windows/amd64 --builder $(BUILDX_WINDOWS_BUILDER)-$* -f $(agones_path)/cmd/sdk-server/Dockerfile.windows --tag=$(sidecar_tag)-windows_amd64-$* --build-arg WINDOWS_VERSION=$* --build-arg IMAGE_TAG=$(if $(filter ltsc2019,$*),$(LTSC2019_IMAGE_TAG)) $(DOCKER_BUILD_ARGS) $(agones_path)/cmd/sdk-server/ $(WINDOWS_DOCKER_PUSH_ARGS)
build-agones-sdk-image-windows-%: $(ensure-build-image) build-agones-sdk-binary build-licenses build-required-src-dist ensure-windows-buildx
docker buildx build --platform windows/amd64 --builder $(BUILDX_WINDOWS_BUILDER) -f $(agones_path)/cmd/sdk-server/Dockerfile.windows --tag=$(sidecar_tag)-windows_amd64-$* --build-arg WINDOWS_VERSION=$* --build-arg IMAGE_TAG=$(if $(filter ltsc2019,$*),$(LTSC2019_IMAGE_TAG)) $(DOCKER_BUILD_ARGS) $(agones_path)/cmd/sdk-server/ $(WINDOWS_DOCKER_PUSH_ARGS)

# Build a static binary for the ping service
build-ping-binary: build-ping-binary-amd64
Expand Down
2 changes: 1 addition & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ steps:
declare -A versionsAndRegions=( [1.29]=europe-west1 [1.30]=asia-east1 [1.31]=us-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&ScheduledAutoscaler=true&DisableResyncOnSDKServer=false&AutopilotPassthroughPort=false&GKEAutopilotExtendedDurationPods=false&Example=true"
featureWithGate="PlayerAllocationFilter=true&FleetAutoscaleRequestMetaData=true&PlayerTracking=true&CountsAndLists=false&RollingUpdateFix=true&PortRanges=true&PortPolicyNone=true&ScheduledAutoscaler=true&DisableResyncOnSDKServer=false&AutopilotPassthroughPort=false&GKEAutopilotExtendedDurationPods=false&Example=true"
featureWithoutGate=""
# Use this if specific feature gates can only be supported on specific Kubernetes versions.
Expand Down
1 change: 1 addition & 0 deletions install/helm/agones/defaultfeaturegates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CountsAndLists: true
DisableResyncOnSDKServer: true

# Alpha features
FleetAutoscaleRequestMetaData: false
PlayerAllocationFilter: false
PlayerTracking: false
RollingUpdateFix: false
Expand Down
12 changes: 12 additions & 0 deletions install/helm/agones/templates/ping.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ metadata:
spec:
selector:
agones.dev/role: ping
{{- if .Values.agones.ping.http.ipFamilyPolicy }}
ipFamilyPolicy: {{ .Values.agones.ping.http.ipFamilyPolicy }}
{{- end }}
{{- if .Values.agones.ping.http.ipFamilies }}
ipFamilies: {{ toYaml .Values.agones.ping.http.ipFamilies | nindent 4 }}
{{- end }}
ports:
- port: {{ .Values.agones.ping.http.port }}
name: http
Expand Down Expand Up @@ -199,6 +205,12 @@ metadata:
spec:
selector:
agones.dev/role: ping
{{- if .Values.agones.ping.udp.ipFamilyPolicy }}
ipFamilyPolicy: {{ .Values.agones.ping.udp.ipFamilyPolicy }}
{{- end }}
{{- if .Values.agones.ping.udp.ipFamilies }}
ipFamilies: {{ toYaml .Values.agones.ping.udp.ipFamilies | nindent 4 }}
{{- end }}
ports:
- port: {{ .Values.agones.ping.udp.port }}
name: udp
Expand Down
6 changes: 6 additions & 0 deletions install/helm/agones/templates/service/allocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ metadata:
spec:
selector:
multicluster.agones.dev/role: allocator
{{- if .Values.agones.allocator.service.ipFamilyPolicy }}
ipFamilyPolicy: {{ .Values.agones.allocator.service.ipFamilyPolicy }}
{{- end }}
{{- if .Values.agones.allocator.service.ipFamilies }}
ipFamilies: {{ toYaml .Values.agones.allocator.service.ipFamilies | nindent 4 }}
{{- end }}
ports:
{{- if .Values.agones.allocator.service.http.enabled }}
- port: {{ .Values.agones.allocator.service.http.port }}
Expand Down
6 changes: 6 additions & 0 deletions install/helm/agones/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ agones:
externalTrafficPolicy: Cluster
loadBalancerSourceRanges: []
annotations: {}
ipFamilyPolicy: ""
ipFamilies: []
udp:
expose: true
rateLimit: 20
Expand All @@ -197,6 +199,8 @@ agones:
externalTrafficPolicy: Cluster
loadBalancerSourceRanges: []
annotations: {}
ipFamilyPolicy: ""
ipFamilies: []
healthCheck:
initialDelaySeconds: 3
periodSeconds: 3
Expand Down Expand Up @@ -240,6 +244,8 @@ agones:
loadBalancerIP: ""
loadBalancerSourceRanges: []
annotations: {}
ipFamilyPolicy: ""
ipFamilies: []
http:
enabled: true
appProtocol: ""
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/autoscaling/v1/fleetautoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ type FleetAutoscaleRequest struct {
Namespace string `json:"namespace"`
// The Fleet's status values
Status agonesv1.FleetStatus `json:"status"`
// Standard map labels; More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels.
Labels map[string]string `json:"labels,omitempty"`
// Standard map annotations; More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations.
Annotations map[string]string `json:"annotations,omitempty"`
}

// FleetAutoscaleResponse defines the response of webhook autoscaler endpoint
Expand Down
5 changes: 5 additions & 0 deletions pkg/fleetautoscalers/fleetautoscalers.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ func applyWebhookPolicy(w *autoscalingv1.WebhookPolicy, f *agonesv1.Fleet) (repl
Response: nil,
}

if runtime.FeatureEnabled(runtime.FeatureFleetAutoscaleRequestMetaData) {
faReq.Request.Annotations = f.ObjectMeta.Annotations
faReq.Request.Labels = f.ObjectMeta.Labels
}

b, err := json.Marshal(faReq)
if err != nil {
return 0, false, err
Expand Down
45 changes: 45 additions & 0 deletions pkg/fleetautoscalers/fleetautoscalers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io"
"net/http"
"net/http/httptest"
"strconv"
"testing"
"time"

Expand Down Expand Up @@ -92,6 +93,15 @@ func (t testServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
faResp.Replicas = faReq.Status.Replicas * scaleFactor
}

// override value for tests
if faReq.Annotations != nil {
if value, ok := faReq.Annotations["fixedReplicas"]; ok {
faResp.Scale = true
replicas, _ := strconv.Atoi(value)
faResp.Replicas = int32(replicas)
}
}

review := &autoscalingv1.FleetAutoscaleReview{
Request: faReq,
Response: &faResp,
Expand Down Expand Up @@ -579,6 +589,41 @@ func TestApplyWebhookPolicy(t *testing.T) {
}
}

func TestApplyWebhookPolicyWithMetadata(t *testing.T) {
t.Parallel()

utilruntime.FeatureTestMutex.Lock()
defer utilruntime.FeatureTestMutex.Unlock()

err := utilruntime.ParseFeatures(string(utilruntime.FeatureFleetAutoscaleRequestMetaData) + "=true")
assert.NoError(t, err)
defer func() {
_ = utilruntime.ParseFeatures("")
}()

ts := testServer{}
server := httptest.NewServer(ts)
defer server.Close()

_, fleet := defaultWebhookFixtures()

fixedReplicas := int32(11)
fleet.ObjectMeta.Annotations = map[string]string{
"fixedReplicas": fmt.Sprintf("%d", fixedReplicas),
}

webhookPolicy := &autoscalingv1.WebhookPolicy{
Service: nil,
URL: &(server.URL),
}

replicas, limited, err := applyWebhookPolicy(webhookPolicy, fleet)

assert.Nil(t, err)
assert.False(t, limited)
assert.Equal(t, fixedReplicas, replicas)
}

func TestApplyWebhookPolicyNilFleet(t *testing.T) {
t.Parallel()

Expand Down
16 changes: 10 additions & 6 deletions pkg/util/runtime/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const (
////////////////
// Alpha features

// FeatureFleetAutoscaleRequestMetaData is a feature flag that enables/disables fleet metadata on webhook autoscaler request.
FeatureFleetAutoscaleRequestMetaData Feature = "FleetAutoscaleRequestMetaData"

// FeaturePlayerAllocationFilter is a feature flag that enables the ability for Allocations to filter based on
// player capacity.
FeaturePlayerAllocationFilter Feature = "PlayerAllocationFilter"
Expand Down Expand Up @@ -134,12 +137,13 @@ var (
FeatureDisableResyncOnSDKServer: true,

// Alpha features
FeaturePlayerAllocationFilter: false,
FeaturePlayerTracking: false,
FeatureRollingUpdateFix: false,
FeaturePortRanges: false,
FeaturePortPolicyNone: false,
FeatureScheduledAutoscaler: false,
FeatureFleetAutoscaleRequestMetaData: false,
FeaturePlayerAllocationFilter: false,
FeaturePlayerTracking: false,
FeatureRollingUpdateFix: false,
FeaturePortRanges: false,
FeaturePortPolicyNone: false,
FeatureScheduledAutoscaler: false,

// Dev features

Expand Down
20 changes: 20 additions & 0 deletions site/content/en/docs/Guides/feature-stages.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,25 @@ that can be found in the [Helm configuration]({{< ref "/docs/Installation/Instal

The current set of `alpha` and `beta` feature gates:

{{% feature expiryVersion="1.48.0" %}}

| Feature Name | Gate | Default | Stage | Since |
|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------|----------|---------|--------|
| [CountsAndLists](https://github.com/googleforgames/agones/issues/2716) | `CountsAndLists` | Enabled | `Beta` | 1.41.0 |
| [DisableResyncOnSDKServer](https://github.com/googleforgames/agones/issues/3377) | `DisableResyncOnSDKServer` | Enabled | `Beta` | 1.40.0 |
| [Support Passthrough on GKE Autopilot](https://github.com/googleforgames/agones/issues/3721) | `AutopilotPassthroughPort` | Enabled | `Beta` | 1.43.0 |
| [Support for Extended Duration Pods on GKE Autopilot (*1.28+ only*)](https://github.com/googleforgames/agones/issues/3386) | `GKEAutopilotExtendedDurationPods` | Enabled | `Beta` | 1.44.0 |
| [GameServer player capacity filtering on GameServerAllocations](https://github.com/googleforgames/agones/issues/1239) | `PlayerAllocationFilter` | Disabled | `Alpha` | 1.14.0 |
| [Player Tracking]({{< ref "/docs/Guides/player-tracking.md" >}}) | `PlayerTracking` | Disabled | `Alpha` | 1.6.0 |
| [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 |
| Example Gate (not in use) | `Example` | Disabled | None | 0.13.0 |

{{% /feature %}}

{{% feature publishVersion="1.48.0" %}}

| Feature Name | Gate | Default | Stage | Since |
|-----------------------------------------------------------------------------------------------------------------------------|------------------------------------|----------|---------|--------|
Expand All @@ -38,8 +56,10 @@ 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 |
| [Extend Webhook autoscaler to send fleet metadata with the request](https://github.com/googleforgames/agones/issues/3951) | `FleetAutoscaleRequestMetaData` | Disabled | `Alpha` | 1.48.0 |
| Example Gate (not in use) | `Example` | Disabled | None | 0.13.0 |

{{% /feature %}}

[fleet-updates]: {{% relref "./fleet-updates.md#notifying-gameservers-on-fleet-updatedownscale" %}}

Expand Down
Loading

0 comments on commit 37dcef7

Please sign in to comment.