Skip to content

Commit 6519b79

Browse files
authored
[datadogpodautoscalers] Add local fallback policy (#1759)
* Fix missing apostrophe in dpa json * Add fallback policy and types * Generate files * Fix typo in apply policy name * Use new fallback policy type * Update fallback policy to only expose necessary options * Update comment to reflect how pod resource objectives are defined * Use bool for enabling fallback to reflect binary option * fixup! Use bool for enabling fallback to reflect binary option * Use fallback as top level for flexibility to add other fallback modes in future
1 parent cfeac2a commit 6519b79

File tree

5 files changed

+158
-2
lines changed

5 files changed

+158
-2
lines changed

api/datadoghq/v1alpha2/datadogpodautoscaler_types.go

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
// periodSeconds: 60
3737
// objectives:
3838
// - type: PodResource
39-
// resource:
39+
// podResource:
4040
// name: cpu
4141
// value:
4242
// type: Absolute|Utilization
@@ -49,6 +49,11 @@ import (
4949
// type: Absolute|Utilization
5050
// absolute: 500m
5151
// utilization: 80
52+
// fallback:
53+
// horizontal:
54+
// enabled: true
55+
// triggers:
56+
// staleRecommendationThresholdSeconds: 600
5257
// constraints:
5358
// minReplicas: 1
5459
// maxReplicas: 10
@@ -83,6 +88,11 @@ type DatadogPodAutoscalerSpec struct {
8388
// +kubebuilder:validation:MinItems=1
8489
Objectives []common.DatadogPodAutoscalerObjective `json:"objectives,omitempty"`
8590

91+
// Fallback defines how recommendations should be applied when in fallback mode.
92+
// +optional
93+
// +kubebuilder:default={}
94+
Fallback *DatadogFallbackPolicy `json:"fallback,omitempty"`
95+
8696
// Constraints defines constraints that should always be respected.
8797
Constraints *common.DatadogPodAutoscalerConstraints `json:"constraints,omitempty"`
8898
}
@@ -119,6 +129,37 @@ type DatadogPodAutoscalerApplyPolicy struct {
119129
ScaleDown *common.DatadogPodAutoscalerScalingPolicy `json:"scaleDown,omitempty"`
120130
}
121131

132+
// DatadogFallbackPolicy configures the behavior during fallback mode.
133+
type DatadogFallbackPolicy struct {
134+
// Horizontal configures the behavior during horizontal fallback mode.
135+
// +optional
136+
// +kubebuilder:default={}
137+
Horizontal DatadogPodAutoscalerHorizontalFallbackPolicy `json:"horizontal,omitempty"`
138+
}
139+
140+
// DatadogPodAutoscalerHorizontalFallbackPolicy defines how recommendations should be applied in fallback mode.
141+
type DatadogPodAutoscalerHorizontalFallbackPolicy struct {
142+
// Enabled determines whether recommendations should be applied by the controller:
143+
// +optional
144+
// +kubebuilder:default=true
145+
Enabled bool `json:"enabled"`
146+
147+
// Triggers defines the triggers that will generate recommendations.
148+
// +optional
149+
// +kubebuilder:default={}
150+
Triggers HorizontalFallbackTriggers `json:"triggers,omitempty"`
151+
}
152+
153+
// HorizontalFallbackTriggers defines the triggers that will cause local fallback to be enabled.
154+
type HorizontalFallbackTriggers struct {
155+
// StaleRecommendationThresholdSeconds defines the time window the controller will wait after detecting an error before applying recommendations.
156+
// +optional
157+
// +kubebuilder:default=600
158+
// +kubebuilder:validation:Minimum=100
159+
// +kubebuilder:validation:Maximum=1200
160+
StaleRecommendationThresholdSeconds int32 `json:"staleRecommendationThresholdSeconds,omitempty"`
161+
}
162+
122163
// +kubebuilder:object:root=true
123164
// +kubebuilder:resource:shortName=dpa
124165
// +kubebuilder:subresource:status

api/datadoghq/v1alpha2/zz_generated.deepcopy.go

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/v1/datadoghq.com_datadogpodautoscalers.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,32 @@ spec:
819819
required:
820820
- maxReplicas
821821
type: object
822+
fallback:
823+
default: {}
824+
description: Fallback defines how recommendations should be applied when in fallback mode.
825+
properties:
826+
horizontal:
827+
default: {}
828+
description: Horizontal configures the behavior during horizontal fallback mode.
829+
properties:
830+
enabled:
831+
default: true
832+
description: 'Enabled determines whether recommendations should be applied by the controller:'
833+
type: boolean
834+
triggers:
835+
default: {}
836+
description: Triggers defines the triggers that will generate recommendations.
837+
properties:
838+
staleRecommendationThresholdSeconds:
839+
default: 600
840+
description: StaleRecommendationThresholdSeconds defines the time window the controller will wait after detecting an error before applying recommendations.
841+
format: int32
842+
maximum: 1200
843+
minimum: 100
844+
type: integer
845+
type: object
846+
type: object
847+
type: object
822848
objectives:
823849
description: |-
824850
Objectives are the objectives to reach and maintain for the target resource.

config/crd/bases/v1/datadoghq.com_datadogpodautoscalers_v1alpha2.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,43 @@
279279
],
280280
"type": "object"
281281
},
282+
"fallback": {
283+
"additionalProperties": false,
284+
"default": {},
285+
"description": "Fallback defines how recommendations should be applied when in fallback mode.",
286+
"properties": {
287+
"horizontal": {
288+
"additionalProperties": false,
289+
"default": {},
290+
"description": "Horizontal configures the behavior during horizontal fallback mode.",
291+
"properties": {
292+
"enabled": {
293+
"default": true,
294+
"description": "Enabled determines whether recommendations should be applied by the controller:",
295+
"type": "boolean"
296+
},
297+
"triggers": {
298+
"additionalProperties": false,
299+
"default": {},
300+
"description": "Triggers defines the triggers that will generate recommendations.",
301+
"properties": {
302+
"staleRecommendationThresholdSeconds": {
303+
"default": 600,
304+
"description": "StaleRecommendationThresholdSeconds defines the time window the controller will wait after detecting an error before applying recommendations.",
305+
"format": "int32",
306+
"maximum": 1200,
307+
"minimum": 100,
308+
"type": "integer"
309+
}
310+
},
311+
"type": "object"
312+
}
313+
},
314+
"type": "object"
315+
}
316+
},
317+
"type": "object"
318+
},
282319
"objectives": {
283320
"description": "Objectives are the objectives to reach and maintain for the target resource.\nDefault to a single objective to maintain 80% POD CPU utilization.",
284321
"items": {

config/crd/bases/v1/datadoghq.com_datadogpodautoscalers_v2alpha1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
description": "DatadogPodAutoscaler is the Schema for the datadogpodautoscalers API",
2+
"description": "DatadogPodAutoscaler is the Schema for the datadogpodautoscalers API",
33
"properties": {
44
"apiVersion": {
55
"description": "APIVersion defines the versioned schema of this representation of an object.\nServers should convert recognized schemas to the latest internal value, and\nmay reject unrecognized values.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",

0 commit comments

Comments
 (0)