Skip to content

Commit 9b7a32a

Browse files
committed
[infinispan/infinispan#14802] Use /health/live and /heath/ready probes in supported servers
1 parent 5462104 commit 9b7a32a

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

pkg/reconcile/pipeline/infinispan/handler/provision/pods.go

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,59 @@ func PodLifecycle() *corev1.Lifecycle {
5353

5454
func PodLivenessProbe(i *ispnv1.Infinispan, operand version.Operand) *corev1.Probe {
5555
i.InitServiceContainer()
56-
return probe(i.Spec.Service.Container.LivenessProbe, operand)
56+
if DecoupledProbesSupported(operand) {
57+
return livenessProbe(i.Spec.Service.Container.LivenessProbe)
58+
}
59+
return legacyHealthProbe(i.Spec.Service.Container.LivenessProbe, operand)
5760
}
5861

5962
func PodReadinessProbe(i *ispnv1.Infinispan, operand version.Operand) *corev1.Probe {
6063
i.InitServiceContainer()
61-
return probe(i.Spec.Service.Container.ReadinessProbe, operand)
64+
if DecoupledProbesSupported(operand) {
65+
return readinessProbe(i.Spec.Service.Container.ReadinessProbe)
66+
}
67+
return legacyHealthProbe(i.Spec.Service.Container.ReadinessProbe, operand)
6268
}
6369

6470
func PodStartupProbe(i *ispnv1.Infinispan, operand version.Operand) *corev1.Probe {
6571
i.InitServiceContainer()
66-
return probe(i.Spec.Service.Container.StartupProbe, operand)
72+
if DecoupledProbesSupported(operand) {
73+
return livenessProbe(i.Spec.Service.Container.StartupProbe)
74+
}
75+
return legacyHealthProbe(i.Spec.Service.Container.StartupProbe, operand)
76+
}
77+
78+
func DecoupledProbesSupported(operand version.Operand) bool {
79+
u := operand.UpstreamVersion
80+
switch u.Major {
81+
case 14:
82+
return false
83+
case 15:
84+
return u.Minor == 0 && u.Patch > 14 || u.Minor == 2 && u.Patch > 1
85+
default:
86+
return true
87+
}
6788
}
6889

69-
func probe(p ispnv1.ContainerProbeSpec, operand version.Operand) *corev1.Probe {
90+
func livenessProbe(p ispnv1.ContainerProbeSpec) *corev1.Probe {
91+
return probe(p, "/health/live")
92+
}
93+
94+
func readinessProbe(p ispnv1.ContainerProbeSpec) *corev1.Probe {
95+
return probe(p, "/health/ready")
96+
}
97+
98+
func legacyHealthProbe(p ispnv1.ContainerProbeSpec, operand version.Operand) *corev1.Probe {
7099
var path string
71100
if operand.UpstreamVersion.GTE(semver.Version{Major: 15}) {
72101
path = "rest/v2/container/health/status"
73102
} else {
74103
path = "rest/v2/cache-managers/default/health/status"
75104
}
105+
return probe(p, path)
106+
}
107+
108+
func probe(p ispnv1.ContainerProbeSpec, path string) *corev1.Probe {
76109
return &corev1.Probe{
77110
ProbeHandler: corev1.ProbeHandler{
78111
HTTPGet: &corev1.HTTPGetAction{

test/e2e/infinispan/upgrade_operand_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ func TestScaleDownBlockedWithDegradedCache(t *testing.T) {
457457
}
458458

459459
// specImageOperands() returns two latest Operands with the matching major/minor version
460+
// If two Operands are not available that support the /health/* endpoints, older Operands are provided
460461
func specImageOperands() (*version.Operand, *version.Operand) {
461462
operands := tutils.VersionManager().Operands
462463
length := len(operands)
@@ -466,7 +467,8 @@ func specImageOperands() (*version.Operand, *version.Operand) {
466467
latest = operands[length-1-i]
467468
latestMinus1 = operands[length-2-i]
468469
if latest.UpstreamVersion.Major == latestMinus1.UpstreamVersion.Major &&
469-
latest.UpstreamVersion.Minor == latestMinus1.UpstreamVersion.Minor {
470+
latest.UpstreamVersion.Minor == latestMinus1.UpstreamVersion.Minor &&
471+
provision.DecoupledProbesSupported(*latest) == provision.DecoupledProbesSupported(*latestMinus1) {
470472
return latestMinus1, latest
471473
}
472474
}

0 commit comments

Comments
 (0)