Skip to content

Use /health/live and /health/ready probes in supported servers #2281

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ spec:
"upstream-version": "15.0.14",
"image": "quay.io/infinispan/server:15.0.14.Final"
},
{
"upstream-version": "15.0.15",
"image": "quay.io/infinispan-test/server:14870"
},
{
"upstream-version": "15.1.0",
"image": "quay.io/infinispan/server:15.1.0.Final"
Expand Down Expand Up @@ -159,6 +163,10 @@ spec:
{
"upstream-version": "15.2.1",
"image": "quay.io/infinispan/server:15.2.1.Final"
},
{
"upstream-version": "15.2.2",
"image": "quay.io/infinispan-test/server:15.2.x"
}
]
- name: POD_NAME
Expand Down
41 changes: 37 additions & 4 deletions pkg/reconcile/pipeline/infinispan/handler/provision/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,59 @@ func PodLifecycle() *corev1.Lifecycle {

func PodLivenessProbe(i *ispnv1.Infinispan, operand version.Operand) *corev1.Probe {
i.InitServiceContainer()
return probe(i.Spec.Service.Container.LivenessProbe, operand)
if DecoupledProbesSupported(operand) {
return livenessProbe(i.Spec.Service.Container.LivenessProbe)
}
return legacyHealthProbe(i.Spec.Service.Container.LivenessProbe, operand)
}

func PodReadinessProbe(i *ispnv1.Infinispan, operand version.Operand) *corev1.Probe {
i.InitServiceContainer()
return probe(i.Spec.Service.Container.ReadinessProbe, operand)
if DecoupledProbesSupported(operand) {
return readinessProbe(i.Spec.Service.Container.ReadinessProbe)
}
return legacyHealthProbe(i.Spec.Service.Container.ReadinessProbe, operand)
}

func PodStartupProbe(i *ispnv1.Infinispan, operand version.Operand) *corev1.Probe {
i.InitServiceContainer()
return probe(i.Spec.Service.Container.StartupProbe, operand)
if DecoupledProbesSupported(operand) {
return livenessProbe(i.Spec.Service.Container.StartupProbe)
}
return legacyHealthProbe(i.Spec.Service.Container.StartupProbe, operand)
}

func DecoupledProbesSupported(operand version.Operand) bool {
u := operand.UpstreamVersion
switch u.Major {
case 14:
return false
case 15:
return u.Minor == 0 && u.Patch > 14 || u.Minor == 2 && u.Patch > 1
default:
return true
}
}

func probe(p ispnv1.ContainerProbeSpec, operand version.Operand) *corev1.Probe {
func livenessProbe(p ispnv1.ContainerProbeSpec) *corev1.Probe {
return probe(p, "/health/live")
}

func readinessProbe(p ispnv1.ContainerProbeSpec) *corev1.Probe {
return probe(p, "/health/ready")
}

func legacyHealthProbe(p ispnv1.ContainerProbeSpec, operand version.Operand) *corev1.Probe {
var path string
if operand.UpstreamVersion.GTE(semver.Version{Major: 15}) {
path = "rest/v2/container/health/status"
} else {
path = "rest/v2/cache-managers/default/health/status"
}
return probe(p, path)
}

func probe(p ispnv1.ContainerProbeSpec, path string) *corev1.Probe {
return &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/infinispan/upgrade_operand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ func TestScaleDownBlockedWithDegradedCache(t *testing.T) {
}

// specImageOperands() returns two latest Operands with the matching major/minor version
// If two Operands are not available that support the /health/* endpoints, older Operands are provided
func specImageOperands() (*version.Operand, *version.Operand) {
operands := tutils.VersionManager().Operands
length := len(operands)
Expand All @@ -466,7 +467,8 @@ func specImageOperands() (*version.Operand, *version.Operand) {
latest = operands[length-1-i]
latestMinus1 = operands[length-2-i]
if latest.UpstreamVersion.Major == latestMinus1.UpstreamVersion.Major &&
latest.UpstreamVersion.Minor == latestMinus1.UpstreamVersion.Minor {
latest.UpstreamVersion.Minor == latestMinus1.UpstreamVersion.Minor &&
provision.DecoupledProbesSupported(*latest) == provision.DecoupledProbesSupported(*latestMinus1) {
return latestMinus1, latest
}
}
Expand Down
Loading