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

feat: Add API Changes and Validation for FleetAutoscaler Schedule/Chain Policy #3893

Merged
merged 30 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
685f518
define and add crd changes for new fleetautoscaler chain policy
indexjoseph Jun 20, 2024
711ceaa
Made API Changes for Chain Policy
indexjoseph Jun 21, 2024
59430d3
API Changes for Fleet Autoscaler Policy and Chain Policy
indexjoseph Jun 23, 2024
d5c3cd2
chain policy tests
indexjoseph Jun 23, 2024
b57d651
change feature flag stage to alpha
indexjoseph Jun 24, 2024
30d3496
rollback api changes and add scheduled autoscaer as dev feature gate
indexjoseph Jun 24, 2024
6097474
remove added vendor files
indexjoseph Jun 24, 2024
707b1e2
fix example spacing
indexjoseph Jun 24, 2024
c8f3e24
fix yaml lint
indexjoseph Jun 24, 2024
df77e6d
fix enumerations for policies
indexjoseph Jun 24, 2024
3d666c4
fixed install yaml
indexjoseph Jun 25, 2024
a753ef1
remove extra character and add documentation
indexjoseph Jun 25, 2024
22dd8b2
fix copyright dates, feature gate and include policy
indexjoseph Jun 26, 2024
a3fff74
fix recursive chain policy issue
indexjoseph Jun 27, 2024
3da4b61
remove extra indentation
indexjoseph Jun 27, 2024
c2860c2
regenerate dependecies
indexjoseph Jul 8, 2024
7989d42
move timezone field into activePeriod and only allow for RFC3339 star…
indexjoseph Jul 9, 2024
7f827c0
Add generated deepcopy for new Chain Policy
indexjoseph Jul 10, 2024
75a4a16
change chain entry uid to id
indexjoseph Jul 15, 2024
1e2f80c
run go mod tidy and crd generation
indexjoseph Jul 15, 2024
f7da4e3
crd changes for schedule
indexjoseph Jul 17, 2024
a921b0e
fix example time to have valid start/end times
indexjoseph Jul 18, 2024
de4b803
install yaml
indexjoseph Jul 18, 2024
1848627
Add schedule as a policy and separate from chain policy
indexjoseph Jul 25, 2024
68fa20a
Merge branch 'main' into chain-api-changes
zmerlynn Jul 25, 2024
3c826c1
Update FleetAutoscaler Chain Policy Definition to Exclude Policy Prop…
indexjoseph Jul 26, 2024
a86aa34
Update chainfleetautoscaler to have list of entries (removing policy …
indexjoseph Jul 26, 2024
1d7eb1d
regenerate api docs
indexjoseph Jul 27, 2024
0e04671
Add validation for ensuring that a user enter's a policy if a chain e…
indexjoseph Jul 29, 2024
067d52b
Merge branch 'main' into chain-api-changes
zmerlynn Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 42 additions & 34 deletions examples/chainfleetautoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
# [Stage:Dev]
# [FeatureFlag:ScheduledAutoscaler]
# Example of a FleetAutoscaler - this is used to scale a Fleet based on a schedule.
# Example of a FleetAutoscaler - this is used to scale a Fleet based on a chain.
#

#
Expand All @@ -27,65 +27,73 @@ kind: FleetAutoscaler
metadata:
name: chain-fleet-autoscaler
spec:
fleetName: fleet-example
policy:
# Chain based policy for autoscaling.
type: Chain
chain:
# Id of chain entry. If not set, the Id will be defaulted to the index of the entry within the chain.
- id: "weekday"
type: Schedule # Schedule based condition.
indexjoseph marked this conversation as resolved.
Show resolved Hide resolved
type: Schedule # Schedule based policy.
schedule:
between:
# The policy becomes eligible for application starting on Feb 20, 2024 at 4:04 PM EST. If not set, the policy will immediately be eligible for application.
start: "2024-02-20T16:04:04-05:00"
# The policy becomes ineligible for application on Feb 23, 2024 at 4:04 PM EST. If not set, the policy will always be eligible for application (after the start time).
end: "2024-02-23T16:04:04-05:00"
# The policy becomes eligible for application starting on Feb 20, 2100 at 4:04 PM EST. If not set, the policy will immediately be eligible for application.
start: "2100-02-20T16:04:04-05:00"
# The policy becomes ineligible for application on Feb 23, 2100 at 4:04 PM EST. If not set, the policy will always be eligible for application (after the start time).
end: "2100-02-23T16:04:04-05:00"
activePeriod:
# Timezone to be used for the startCron field. Defaults to UTC if not set.
timezone: "America/New_York"
# Start applying the policy everyday at 1:00 AM EST. If not set, the policy will always be applied in the .between window.
# (Only eligible starting on Feb 20, 2024 at 4:04 PM).
# (Only eligible starting on Feb 20, 2100 at 4:04 PM).
startCron: "0 1 * * 0"
# Only apply the policy for 5 hours. If not set, the duration will be defaulted to always/indefinite.
duration: "5h"
# Policy to be applied during the activePeriod. Required.
policy:
type: Buffer
buffer:
bufferSize: 50
minReplicas: 100
maxReplicas: 2000
# Policy to be applied during the activePeriod. Required.
policy:
type: Buffer
buffer:
bufferSize: 50
minReplicas: 100
maxReplicas: 2000
# Id of chain entry. If not set, the Id will be defaulted to the index of the entry within the chain list.
- id: "weekend"
type: Schedule
type: Schedule # Schedule based policy.
schedule:
between:
# The policy becomes eligible for application starting on Feb 24, 2024 at 4:05 PM EST. If not set, the policy will immediately be eligible for application.
start: "2024-02-24T16:04:05-05:00"
# The policy becomes ineligible for application starting on Feb 26, 2024 at 4:05 PM EST. If not set, the policy will always be eligible for application (after the start time).
end: "2024-02-26T16:04:05-05:00"
# The policy becomes eligible for application starting on Feb 24, 2100 at 4:05 PM EST. If not set, the policy will immediately be eligible for application.
start: "2100-02-24T16:04:05-05:00"
# The policy becomes ineligible for application starting on Feb 26, 2100 at 4:05 PM EST. If not set, the policy will always be eligible for application (after the start time).
end: "2100-02-26T16:04:05-05:00"
activePeriod:
# Timezone to be used for the startCron field. Defaults to UTC if not set.
timezone: "America/New_York"
# Start applying the policy everyday at 1:00 AM EST. If not set, the policy will always be applied in the .between window.
# (Only eligible starting on Feb 24, 2024 at 4:05 PM EST)
# (Only eligible starting on Feb 24, 2100 at 4:05 PM EST)
startCron: "0 1 * * 0"
# Only apply the policy for 7 hours. If not set the duration will be defaulted to always/indefinite.
duration: "7h"
# Policy to be applied during the activePeriod. Required.
policy:
type: Counter
counter:
key: rooms
bufferSize: 10
minCapacity: 500
maxCapacity: 1000
# Policy to be applied during the activePeriod. Required.
policy:
type: Counter
counter:
key: rooms
bufferSize: 10
minCapacity: 500
maxCapacity: 1000
# Id of chain entry. If not set, the Id will be defaulted to the index of the entry within the chain list.
- id: "default"
# Policy will always be applied when no other policy is applicable. Required.
policy:
type: Buffer
buffer:
bufferSize: 5
minReplicas: 100
maxReplicas: 2000
type: Buffer
buffer:
bufferSize: 5
minReplicas: 100
maxReplicas: 2000
# The autoscaling sync strategy, this will determine how frequent any schedules within the chain is evaluated.
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
62 changes: 62 additions & 0 deletions examples/schedulefleetautoscaler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
# Copyright 2024 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# [Stage:Dev]
# [FeatureFlag:ScheduledAutoscaler]
# Example of a FleetAutoscaler - this is used to scale a Fleet based on a schedule.
#

#
# For a full reference and details: https://agones.dev/site/docs/reference/fleetautoscaler/
#
apiVersion: autoscaling.agones.dev/v1
kind: FleetAutoscaler
metadata:
name: schedule-fleet-autoscaler
spec:
fleetName: fleet-example
policy:
# Schedule based policy for autoscaling.
type: Schedule
schedule:
between:
# The policy becomes eligible for application starting on July 4th, 2024 at 4:04 PM PST. If not set, the policy will immediately be eligible for application.
start: "2024-07-04T16:04:04-07:00"
# The policy becomes ineligible for application on Sept 21, 2100 at 4:04 PM PST. If not set, the policy will always be eligible for application (after the start time).
end: "2100-09-21T16:04:04-07:00"
activePeriod:
# Timezone to be used for the startCron field. Defaults to UTC if not set.
timezone: "America/Los_Angeles"
# Start applying the policy everyday at 1:00 AM PST. If not set, the policy will always be applied in the .between window.
# (Only eligible starting on Feb 20, 2100 at 4:04 PM).
startCron: "0 1 * * 0"
# Only apply the policy for 5 hours. If not set, the duration will be defaulted to always/indefinite.
duration: "5h"
# Policy to be applied during the activePeriod. Required.
policy:
type: Buffer
buffer:
bufferSize: 50
minReplicas: 100
maxReplicas: 2000
# The autoscaling sync strategy, this will determine how frequent the schedule is evaluated.
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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.16.0
github.com/robfig/cron/v3 v3.0.1
github.com/sirupsen/logrus v1.9.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z
github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg=
github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down
53 changes: 34 additions & 19 deletions install/helm/agones/templates/crds/_fleetautoscalerpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,23 @@
---
{{/* schema for a fleet autoscaler policy */}}
{{- define "fleetautoscaler.policy" }}
{{- if .includePolicy }}
policy:
type: object
required:
- type
properties:
{{- end }}
type:
type: string
enum:
- Buffer
- Webhook
- Counter
- List
{{- if .includeSchedulePolicy }}
- Schedule
{{- end }}
{{- if .includeChainPolicy }}
- Chain
{{- end }}
Expand Down Expand Up @@ -112,6 +117,33 @@ policy:
anyOf:
- type: integer
- type: string
{{- if .includeSchedulePolicy }}
schedule: # Defines when the policy is applied.
type: object
nullable: true
required:
- policy
properties:
between:
type: object
nullable: true
properties:
start: # Defines when to start evaluating the active period, must conform to RFC3339.
type: string
end: # Defines when to stop evaluating the active period, must conform to RFC3339.
type: string
activePeriod:
type: object
nullable: true
properties:
timezone: # Timezone to be used for the startCron field, must conform with the IANA Time Zone database (e.g. America/New_York).
type: string
startCron: # Cron expression defining when to start applying the policy. All TZ/CRON_TZ specification within startCron will be rejected, please use the timezone field above to specify a timezone. Must conform with UNIX CRON syntax.
type: string
duration: # The length of time the policy should be applied for (e.g. 2h45m).
type: string
{{- include "fleetautoscaler.policy" (dict "includeChainPolicy" false "includeSchedulePolicy" false "includePolicy" true) | indent 8 }}
{{- end }}
{{- if .includeChainPolicy }}
chain:
type: array
Expand All @@ -120,27 +152,10 @@ policy:
type: object
nullable: true
required:
- policy
- type
properties:
id: # The Id of a chain entry.
type: string
schedule: # Defines when the policy is applied.
type: object
properties:
between:
type: object
start: # Defines when to start evaluating the active period, must conform to RFC3339.
type: string
end: # Defines when to stop evaluating the active period, must conform to RFC3339.
type: string
activePeriod:
type: object
timezone: # Timezone to be used for the startCron field, must conform with the IANA Time Zone database (e.g. America/New_York).
type: string
startCron: # Cron expression defining when to start applying the policy. All TZ/CRON_TZ specification within startCron will be rejected, please use the timezone field above to specify a timezone. Must conform with UNIX CRON syntax.
type: string
duration: # The length of time the policy should be applied for (e.g. 2h45m).
type: string
{{- include "fleetautoscaler.policy" (dict "includeChainPolicy" false) | indent 12 }} # Defines which policy to apply during the active period. Required.
{{- include "fleetautoscaler.policy" (dict "includeChainPolicy" false "includeSchedulePolicy" true "includePolicy" false) | indent 6 }} # Defines which policy to apply during the active period. Required.
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion install/helm/agones/templates/crds/fleetautoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spec:
maxLength: 63
pattern: "^[a-z0-9]([-\\.a-z0-9]*[a-z0-9])?$"
{{- $featureGates := include "agones.featureGates" . | fromYaml }}
{{- include "fleetautoscaler.policy" (dict "includeChainPolicy" $featureGates.ScheduledAutoscaler) | indent 16 }}
{{- include "fleetautoscaler.policy" (dict "includeChainPolicy" $featureGates.ScheduledAutoscaler "includeSchedulePolicy" $featureGates.ScheduledAutoscaler "includePolicy" true) | indent 16 }}
sync:
type: object
required:
Expand Down
Loading
Loading