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

Increase readiness and liveness probe timeouts, introduce an initial delay #438

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
24 changes: 21 additions & 3 deletions pkg/resources/jobs/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ func NewRunnerJob(k6 v1alpha1.TestRunI, index int, token string) (*batchv1.Job,
VolumeMounts: volumeMounts,
Ports: ports,
EnvFrom: k6.GetSpec().Runner.EnvFrom,
LivenessProbe: generateProbe(k6.GetSpec().Runner.LivenessProbe),
ReadinessProbe: generateProbe(k6.GetSpec().Runner.ReadinessProbe),
LivenessProbe: generateLivenessProbe(k6.GetSpec().Runner.LivenessProbe),
ReadinessProbe: generateReadinessProbe(k6.GetSpec().Runner.ReadinessProbe),
SecurityContext: &k6.GetSpec().Runner.ContainerSecurityContext,
}},
TerminationGracePeriodSeconds: &zero,
Expand Down Expand Up @@ -276,11 +276,29 @@ func newAntiAffinity() *corev1.Affinity {
}
}

func generateProbe(configuredProbe *corev1.Probe) *corev1.Probe {
func generateLivenessProbe(configuredProbe *corev1.Probe) *corev1.Probe {
if configuredProbe != nil {
return configuredProbe
}
return &corev1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Port: intstr.IntOrString{IntVal: 6565},
Scheme: "HTTP",
},
},
}
}

func generateReadinessProbe(configuredProbe *corev1.Probe) *corev1.Probe {
if configuredProbe != nil {
return configuredProbe
}
return &corev1.Probe{
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand Down
33 changes: 33 additions & 0 deletions pkg/resources/jobs/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ func TestNewRunnerJob(t *testing.T) {
},
},
LivenessProbe: &corev1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand All @@ -348,6 +350,7 @@ func TestNewRunnerJob(t *testing.T) {
},
},
ReadinessProbe: &corev1.Probe{
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand Down Expand Up @@ -463,6 +466,8 @@ func TestNewRunnerJobNoisy(t *testing.T) {
VolumeMounts: script.VolumeMount(),
Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
LivenessProbe: &corev1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand All @@ -472,6 +477,7 @@ func TestNewRunnerJobNoisy(t *testing.T) {
},
},
ReadinessProbe: &corev1.Probe{
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand Down Expand Up @@ -578,6 +584,8 @@ func TestNewRunnerJobUnpaused(t *testing.T) {
VolumeMounts: script.VolumeMount(),
Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
LivenessProbe: &corev1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand All @@ -587,6 +595,7 @@ func TestNewRunnerJobUnpaused(t *testing.T) {
},
},
ReadinessProbe: &corev1.Probe{
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand Down Expand Up @@ -693,6 +702,8 @@ func TestNewRunnerJobArguments(t *testing.T) {
VolumeMounts: script.VolumeMount(),
Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
LivenessProbe: &corev1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand All @@ -702,6 +713,7 @@ func TestNewRunnerJobArguments(t *testing.T) {
},
},
ReadinessProbe: &corev1.Probe{
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand Down Expand Up @@ -809,6 +821,8 @@ func TestNewRunnerJobServiceAccount(t *testing.T) {
VolumeMounts: script.VolumeMount(),
Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
LivenessProbe: &corev1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand All @@ -818,6 +832,7 @@ func TestNewRunnerJobServiceAccount(t *testing.T) {
},
},
ReadinessProbe: &corev1.Probe{
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand Down Expand Up @@ -939,6 +954,8 @@ func TestNewRunnerJobIstio(t *testing.T) {
VolumeMounts: script.VolumeMount(),
Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
LivenessProbe: &corev1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand All @@ -948,6 +965,7 @@ func TestNewRunnerJobIstio(t *testing.T) {
},
},
ReadinessProbe: &corev1.Probe{
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand Down Expand Up @@ -1064,6 +1082,8 @@ func TestNewRunnerJobCloud(t *testing.T) {
VolumeMounts: script.VolumeMount(),
Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
LivenessProbe: &corev1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand All @@ -1073,6 +1093,7 @@ func TestNewRunnerJobCloud(t *testing.T) {
},
},
ReadinessProbe: &corev1.Probe{
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand Down Expand Up @@ -1181,6 +1202,8 @@ func TestNewRunnerJobLocalFile(t *testing.T) {
VolumeMounts: script.VolumeMount(),
Ports: []corev1.ContainerPort{{ContainerPort: 6565}},
LivenessProbe: &corev1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand All @@ -1190,6 +1213,7 @@ func TestNewRunnerJobLocalFile(t *testing.T) {
},
},
ReadinessProbe: &corev1.Probe{
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand Down Expand Up @@ -1323,6 +1347,8 @@ func TestNewRunnerJobWithInitContainer(t *testing.T) {
},
},
LivenessProbe: &corev1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand All @@ -1332,6 +1358,7 @@ func TestNewRunnerJobWithInitContainer(t *testing.T) {
},
},
ReadinessProbe: &corev1.Probe{
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand Down Expand Up @@ -1502,6 +1529,8 @@ func TestNewRunnerJobWithVolume(t *testing.T) {
},
},
LivenessProbe: &corev1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand All @@ -1511,6 +1540,7 @@ func TestNewRunnerJobWithVolume(t *testing.T) {
},
},
ReadinessProbe: &corev1.Probe{
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand Down Expand Up @@ -1672,6 +1702,8 @@ func TestNewRunnerJobPLZTestRun(t *testing.T) {
},
},
LivenessProbe: &corev1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand All @@ -1681,6 +1713,7 @@ func TestNewRunnerJobPLZTestRun(t *testing.T) {
},
},
ReadinessProbe: &corev1.Probe{
TimeoutSeconds: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/v1/status",
Expand Down
Loading