Skip to content

Commit

Permalink
feat(probe): add startup probes (#1234)
Browse files Browse the repository at this point in the history
Signed-off-by: Wassim DHIF <[email protected]>
  • Loading branch information
wdhif authored Jul 9, 2024
1 parent eb49fb8 commit b6bd845
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 1 deletion.
18 changes: 18 additions & 0 deletions apis/datadoghq/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ func GetDefaultReadinessProbe() *corev1.Probe {
return readinessProbe
}

// GetDefaultStartupProbe creates a defaulted StartupProbe
func GetDefaultStartupProbe() *corev1.Probe {
startupProbe := &corev1.Probe{
InitialDelaySeconds: DefaultStartupProbeInitialDelaySeconds,
PeriodSeconds: DefaultStartupProbePeriodSeconds,
TimeoutSeconds: DefaultStartupProbeTimeoutSeconds,
SuccessThreshold: DefaultStartupProbeSuccessThreshold,
FailureThreshold: DefaultStartupProbeFailureThreshold,
}
startupProbe.HTTPGet = &corev1.HTTPGetAction{
Path: DefaultStartupProbeHTTPPath,
Port: intstr.IntOrString{
IntVal: DefaultAgentHealthPort,
},
}
return startupProbe
}

// GetDefaultTraceAgentProbe creates a defaulted liveness/readiness probe for the Trace Agent
func GetDefaultTraceAgentProbe() *corev1.Probe {
probe := &corev1.Probe{
Expand Down
12 changes: 11 additions & 1 deletion apis/datadoghq/common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ const (
// DefaultHelmCheckConf default Helm Check ConfigMap name
DefaultHelmCheckConf string = "helm-check-config"

// DefaultAgentHealthPort default agent health port
DefaultAgentHealthPort int32 = 5555

// Liveness probe default config
DefaultLivenessProbeInitialDelaySeconds int32 = 15
DefaultLivenessProbePeriodSeconds int32 = 15
DefaultLivenessProbeTimeoutSeconds int32 = 5
DefaultLivenessProbeSuccessThreshold int32 = 1
DefaultLivenessProbeFailureThreshold int32 = 6
DefaultAgentHealthPort int32 = 5555
DefaultLivenessProbeHTTPPath = "/live"

// Readiness probe default config
Expand All @@ -98,6 +100,14 @@ const (
DefaultReadinessProbeFailureThreshold int32 = 6
DefaultReadinessProbeHTTPPath = "/ready"

// Startup probe default config
DefaultStartupProbeInitialDelaySeconds int32 = 15
DefaultStartupProbePeriodSeconds int32 = 15
DefaultStartupProbeTimeoutSeconds int32 = 5
DefaultStartupProbeSuccessThreshold int32 = 1
DefaultStartupProbeFailureThreshold int32 = 6
DefaultStartupProbeHTTPPath = "/startup"

// Default Image name
DefaultAgentImageName string = "agent"
DefaultClusterAgentImageName string = "cluster-agent"
Expand Down
18 changes: 18 additions & 0 deletions controllers/datadogagent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@ func defaultReadinessProbe() *corev1.Probe {
}
}

func defaultStartupProbe() *corev1.Probe {
return &corev1.Probe{
InitialDelaySeconds: 15,
PeriodSeconds: 15,
TimeoutSeconds: 5,
SuccessThreshold: 1,
FailureThreshold: 6,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/startup",
Port: intstr.IntOrString{
IntVal: 5555,
},
},
},
}
}

func defaultVolumes() []corev1.Volume {
return []corev1.Volume{
{
Expand Down
1 change: 1 addition & 0 deletions controllers/datadogagent/clusteragent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func clusterAgentDefaultPodSpec() corev1.PodSpec {
},
LivenessProbe: defaultLivenessProbe(),
ReadinessProbe: defaultReadinessProbe(),
StartupProbe: defaultStartupProbe(),
SecurityContext: &corev1.SecurityContext{
ReadOnlyRootFilesystem: apiutils.NewBoolPointer(true),
AllowPrivilegeEscalation: apiutils.NewBoolPointer(false),
Expand Down
1 change: 1 addition & 0 deletions controllers/datadogagent/component/agent/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func coreAgentContainer(dda metav1.Object) corev1.Container {
VolumeMounts: volumeMountsForCoreAgent(),
LivenessProbe: apicommon.GetDefaultLivenessProbe(),
ReadinessProbe: apicommon.GetDefaultReadinessProbe(),
StartupProbe: apicommon.GetDefaultStartupProbe(),
}
}

Expand Down
1 change: 1 addition & 0 deletions controllers/datadogagent/component/clusteragent/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func defaultPodSpec(dda metav1.Object, volumes []corev1.Volume, volumeMounts []c
VolumeMounts: volumeMounts,
LivenessProbe: apicommon.GetDefaultLivenessProbe(),
ReadinessProbe: apicommon.GetDefaultReadinessProbe(),
StartupProbe: apicommon.GetDefaultStartupProbe(),
Command: nil,
Args: nil,
SecurityContext: &corev1.SecurityContext{
Expand Down
19 changes: 19 additions & 0 deletions controllers/datadogagent/component/clusteragent/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func clusterAgentDefaultPodSpec() corev1.PodSpec {
},
LivenessProbe: defaultLivenessProbe(),
ReadinessProbe: defaultReadinessProbe(),
StartupProbe: defaultStartupProbe(),
SecurityContext: &corev1.SecurityContext{
ReadOnlyRootFilesystem: apiutils.NewBoolPointer(true),
AllowPrivilegeEscalation: apiutils.NewBoolPointer(false),
Expand Down Expand Up @@ -191,6 +192,24 @@ func defaultReadinessProbe() *corev1.Probe {
}
}

func defaultStartupProbe() *corev1.Probe {
return &corev1.Probe{
InitialDelaySeconds: 15,
PeriodSeconds: 15,
TimeoutSeconds: 5,
SuccessThreshold: 1,
FailureThreshold: 6,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/startup",
Port: intstr.IntOrString{
IntVal: 5555,
},
},
},
}
}

func clusterAgentDefaultEnvVars() []corev1.EnvVar {
return []corev1.EnvVar{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func defaultPodSpec(dda metav1.Object, volumes []corev1.Volume, volumeMounts []c
},
LivenessProbe: apicommon.GetDefaultLivenessProbe(),
ReadinessProbe: apicommon.GetDefaultReadinessProbe(),
StartupProbe: apicommon.GetDefaultStartupProbe(),
SecurityContext: &corev1.SecurityContext{
ReadOnlyRootFilesystem: apiutils.NewBoolPointer(true),
AllowPrivilegeEscalation: apiutils.NewBoolPointer(false),
Expand Down

0 comments on commit b6bd845

Please sign in to comment.