Skip to content

Commit

Permalink
Change slow start to create strategy (#1416) (#1420)
Browse files Browse the repository at this point in the history
  • Loading branch information
khewonc authored Sep 13, 2024
1 parent f7ef0be commit a685f28
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 261 deletions.
2 changes: 1 addition & 1 deletion api/datadoghq/common/envvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,5 @@ const (

// DatadogAgentProfile env var names
const (
SlowStartEnabled = "DD_DAP_SLOW_START_ENABLED"
CreateStrategyEnabled = "DD_DAP_CREATE_STRATEGY_ENABLED"
)
18 changes: 9 additions & 9 deletions api/datadoghq/v1alpha1/datadogagentprofile_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import (
)

type ComponentName string
type SlowStartStatus string
type CreateStrategyStatus string

const (
// NodeAgentComponentName is the name of the Datadog Node Agent
NodeAgentComponentName ComponentName = "nodeAgent"

CompletedStatus SlowStartStatus = "Completed"
WaitingStatus SlowStartStatus = "Waiting"
InProgressStatus SlowStartStatus = "In Progress"
CompletedStatus CreateStrategyStatus = "Completed"
WaitingStatus CreateStrategyStatus = "Waiting"
InProgressStatus CreateStrategyStatus = "In Progress"
)

// DatadogAgentProfileSpec defines the desired state of DatadogAgentProfile
Expand Down Expand Up @@ -105,18 +105,18 @@ type DatadogAgentProfileStatus struct {
// +optional
Applied metav1.ConditionStatus `json:"applied,omitempty"`

// SlowStart is the state of the slow start feature.
// CreateStrategy is the state of the create strategy feature.
// +optional
SlowStart *SlowStart `json:"slowStart,omitempty"`
CreateStrategy *CreateStrategy `json:"CreateStrategy,omitempty"`
}

// SlowStart defines the observed state of the slow start feature based on the agent deployment.
// CreateStrategy defines the observed state of the create strategy feature based on the agent deployment.
// +k8s:openapi-gen=true
// +kubebuilder:object:generate=true
type SlowStart struct {
type CreateStrategy struct {
// Status shows the current state of the feature.
// +optional
Status SlowStartStatus `json:"status,omitempty"`
Status CreateStrategyStatus `json:"status,omitempty"`

// NodesLabeled shows the number of nodes currently labeled.
// +optional
Expand Down
44 changes: 22 additions & 22 deletions api/datadoghq/v1alpha1/zz_generated.deepcopy.go

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

114 changes: 57 additions & 57 deletions api/datadoghq/v1alpha1/zz_generated.openapi.go

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

46 changes: 23 additions & 23 deletions config/crd/bases/v1/datadoghq.com_datadogagentprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,29 @@ spec:
status:
description: DatadogAgentProfileStatus defines the observed state of DatadogAgentProfile
properties:
CreateStrategy:
description: CreateStrategy is the state of the create strategy feature.
properties:
lastTransition:
description: LastTransition is the last time the status was updated.
format: date-time
type: string
maxUnavailable:
description: MaxUnavailable shows the number of pods that can be in an unready state.
format: int32
type: integer
nodesLabeled:
description: NodesLabeled shows the number of nodes currently labeled.
format: int32
type: integer
podsReady:
description: PodsReady shows the number of pods in the ready state.
format: int32
type: integer
status:
description: Status shows the current state of the feature.
type: string
type: object
applied:
description: Applied shows whether the DatadogAgentProfile conflicts with an existing DatadogAgentProfile.
type: string
Expand Down Expand Up @@ -407,29 +430,6 @@ spec:
description: LastUpdate is the last time the status was updated.
format: date-time
type: string
slowStart:
description: SlowStart is the state of the slow start feature.
properties:
lastTransition:
description: LastTransition is the last time the status was updated.
format: date-time
type: string
maxUnavailable:
description: MaxUnavailable shows the number of pods that can be in an unready state.
format: int32
type: integer
nodesLabeled:
description: NodesLabeled shows the number of nodes currently labeled.
format: int32
type: integer
podsReady:
description: PodsReady shows the number of pods in the ready state.
format: int32
type: integer
status:
description: Status shows the current state of the feature.
type: string
type: object
valid:
description: Valid shows if the DatadogAgentProfile has a valid config spec.
type: string
Expand Down
22 changes: 11 additions & 11 deletions internal/controller/datadogagent/controller_reconcile_v2_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,21 @@ func (r *Reconciler) createOrUpdateDaemonset(parentLogger logr.Logger, dda *data

if alreadyExists {
now := metav1.NewTime(time.Now())
if agentprofile.SlowStartEnabled() {
if profile.Status.SlowStart != nil {
profile.Status.SlowStart.PodsReady = currentDaemonset.Status.NumberReady
if agentprofile.CreateStrategyEnabled() {
if profile.Status.CreateStrategy != nil {
profile.Status.CreateStrategy.PodsReady = currentDaemonset.Status.NumberReady
}
if shouldCheckSlowStartStatus(profile) {
if shouldCheckCreateStrategyStatus(profile) {
newStatus := v1alpha1.WaitingStatus

if int(profile.Status.SlowStart.NodesLabeled-currentDaemonset.Status.NumberReady) < int(profile.Status.SlowStart.MaxUnavailable) {
if int(profile.Status.CreateStrategy.NodesLabeled-currentDaemonset.Status.NumberReady) < int(profile.Status.CreateStrategy.MaxUnavailable) {
newStatus = v1alpha1.InProgressStatus
}

if profile.Status.SlowStart.Status != newStatus {
profile.Status.SlowStart.LastTransition = &now
if profile.Status.CreateStrategy.Status != newStatus {
profile.Status.CreateStrategy.LastTransition = &now
}
profile.Status.SlowStart.Status = newStatus
profile.Status.CreateStrategy.Status = newStatus
}
r.updateDAPStatus(logger, profile)
}
Expand Down Expand Up @@ -391,7 +391,7 @@ func ensureSelectorInPodTemplateLabels(logger logr.Logger, selector *metav1.Labe
return labels
}

func shouldCheckSlowStartStatus(profile *v1alpha1.DatadogAgentProfile) bool {
func shouldCheckCreateStrategyStatus(profile *v1alpha1.DatadogAgentProfile) bool {
if profile == nil {
return false
}
Expand All @@ -400,9 +400,9 @@ func shouldCheckSlowStartStatus(profile *v1alpha1.DatadogAgentProfile) bool {
return false
}

if profile.Status.SlowStart == nil {
if profile.Status.CreateStrategy == nil {
return false
}

return profile.Status.SlowStart.Status != v1alpha1.CompletedStatus
return profile.Status.CreateStrategy.Status != v1alpha1.CompletedStatus
}
Loading

0 comments on commit a685f28

Please sign in to comment.