Skip to content

Commit

Permalink
Fix some names in common Autoscaler types (#1706)
Browse files Browse the repository at this point in the history
  • Loading branch information
vboulineau authored Feb 18, 2025
1 parent cf9ddc3 commit bd4ad0b
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 194 deletions.
74 changes: 37 additions & 37 deletions api/datadoghq/common/datadogpodautoscaler_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ const (
// DatadogPodAutoscalerAutoUpdateStrategy is the default mode.
DatadogPodAutoscalerAutoUpdateStrategy DatadogPodAutoscalerUpdateStrategy = "Auto"

// DatadogPodAutoscalerDisabledUpdateStrategy will disable the update of the target resource.
// DatadogPodAutoscalerDisabledUpdateStrategy will disable the update of the target workload.
DatadogPodAutoscalerDisabledUpdateStrategy DatadogPodAutoscalerUpdateStrategy = "Disabled"
)

// DatadogPodAutoscalerUpdatePolicy defines the policy to update the target resource.
// DatadogPodAutoscalerUpdatePolicy defines the policy to update the target workload.
// +kubebuilder:object:generate=true
type DatadogPodAutoscalerUpdatePolicy struct {
// Strategy defines the mode of the update policy.
Expand Down Expand Up @@ -63,7 +63,7 @@ const (
DatadogPodAutoscalerDisabledStrategySelect DatadogPodAutoscalerScalingStrategySelect = "Disabled"
)

// DatadogPodAutoscalerScalingPolicy defines the policy to scale the target resource.
// DatadogPodAutoscalerScalingPolicy defines the policy to scale the target workload.
// +kubebuilder:object:generate=true
type DatadogPodAutoscalerScalingPolicy struct {
// Strategy is used to specify which policy should be used.
Expand Down Expand Up @@ -115,74 +115,74 @@ type DatadogPodAutoscalerScalingRule struct {
PeriodSeconds int32 `json:"periodSeconds"`
}

// DatadogPodAutoscalerTargetType defines the type of the target.
// DatadogPodAutoscalerObjectiveType defines the type of the objective.
// +kubebuilder:validation:Enum:=PodResource;ContainerResource
type DatadogPodAutoscalerTargetType string
type DatadogPodAutoscalerObjectiveType string

const (
// DatadogPodAutoscalerPodResourceTargetType allows to set pod-level resource targets.
DatadogPodAutoscalerPodResourceTargetType DatadogPodAutoscalerTargetType = "PodResource"
// DatadogPodAutoscalerPodResourceObjectiveType allows to set pod-level resource objectives.
DatadogPodAutoscalerPodResourceObjectiveType DatadogPodAutoscalerObjectiveType = "PodResource"

// DatadogPodAutoscalerContainerResourceTargetType allows to set container-level resource targets.
DatadogPodAutoscalerContainerResourceTargetType DatadogPodAutoscalerTargetType = "ContainerResource"
// DatadogPodAutoscalerContainerResourceObjectiveType allows to set container-level resource objectives.
DatadogPodAutoscalerContainerResourceObjectiveType DatadogPodAutoscalerObjectiveType = "ContainerResource"
)

// DatadogPodAutoscalerObjective defines the objectives to reach and maintain for the target resource.
// DatadogPodAutoscalerObjective defines the objectives to reach and maintain for the target workload.
// +kubebuilder:object:generate=true
type DatadogPodAutoscalerObjective struct {
// Type sets the type of the target.
Type DatadogPodAutoscalerTargetType `json:"type"`
// Type sets the type of the objective.
Type DatadogPodAutoscalerObjectiveType `json:"type"`

// PodResource allows to set a pod-level resource target.
PodResource *DatadogPodAutoscalerResourceTarget `json:"podResource,omitempty"`
// PodResource allows to set a pod-level resource objective.
PodResource *DatadogPodAutoscalerPodResourceObjective `json:"podResource,omitempty"`

// ContainerResource allows to set a container-level resource target.
ContainerResource *DatadogPodAutoscalerContainerResourceTarget `json:"containerResource,omitempty"`
// ContainerResource allows to set a container-level resource objective.
ContainerResource *DatadogPodAutoscalerContainerResourceObjective `json:"containerResource,omitempty"`
}

// DatadogPodAutoscalerResourceTarget defines a pod-level resource target (for instance, CPU Utilization at 80%)
// For pod-level targets, resources are the sum of all containers resources.
// DatadogPodAutoscalerPodResourceObjective defines a pod-level resource objective (for instance, CPU Utilization at 80%)
// For pod-level objectives, resources are the sum of all containers resources.
// Utilization is computed from sum(usage) / sum(requests).
// +kubebuilder:object:generate=true
type DatadogPodAutoscalerResourceTarget struct {
type DatadogPodAutoscalerPodResourceObjective struct {
// Name is the name of the resource.
// +kubebuilder:validation:Enum:=cpu
Name corev1.ResourceName `json:"name"`

// Value is the value of the target.
Value DatadogPodAutoscalerTargetValue `json:"value"`
// Value is the value of the objective.
Value DatadogPodAutoscalerObjectiveValue `json:"value"`
}

// DatadogPodAutoscalerContainerResourceTarget defines a container-level resource target (for instance, CPU Utilization for container named "foo" at 80%)
// DatadogPodAutoscalerContainerResourceObjective defines a container-level resource objective (for instance, CPU Utilization for container named "foo" at 80%)
// +kubebuilder:object:generate=true
type DatadogPodAutoscalerContainerResourceTarget struct {
type DatadogPodAutoscalerContainerResourceObjective struct {
// Name is the name of the resource.
// +kubebuilder:validation:Enum:=cpu
Name corev1.ResourceName `json:"name"`

// Value is the value of the target.
Value DatadogPodAutoscalerTargetValue `json:"value"`
// Value is the value of the objective
Value DatadogPodAutoscalerObjectiveValue `json:"value"`

// Container is the name of the container.
Container string `json:"container"`
}

// DatadogPodAutoscalerTargetValueType specifies the type of metric being targeted, and should be either
// DatadogPodAutoscalerObjectiveValueType specifies the type of objective value.
// kubebuilder:validation:Enum:=Utilization
type DatadogPodAutoscalerTargetValueType string
type DatadogPodAutoscalerObjectiveValueType string

const (
// DatadogPodAutoscalerUtilizationTargetValueType declares a MetricTarget is an AverageUtilization value
DatadogPodAutoscalerUtilizationTargetValueType DatadogPodAutoscalerTargetValueType = "Utilization"
// DatadogPodAutoscalerUtilizationObjectiveValueType declares an objective based on a Utilization (percentage, 0-100).
DatadogPodAutoscalerUtilizationObjectiveValueType DatadogPodAutoscalerObjectiveValueType = "Utilization"
)

// DatadogPodAutoscalerTargetValue defines the value of the target.
// DatadogPodAutoscalerObjectiveValue defines the target value of the objective.
// +kubebuilder:object:generate=true
type DatadogPodAutoscalerTargetValue struct {
// Type specifies how the value is expressed (Absolute or Utilization).
Type DatadogPodAutoscalerTargetValueType `json:"type"`
type DatadogPodAutoscalerObjectiveValue struct {
// Type specifies how the value is expressed (possible values: Utilization).
Type DatadogPodAutoscalerObjectiveValueType `json:"type"`

// Utilization defines a percentage of the target compared to requested resource
// Utilization defines a percentage of the target compared to requested workload
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=100
Utilization *int32 `json:"utilization,omitempty"`
Expand Down Expand Up @@ -252,7 +252,7 @@ type DatadogPodAutoscalerStatus struct {
Conditions []DatadogPodAutoscalerCondition `json:"conditions,omitempty"`
}

// DatadogPodAutoscalerValueSource defines the source of the value used to scale the target resource.
// DatadogPodAutoscalerValueSource defines the source of the value used to scale the target workload.
type DatadogPodAutoscalerValueSource string

const (
Expand All @@ -279,13 +279,13 @@ type DatadogPodAutoscalerHorizontalStatus struct {
// DatadogPodAutoscalerHorizontalTargetStatus defines the current target of the horizontal scaling
// +kubebuilder:object:generate=true
type DatadogPodAutoscalerHorizontalTargetStatus struct {
// Source is the source of the value used to scale the target resource
// Source is the source of the value used to scale the target workload
Source DatadogPodAutoscalerValueSource `json:"source"`

// GeneratedAt is the timestamp at which the recommendation was generated
GeneratedAt metav1.Time `json:"generatedAt,omitempty"`

// Replicas is the desired number of replicas for the resource
// Replicas is the desired number of replicas for the workload
Replicas int32 `json:"desiredReplicas"`
}

Expand Down
60 changes: 30 additions & 30 deletions api/datadoghq/common/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions api/datadoghq/v1alpha2/datadogpodautoscaler_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/DataDog/datadog-operator/api/datadoghq/v1alpha1"
)

Expand All @@ -17,7 +19,10 @@ func NewDatadogPodAutoscalerFromV1Alpha1(in *v1alpha1.DatadogPodAutoscaler) *Dat
// As many types are shared, we'll assign the deep copied value to the new object
in = in.DeepCopy()
out := &DatadogPodAutoscaler{
TypeMeta: in.TypeMeta,
TypeMeta: metav1.TypeMeta{
Kind: "DatadogPodAutoscaler",
APIVersion: "datadoghq.com/v1alpha2",
},
ObjectMeta: in.ObjectMeta,
Spec: ConvertDatadogPodAutoscalerSpecFromV1Alpha1(in.Spec),
Status: in.Status,
Expand Down Expand Up @@ -61,7 +66,10 @@ func NewDatadogPodAutoscalerToV1Alpha1(in *DatadogPodAutoscaler) *v1alpha1.Datad
// As many types are shared, we'll assign the deep copied value to the new object
in = in.DeepCopy()
out := &v1alpha1.DatadogPodAutoscaler{
TypeMeta: in.TypeMeta,
TypeMeta: metav1.TypeMeta{
Kind: "DatadogPodAutoscaler",
APIVersion: "datadoghq.com/v1alpha1",
},
ObjectMeta: in.ObjectMeta,
Spec: ConvertDatadogPodAutoscalerSpecToV1Alpha1(in.Spec),
Status: in.Status,
Expand Down
Loading

0 comments on commit bd4ad0b

Please sign in to comment.