From 54621048dd6ba0b062a2f260f11b9fe63570553c Mon Sep 17 00:00:00 2001 From: Ryan Emerson Date: Mon, 19 May 2025 12:01:56 +0100 Subject: [PATCH 1/2] DON'T MERGE. Add test image with /health/* endpoints --- config/manager/manager.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index bbf9c6b79..cf858808a 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -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" @@ -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 From 9b7a32a2523fad4a556d752ff00b953f9bce4c00 Mon Sep 17 00:00:00 2001 From: Ryan Emerson Date: Tue, 20 May 2025 10:22:51 +0100 Subject: [PATCH 2/2] [infinispan/infinispan#14802] Use /health/live and /heath/ready probes in supported servers --- .../infinispan/handler/provision/pods.go | 41 +++++++++++++++++-- test/e2e/infinispan/upgrade_operand_test.go | 4 +- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/pkg/reconcile/pipeline/infinispan/handler/provision/pods.go b/pkg/reconcile/pipeline/infinispan/handler/provision/pods.go index 148de07fc..8c475d7c7 100644 --- a/pkg/reconcile/pipeline/infinispan/handler/provision/pods.go +++ b/pkg/reconcile/pipeline/infinispan/handler/provision/pods.go @@ -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{ diff --git a/test/e2e/infinispan/upgrade_operand_test.go b/test/e2e/infinispan/upgrade_operand_test.go index adf3587b6..e92a38940 100644 --- a/test/e2e/infinispan/upgrade_operand_test.go +++ b/test/e2e/infinispan/upgrade_operand_test.go @@ -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) @@ -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 } }