Skip to content

Commit

Permalink
Move UpdateStrategy from v2alpha1 to common/v1 (#1378)
Browse files Browse the repository at this point in the history
  • Loading branch information
levan-m committed Aug 28, 2024
1 parent a5d137d commit cba1ec6
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 131 deletions.
26 changes: 26 additions & 0 deletions apis/datadoghq/common/v1/agent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package common
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)

// AgentImageConfig defines the agent container image config.
Expand Down Expand Up @@ -126,3 +127,28 @@ type DeploymentStatus struct {
// DeploymentName corresponds to the name of the Deployment.
DeploymentName string `json:"deploymentName,omitempty"`
}

// The deployment strategy to use to replace existing pods with new ones.
// +k8s:openapi-gen=true
// +kubebuilder:object:generate=true
type UpdateStrategy struct {
// Type can be "RollingUpdate" or "OnDelete" for DaemonSets and "RollingUpdate"
// or "Recreate" for Deployments
Type string `json:"type,omitempty"`
// Configure the rolling update strategy of the Deployment or DaemonSet.
RollingUpdate *RollingUpdate `json:"rollingUpdate,omitempty"`
}

// RollingUpdate describes how to replace existing pods with new ones.
// +k8s:openapi-gen=true
// +kubebuilder:object:generate=true
type RollingUpdate struct {
// The maximum number of pods that can be unavailable during the update.
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
// Refer to the Kubernetes API documentation for additional details..
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`

// MaxSurge behaves differently based on the Kubernetes resource. Refer to the
// Kubernetes API documentation for additional details.
MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty"`
}
46 changes: 46 additions & 0 deletions apis/datadoghq/common/v1/zz_generated.deepcopy.go

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

26 changes: 1 addition & 25 deletions apis/datadoghq/v2alpha1/datadogagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package v2alpha1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"

commonv1 "github.com/DataDog/datadog-operator/apis/datadoghq/common/v1"
)
Expand Down Expand Up @@ -1278,7 +1277,7 @@ type DatadogAgentComponentOverride struct {

// The deployment strategy to use to replace existing pods with new ones.
// +optional
UpdateStrategy *UpdateStrategy `json:"updateStrategy,omitempty"`
UpdateStrategy *commonv1.UpdateStrategy `json:"updateStrategy,omitempty"`

// Configure the component tolerations.
// +optional
Expand Down Expand Up @@ -1383,29 +1382,6 @@ const (
SingleContainerStrategy ContainerStrategyType = "single"
)

// The deployment strategy to use to replace existing pods with new ones.
// +k8s:openapi-gen=true
type UpdateStrategy struct {
// Type can be "RollingUpdate" or "OnDelete" for DaemonSets and "RollingUpdate"
// or "Recreate" for Deployments
Type string `json:"type,omitempty"`
// Configure the rolling update strategy of the Deployment or DaemonSet.
RollingUpdate *RollingUpdate `json:"rollingUpdate,omitempty"`
}

// RollingUpdate describes how to replace existing pods with new ones.
// +k8s:openapi-gen=true
type RollingUpdate struct {
// The maximum number of pods that can be unavailable during the update.
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
// Refer to the Kubernetes API documentation for additional details..
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`

// MaxSurge behaves differently based on the Kubernetes resource. Refer to the
// Kubernetes API documentation for additional details.
MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty"`
}

// FIPSConfig contains the FIPS configuration.
// +k8s:openapi-gen=true
type FIPSConfig struct {
Expand Down
48 changes: 1 addition & 47 deletions apis/datadoghq/v2alpha1/zz_generated.deepcopy.go

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

57 changes: 0 additions & 57 deletions apis/datadoghq/v2alpha1/zz_generated.openapi.go

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

5 changes: 3 additions & 2 deletions controllers/datadogagent/override/daemonset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package override
import (
"testing"

commonv1 "github.com/DataDog/datadog-operator/apis/datadoghq/common/v1"
"github.com/DataDog/datadog-operator/apis/datadoghq/v2alpha1"
apiutils "github.com/DataDog/datadog-operator/apis/utils"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -144,9 +145,9 @@ func makeDaemonSet(strategyType *string, strategyMaxUnavailable *string, strateg

func makeOverride(strategyType *string, strategyMaxUnavailable *string, strategyMaxSurge *string) v2alpha1.DatadogAgentComponentOverride {
override := v2alpha1.DatadogAgentComponentOverride{
UpdateStrategy: &v2alpha1.UpdateStrategy{
UpdateStrategy: &commonv1.UpdateStrategy{
Type: "",
RollingUpdate: &v2alpha1.RollingUpdate{
RollingUpdate: &commonv1.RollingUpdate{
MaxUnavailable: &intstr.IntOrString{},
MaxSurge: &intstr.IntOrString{},
},
Expand Down

0 comments on commit cba1ec6

Please sign in to comment.