Skip to content

Commit

Permalink
Graduate CustomFasSyncInterval To Stable (#3235)
Browse files Browse the repository at this point in the history
* Graduate CustomFasSyncInterval to Stable

* CustomFasSyncInterval update in agones_crd_api_reference.html
* make gen-api-docs updated the agones_crd_api_reference.html
* modified controller.go
* added feature shortcodes
* updated fleetautoscaler.md
  • Loading branch information
Kalaiselvi84 committed Jul 10, 2023
1 parent 88c38fa commit 635573e
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 107 deletions.
4 changes: 2 additions & 2 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ steps:
region=${versionsAndRegions[$version]}
if [ $cloudProduct = generic ]
then
featureWithGate="CustomFasSyncInterval=false&StateAllocationFilter=false&PlayerAllocationFilter=true&PlayerTracking=true&ResetMetricsOnDelete=false&PodHostname=false&SplitControllerAndExtensions=false&FleetAllocationOverflow=true&Example=true"
featureWithGate="StateAllocationFilter=false&PlayerAllocationFilter=true&PlayerTracking=true&ResetMetricsOnDelete=false&PodHostname=false&SplitControllerAndExtensions=false&FleetAllocationOverflow=true&Example=true"
testCluster="standard-e2e-test-cluster-${version//./-}"
else
featureWithGate="CustomFasSyncInterval=false&StateAllocationFilter=false&PlayerAllocationFilter=true&PlayerTracking=true&ResetMetricsOnDelete=false&PodHostname=false&SplitControllerAndExtensions=true&FleetAllocationOverflow=true&Example=true"
featureWithGate="StateAllocationFilter=false&PlayerAllocationFilter=true&PlayerTracking=true&ResetMetricsOnDelete=false&PodHostname=false&SplitControllerAndExtensions=true&FleetAllocationOverflow=true&Example=true"
testCluster="gke-autopilot-e2e-test-cluster-${version//./-}"
fi
featureWithoutGate=""
Expand Down
2 changes: 0 additions & 2 deletions examples/fleetautoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ spec:
# maximum fleet size that can be set by this FleetAutoscaler
# required
maxReplicas: 20
# [Stage:Beta]
# [FeatureFlag:CustomFasSyncInterval]
# The autoscaling sync strategy
sync:
# type of the sync. for now, only FixedInterval is available
Expand Down
1 change: 0 additions & 1 deletion install/helm/agones/defaultfeaturegates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# Default values for feature gates. Keep in sync with pkg/util/runtime/features.go:featureDefaults

# Beta features
CustomFasSyncInterval: true
PodHostname: true
ResetMetricsOnDelete: true
SplitControllerAndExtensions: true
Expand Down
22 changes: 9 additions & 13 deletions pkg/apis/autoscaling/v1/fleetautoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ type FleetAutoscalerSpec struct {

// Autoscaling policy
Policy FleetAutoscalerPolicy `json:"policy"`
// [Stage:Beta]
// [FeatureFlag:CustomFasSyncInterval]
// Sync defines when FleetAutoscalers runs autoscaling
// +optional
Sync *FleetAutoscalerSync `json:"sync,omitempty"`
Expand Down Expand Up @@ -272,7 +270,7 @@ func (fas *FleetAutoscaler) Validate(causes []metav1.StatusCause) []metav1.Statu
causes = fas.Spec.Policy.List.ValidateListPolicy(causes)
}

if runtime.FeatureEnabled(runtime.FeatureCustomFasSyncInterval) && fas.Spec.Sync != nil {
if fas.Spec.Sync != nil {
causes = fas.Spec.Sync.FixedInterval.ValidateFixedIntervalSync(causes)
}
return causes
Expand Down Expand Up @@ -541,15 +539,13 @@ func (i *FixedIntervalSync) ValidateFixedIntervalSync(causes []metav1.StatusCaus

// ApplyDefaults applies default values to the FleetAutoscaler
func (fas *FleetAutoscaler) ApplyDefaults() {
if runtime.FeatureEnabled(runtime.FeatureCustomFasSyncInterval) {
if fas.Spec.Sync == nil {
fas.Spec.Sync = &FleetAutoscalerSync{}
}
if fas.Spec.Sync.Type == "" {
fas.Spec.Sync.Type = FixedIntervalSyncType
}
if fas.Spec.Sync.FixedInterval.Seconds == 0 {
fas.Spec.Sync.FixedInterval.Seconds = defaultIntervalSyncSeconds
}
if fas.Spec.Sync == nil {
fas.Spec.Sync = &FleetAutoscalerSync{}
}
if fas.Spec.Sync.Type == "" {
fas.Spec.Sync.Type = FixedIntervalSyncType
}
if fas.Spec.Sync.FixedInterval.Seconds == 0 {
fas.Spec.Sync.FixedInterval.Seconds = defaultIntervalSyncSeconds
}
}
4 changes: 0 additions & 4 deletions pkg/apis/autoscaling/v1/fleetautoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ func TestFleetAutoscalerValidateUpdate(t *testing.T) {
})

t.Run("bad sync interval seconds", func(t *testing.T) {
if !runtime.FeatureEnabled(runtime.FeatureCustomFasSyncInterval) {
// Do not run test if FeatureCustomFasSyncInterval is not enabled
t.Skip()
}

fas := defaultFixture()
fas.Spec.Sync.FixedInterval.Seconds = 0
Expand Down
31 changes: 8 additions & 23 deletions pkg/fleetautoscalers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,28 +122,18 @@ func NewController(

autoscaler.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
if runtime.FeatureEnabled(runtime.FeatureCustomFasSyncInterval) {
c.addFasThread(obj.(*autoscalingv1.FleetAutoscaler), true)
} else {
c.workerqueue.Enqueue(obj)
}
c.addFasThread(obj.(*autoscalingv1.FleetAutoscaler), true)
},
UpdateFunc: func(_, newObj interface{}) {
if runtime.FeatureEnabled(runtime.FeatureCustomFasSyncInterval) {
c.updateFasThread(newObj.(*autoscalingv1.FleetAutoscaler))
} else {
c.workerqueue.Enqueue(newObj)
}
c.updateFasThread(newObj.(*autoscalingv1.FleetAutoscaler))
},
DeleteFunc: func(obj interface{}) {
if runtime.FeatureEnabled(runtime.FeatureCustomFasSyncInterval) {
// Could be a DeletedFinalStateUnknown, in which case, just ignore it
fas, ok := obj.(*autoscalingv1.FleetAutoscaler)
if !ok {
return
}
c.deleteFasThread(fas, true)
// Could be a DeletedFinalStateUnknown, in which case, just ignore it
fas, ok := obj.(*autoscalingv1.FleetAutoscaler)
if !ok {
return
}
c.deleteFasThread(fas, true)
},
})

Expand Down Expand Up @@ -292,12 +282,7 @@ func (c *Controller) syncFleetAutoscaler(ctx context.Context, key string) error
}

if fas == nil {
// just in case we don't catch a delete event for some reason, use this as a
// failsafe to ensure we don't end up leaking goroutines.
if runtime.FeatureEnabled(runtime.FeatureCustomFasSyncInterval) {
return c.cleanFasThreads(key)
}
return nil
return c.cleanFasThreads(key)
}

// Retrieve the fleet by spec name
Expand Down
33 changes: 6 additions & 27 deletions pkg/fleetautoscalers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
agonesv1 "agones.dev/agones/pkg/apis/agones/v1"
autoscalingv1 "agones.dev/agones/pkg/apis/autoscaling/v1"
agtesting "agones.dev/agones/pkg/testing"
utilruntime "agones.dev/agones/pkg/util/runtime"
"agones.dev/agones/pkg/util/webhooks"
"github.com/heptiolabs/healthcheck"
"github.com/mattbaird/jsonpatch"
Expand Down Expand Up @@ -169,17 +168,15 @@ func TestControllerCreationMutationHandler(t *testing.T) {
err = json.Unmarshal(result.Response.Patch, patch)
require.NoError(t, err)

if utilruntime.FeatureEnabled(utilruntime.FeatureCustomFasSyncInterval) {
found := false
found := false

for _, expected := range tc.expected.patches {
for _, p := range *patch {
if assert.ObjectsAreEqual(p, expected) {
found = true
}
for _, expected := range tc.expected.patches {
for _, p := range *patch {
if assert.ObjectsAreEqual(p, expected) {
found = true
}
assert.True(t, found, "Could not find operation %#v in patch %v", expected, *patch)
}
assert.True(t, found, "Could not find operation %#v in patch %v", expected, *patch)
}
}
})
Expand Down Expand Up @@ -281,10 +278,6 @@ func TestWebhookControllerCreationValidationHandler(t *testing.T) {

// nolint:dupl
func TestControllerSyncFleetAutoscaler(t *testing.T) {
utilruntime.FeatureTestMutex.Lock()
defer utilruntime.FeatureTestMutex.Unlock()

assert.NoError(t, utilruntime.ParseFeatures(string(utilruntime.FeatureCustomFasSyncInterval)+"=false"))

t.Run("no scaling up because fleet is marked for deletion, buffer policy", func(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -762,10 +755,6 @@ func TestControllerSyncFleetAutoscaler(t *testing.T) {
t.Run("Missing fleet autoscaler, doesn't fail/panic", func(t *testing.T) {
t.Parallel()

utilruntime.FeatureTestMutex.Lock()
defer utilruntime.FeatureTestMutex.Unlock()
require.NoError(t, utilruntime.ParseFeatures(fmt.Sprintf("%s=true", utilruntime.FeatureCustomFasSyncInterval)))

c, m := newFakeController()
ctx, cancel := agtesting.StartInformers(m, c.fleetSynced, c.fleetAutoscalerSynced)
defer cancel()
Expand Down Expand Up @@ -1013,11 +1002,6 @@ func TestControllerUpdateStatusUnableToScale(t *testing.T) {
func TestControllerEvents(t *testing.T) {
t.Parallel()

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

require.NoError(t, utilruntime.ParseFeatures(fmt.Sprintf("%s=true", utilruntime.FeatureCustomFasSyncInterval)))

c, mocks := newFakeController()
fakeWatch := watch.NewFake()
mocks.AgonesClient.AddWatchReactor("fleetautoscalers", k8stesting.DefaultWatchReactor(fakeWatch, nil))
Expand Down Expand Up @@ -1060,11 +1044,6 @@ func TestControllerEvents(t *testing.T) {
func TestControllerAddUpdateDeleteFasThread(t *testing.T) {
t.Parallel()

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

assert.NoError(t, utilruntime.ParseFeatures(fmt.Sprintf("%s=true", utilruntime.FeatureCustomFasSyncInterval)))

var counter int64
c, m := newFakeController()
c.workerqueue.SyncHandler = func(ctx context.Context, s string) error {
Expand Down
4 changes: 0 additions & 4 deletions pkg/util/runtime/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ const (
////////////////
// Beta features

// FeatureCustomFasSyncInterval is a feature flag that enables a custom FleetAutoscaler resync interval
FeatureCustomFasSyncInterval Feature = "CustomFasSyncInterval"

// FeatureSplitControllerAndExtensions is a feature flag that will split agones-controller into two deployments
FeatureSplitControllerAndExtensions Feature = "SplitControllerAndExtensions"

Expand Down Expand Up @@ -104,7 +101,6 @@ var (
// In each of these, keep the feature sorted by descending maturity then alphabetical
featureDefaults = map[Feature]bool{
// Beta features
FeatureCustomFasSyncInterval: true,
FeaturePodHostname: true,
FeatureResetMetricsOnDelete: true,
FeatureSplitControllerAndExtensions: true,
Expand Down
17 changes: 17 additions & 0 deletions site/content/en/docs/Guides/feature-stages.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ that can be found in the [Helm configuration]({{< ref "/docs/Installation/Instal

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

{{% feature expiryVersion="1.34.0" %}}
| Feature Name | Gate | Default | Stage | Since |
|-----------------------------------------------------------------------------------------------------------------------|--------------------------------|----------|---------|--------|
| [Custom resync period for FleetAutoscaler](https://github.com/googleforgames/agones/issues/1955) | `CustomFasSyncInterval` | Enabled | `Beta` | 1.25.0 |
Expand All @@ -36,6 +37,22 @@ The current set of `alpha` and `beta` feature gates:
| [Allocated GameServers are notified on relevant Fleet Updates][fleet-updates] | `FleetAllocationOverflow` | Disabled | `Alpha` | 1.32.0 |
| Example Gate (not in use) | `Example` | Disabled | None | 0.13.0 |

{{% /feature %}}

{{% feature publishVersion="1.34.0" %}}
| Feature Name | Gate | Default | Stage | Since |
|-----------------------------------------------------------------------------------------------------------------------|--------------------------------|----------|---------|--------|
| [GameServer Stable Network ID]({{% ref "/docs/Reference/gameserver.md#stable-network-id" %}}) | `PodHostname` | Enabled | `Beta` | 1.32.0 |
| [Reset Metric Export on Fleet / Autoscaler deletion]({{% relref "./metrics.md#dropping-metric-labels" %}}) | `ResetMetricsOnDelete` | Enabled | `Beta` | 1.32.0 |
| [Split `agones-controller` ](https://github.com/googleforgames/agones/issues/2797) | `SplitControllerAndExtensions` | Enabled | `Beta` | 1.32.0 |
| [GameServer state filtering on GameServerAllocations](https://github.com/googleforgames/agones/issues/1239) | `StateAllocationFilter` | Enabled | `Beta` | 1.26.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 |
| [Allocated GameServers are notified on relevant Fleet Updates][fleet-updates] | `FleetAllocationOverflow` | Disabled | `Alpha` | 1.32.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
2 changes: 1 addition & 1 deletion site/content/en/docs/Guides/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ For example:
$ kubectl logs -n agones-system agones-controller-7575dc59-7p2rg | head
{"filename":"/home/agones/logs/agones-controller-20220615_211540.log","message":"logging to file","numbackups":99,"severity":"info","source":"main","time":"2022-06-15T21:15:40.309349789Z"}
{"logLevel":"info","message":"Setting LogLevel configuration","severity":"info","source":"main","time":"2022-06-15T21:15:40.309403296Z"}
{"ctlConf":{"MinPort":7000,"MaxPort":8000,"SidecarImage":"gcr.io/agones-images/agones-sdk:1.23.0","SidecarCPURequest":"30m","SidecarCPULimit":"0","SidecarMemoryRequest":"0","SidecarMemoryLimit":"0","SdkServiceAccount":"agones-sdk","AlwaysPullSidecar":false,"PrometheusMetrics":true,"Stackdriver":false,"StackdriverLabels":"","KeyFile":"/home/agones/certs/server.key","CertFile":"/home/agones/certs/server.crt","KubeConfig":"","GCPProjectID":"","NumWorkers":100,"APIServerSustainedQPS":400,"APIServerBurstQPS":500,"LogDir":"/home/agones/logs","LogLevel":"info","LogSizeLimitMB":10000},"featureGates":"CustomFasSyncInterval=false\u0026Example=true\u0026NodeExternalDNS=true\u0026PlayerAllocationFilter=false\u0026PlayerTracking=false\u0026StateAllocationFilter=false","message":"starting gameServer operator...","severity":"info","source":"main","time":"2022-06-15T21:15:40.309528802Z","version":"1.23.0"}
{"ctlConf":{"MinPort":7000,"MaxPort":8000,"SidecarImage":"gcr.io/agones-images/agones-sdk:1.23.0","SidecarCPURequest":"30m","SidecarCPULimit":"0","SidecarMemoryRequest":"0","SidecarMemoryLimit":"0","SdkServiceAccount":"agones-sdk","AlwaysPullSidecar":false,"PrometheusMetrics":true,"Stackdriver":false,"StackdriverLabels":"","KeyFile":"/home/agones/certs/server.key","CertFile":"/home/agones/certs/server.crt","KubeConfig":"","GCPProjectID":"","NumWorkers":100,"APIServerSustainedQPS":400,"APIServerBurstQPS":500,"LogDir":"/home/agones/logs","LogLevel":"info","LogSizeLimitMB":10000},"featureGates":"Example=true\u0026NodeExternalDNS=true\u0026PlayerAllocationFilter=false\u0026PlayerTracking=false\u0026StateAllocationFilter=false","message":"starting gameServer operator...","severity":"info","source":"main","time":"2022-06-15T21:15:40.309528802Z","version":"1.23.0"}
...
```

Expand Down
20 changes: 2 additions & 18 deletions site/content/en/docs/Reference/agones_crd_api_reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@ <h3 id="autoscaling.agones.dev/v1.FleetAutoscaler">FleetAutoscaler
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>[Stage:Beta]
[FeatureFlag:CustomFasSyncInterval]
Sync defines when FleetAutoscalers runs autoscaling</p>
</td>
</tr>
</table>
</td>
Expand Down Expand Up @@ -514,12 +508,6 @@ <h3 id="autoscaling.agones.dev/v1.FleetAutoscalerSpec">FleetAutoscalerSpec
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>[Stage:Beta]
[FeatureFlag:CustomFasSyncInterval]
Sync defines when FleetAutoscalers runs autoscaling</p>
</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -6911,9 +6899,7 @@ <h3 id="autoscaling.agones.dev/v1.FleetAutoscaler">FleetAutoscaler
</td>
<td>
<em>(Optional)</em>
<p>[Stage:Beta]
[FeatureFlag:CustomFasSyncInterval]
Sync defines when FleetAutoscalers runs autoscaling</p>
<p>Sync defines when FleetAutoscalers runs autoscaling</p>
</td>
</tr>
</table>
Expand Down Expand Up @@ -7410,9 +7396,7 @@ <h3 id="autoscaling.agones.dev/v1.FleetAutoscalerSpec">FleetAutoscalerSpec
</td>
<td>
<em>(Optional)</em>
<p>[Stage:Beta]
[FeatureFlag:CustomFasSyncInterval]
Sync defines when FleetAutoscalers runs autoscaling</p>
<p>Sync defines when FleetAutoscalers runs autoscaling</p>
</td>
</tr>
</tbody>
Expand Down
41 changes: 41 additions & 0 deletions site/content/en/docs/Reference/fleetautoscaler.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ weight: 30
A full `FleetAutoscaler` specification is available below and in the
{{< ghlink href="examples/fleetautoscaler.yaml" >}}example folder{{< /ghlink >}} for reference :

{{% feature expiryVersion="1.34.0" %}}
```yaml
apiVersion: "autoscaling.agones.dev/v1"
kind: FleetAutoscaler
Expand Down Expand Up @@ -48,6 +49,46 @@ spec:
# the time in seconds between each auto scaling
seconds: 30
```
{{% /feature %}}
{{% feature publishVersion="1.34.0" %}}
```yaml
apiVersion: "autoscaling.agones.dev/v1"
kind: FleetAutoscaler
# FleetAutoscaler Metadata
# {{< k8s-api-version href="#objectmeta-v1-meta" >}}
metadata:
name: fleet-autoscaler-example
spec:
# The name of the fleet to attach to and control. Must be an existing Fleet in the same namespace
# as this FleetAutoscaler
fleetName: fleet-example
# The autoscaling policy
policy:
# type of the policy. for now, only Buffer is available
type: Buffer
# parameters of the buffer policy
buffer:
# Size of a buffer of "ready" game server instances
# The FleetAutoscaler will scale the fleet up and down trying to maintain this buffer,
# as instances are being allocated or terminated
# it can be specified either in absolute (i.e. 5) or percentage format (i.e. 5%)
bufferSize: 5
# minimum fleet size to be set by this FleetAutoscaler.
# if not specified, the actual minimum fleet size will be bufferSize
minReplicas: 10
# maximum fleet size that can be set by this FleetAutoscaler
# required
maxReplicas: 20
# The autoscaling sync strategy
sync:
# type of the sync. for now, only FixedInterval is available
type: FixedInterval
# parameters of the fixedInterval sync
fixedInterval:
# the time in seconds between each auto scaling
seconds: 30
```
{{% /feature %}}

Or for Webhook FleetAutoscaler below and in {{< ghlink href="examples/webhookfleetautoscaler.yaml" >}}example folder{{< /ghlink >}}:

Expand Down

0 comments on commit 635573e

Please sign in to comment.