Skip to content

Commit eb4e514

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

File tree

1 file changed

+37
-4
lines changed
  • pkg/reconcile/pipeline/infinispan/handler/provision

1 file changed

+37
-4
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 decoupledProbes(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 decoupledProbes(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 decoupledProbes(operand) {
73+
return livenessProbe(i.Spec.Service.Container.StartupProbe)
74+
}
75+
return legacyHealthProbe(i.Spec.Service.Container.StartupProbe, operand)
76+
}
77+
78+
func decoupledProbes(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{

0 commit comments

Comments
 (0)