Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add readinessProbe to target allocator deployment for operator #2374

Merged
merged 6 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/ta-readiness-probe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
component: operator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: add readiness probe to target allocator deployment generation

# One or more tracking issues related to the change
issues: [2258]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
25 changes: 17 additions & 8 deletions internal/manifests/targetallocator/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ func Container(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelem
if otelcol.Spec.TargetAllocator.PrometheusCR.Enabled {
args = append(args, "--enable-prometheus-cr-watcher")
}
readinessProbe := &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/readyz",
Port: intstr.FromInt(8080),
},
},
}
livenessProbe := &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Expand All @@ -81,13 +89,14 @@ func Container(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelem

envVars = append(envVars, proxy.ReadProxyVarsFromEnv()...)
return corev1.Container{
Name: naming.TAContainer(),
Image: image,
Ports: ports,
Env: envVars,
VolumeMounts: volumeMounts,
Resources: otelcol.Spec.TargetAllocator.Resources,
Args: args,
LivenessProbe: livenessProbe,
Name: naming.TAContainer(),
Image: image,
Ports: ports,
Env: envVars,
VolumeMounts: volumeMounts,
Resources: otelcol.Spec.TargetAllocator.Resources,
Args: args,
LivenessProbe: livenessProbe,
ReadinessProbe: readinessProbe,
}
}
40 changes: 40 additions & 0 deletions internal/manifests/targetallocator/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ func TestContainerHasEnvVars(t *testing.T) {
Protocol: corev1.ProtocolTCP,
},
},
ReadinessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/readyz",
Port: intstr.FromInt(8080),
},
},
},
LivenessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Expand Down Expand Up @@ -287,6 +295,14 @@ func TestContainerDoesNotOverrideEnvVars(t *testing.T) {
Protocol: corev1.ProtocolTCP,
},
},
ReadinessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/readyz",
Port: intstr.FromInt(8080),
},
},
},
LivenessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Expand All @@ -303,6 +319,30 @@ func TestContainerDoesNotOverrideEnvVars(t *testing.T) {
// verify
assert.Equal(t, expected, c)
}
func TestReadinessProbe(t *testing.T) {
otelcol := v1alpha1.OpenTelemetryCollector{
Spec: v1alpha1.OpenTelemetryCollectorSpec{
TargetAllocator: v1alpha1.OpenTelemetryTargetAllocator{
Enabled: true,
},
},
}
cfg := config.New()
expected := &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/readyz",
Port: intstr.FromInt(8080),
},
},
}

// test
c := Container(cfg, logger, otelcol)

// verify
assert.Equal(t, expected, c.ReadinessProbe)
}
func TestLivenessProbe(t *testing.T) {
// prepare
otelcol := v1alpha1.OpenTelemetryCollector{
Expand Down
7 changes: 7 additions & 0 deletions tests/e2e/targetallocator-features/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ spec:
volumeMounts:
- mountPath: /conf
name: ta-internal
readinessProbe:
httpGet:
path: /readyz
successThreshold: 1
failureThreshold: 3
timeoutSeconds: 1
periodSeconds: 10
livenessProbe:
httpGet:
path: /livez
Expand Down
Loading