Skip to content

Commit

Permalink
update default liveness and readiness probes (#949)
Browse files Browse the repository at this point in the history
* update default liveness and readiness probes

* rm readiness probe from trace agent
  • Loading branch information
celenechang authored and fanny-jiang committed Oct 16, 2023
1 parent a033175 commit 3851153
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 34 deletions.
19 changes: 17 additions & 2 deletions apis/datadoghq/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
)

// GetDefaultLivenessProbe creates a all defaulted LivenessProbe
// GetDefaultLivenessProbe creates a defaulted LivenessProbe
func GetDefaultLivenessProbe() *corev1.Probe {
livenessProbe := &corev1.Probe{
InitialDelaySeconds: DefaultLivenessProbeInitialDelaySeconds,
Expand All @@ -30,7 +30,7 @@ func GetDefaultLivenessProbe() *corev1.Probe {
return livenessProbe
}

// GetDefaultReadinessProbe creates a all defaulted ReadynessProbe
// GetDefaultReadinessProbe creates a defaulted ReadinessProbe
func GetDefaultReadinessProbe() *corev1.Probe {
readinessProbe := &corev1.Probe{
InitialDelaySeconds: DefaultReadinessProbeInitialDelaySeconds,
Expand All @@ -48,6 +48,21 @@ func GetDefaultReadinessProbe() *corev1.Probe {
return readinessProbe
}

// GetDefaultTraceAgentProbe creates a defaulted liveness/readiness probe for the Trace Agent
func GetDefaultTraceAgentProbe() *corev1.Probe {
probe := &corev1.Probe{
InitialDelaySeconds: DefaultLivenessProbeInitialDelaySeconds,
PeriodSeconds: DefaultLivenessProbePeriodSeconds,
TimeoutSeconds: DefaultLivenessProbeTimeoutSeconds,
}
probe.TCPSocket = &corev1.TCPSocketAction{
Port: intstr.IntOrString{
IntVal: DefaultApmPort,
},
}
return probe
}

// GetImage builds the image string based on ImageConfig and the registry configuration.
func GetImage(imageSpec *commonv1.AgentImageConfig, registry *string) string {
if defaulting.IsImageNameContainsTag(imageSpec.Name) {
Expand Down
16 changes: 1 addition & 15 deletions apis/datadoghq/v1alpha1/datadogagent_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func DefaultDatadogAgentSpecAgentApm(agent *DatadogAgentSpecAgentSpec) *APMSpec
}

if agent.Apm.LivenessProbe == nil {
agent.Apm.LivenessProbe = getDefaultAPMAgentLivenessProbe()
agent.Apm.LivenessProbe = apicommon.GetDefaultTraceAgentProbe()
apmOverride.LivenessProbe = agent.Apm.LivenessProbe
}

Expand All @@ -562,20 +562,6 @@ func DefaultDatadogAgentSpecAgentApm(agent *DatadogAgentSpecAgentSpec) *APMSpec
return apmOverride
}

func getDefaultAPMAgentLivenessProbe() *corev1.Probe {
livenessProbe := &corev1.Probe{
InitialDelaySeconds: apicommon.DefaultLivenessProbeInitialDelaySeconds,
PeriodSeconds: apicommon.DefaultLivenessProbePeriodSeconds,
TimeoutSeconds: apicommon.DefaultLivenessProbeTimeoutSeconds,
}
livenessProbe.TCPSocket = &corev1.TCPSocketAction{
Port: intstr.IntOrString{
IntVal: defaultApmHostPort,
},
}
return livenessProbe
}

// DefaultDatadogAgentSpecAgentApmUDS used to default APMUnixDomainSocketSpec
// rreturn the defaulted APMUnixDomainSocketSpec
func DefaultDatadogAgentSpecAgentApmUDS(apm *APMSpec) *APMUnixDomainSocketSpec {
Expand Down
2 changes: 1 addition & 1 deletion apis/datadoghq/v1alpha1/datadogagent_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ func TestDefaultDatadogAgentSpecAgentApm(t *testing.T) {
want: &APMSpec{
HostPort: apiutils.NewInt32Pointer(8126),
UnixDomainSocket: &APMUnixDomainSocketSpec{Enabled: apiutils.NewBoolPointer(false)},
LivenessProbe: getDefaultAPMAgentLivenessProbe(),
LivenessProbe: apicommon.GetDefaultTraceAgentProbe(),
},
},
}
Expand Down
25 changes: 9 additions & 16 deletions controllers/datadogagent/component/agent/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,9 @@ func traceAgentContainer(dda metav1.Object) corev1.Container {
"trace-agent",
fmt.Sprintf("--config=%s", apicommon.AgentCustomConfigVolumePath),
},
Env: commonEnvVars(dda),
VolumeMounts: volumeMountsForTraceAgent(),
LivenessProbe: apicommon.GetDefaultLivenessProbe(),
ReadinessProbe: apicommon.GetDefaultReadinessProbe(),
Env: commonEnvVars(dda),
VolumeMounts: volumeMountsForTraceAgent(),
LivenessProbe: apicommon.GetDefaultTraceAgentProbe(),
}
}

Expand All @@ -155,10 +154,8 @@ func processAgentContainer(dda metav1.Object) corev1.Container {
"process-agent", fmt.Sprintf("--config=%s", apicommon.AgentCustomConfigVolumePath),
fmt.Sprintf("--sysprobe-config=%s", apicommon.SystemProbeConfigVolumePath),
},
Env: commonEnvVars(dda),
VolumeMounts: volumeMountsForProcessAgent(),
LivenessProbe: apicommon.GetDefaultLivenessProbe(),
ReadinessProbe: apicommon.GetDefaultReadinessProbe(),
Env: commonEnvVars(dda),
VolumeMounts: volumeMountsForProcessAgent(),
}
}

Expand All @@ -170,10 +167,8 @@ func securityAgentContainer(dda metav1.Object) corev1.Container {
"security-agent",
"start", fmt.Sprintf("-c=%s", apicommon.AgentCustomConfigVolumePath),
},
Env: envVarsForSecurityAgent(dda),
VolumeMounts: volumeMountsForSecurityAgent(),
LivenessProbe: apicommon.GetDefaultLivenessProbe(),
ReadinessProbe: apicommon.GetDefaultReadinessProbe(),
Env: envVarsForSecurityAgent(dda),
VolumeMounts: volumeMountsForSecurityAgent(),
}
}

Expand All @@ -185,10 +180,8 @@ func systemProbeContainer(dda metav1.Object) corev1.Container {
"system-probe",
fmt.Sprintf("--config=%s", apicommon.SystemProbeConfigVolumePath),
},
Env: commonEnvVars(dda),
VolumeMounts: volumeMountsForSystemProbe(),
LivenessProbe: apicommon.GetDefaultLivenessProbe(),
ReadinessProbe: apicommon.GetDefaultReadinessProbe(),
Env: commonEnvVars(dda),
VolumeMounts: volumeMountsForSystemProbe(),
SecurityContext: &corev1.SecurityContext{
SeccompProfile: &corev1.SeccompProfile{
Type: corev1.SeccompProfileTypeLocalhost,
Expand Down

0 comments on commit 3851153

Please sign in to comment.