Skip to content
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
38 changes: 34 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,56 @@ 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 {
switch operand.UpstreamVersion.Major {
case 14, 15:
return false
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 @@ -588,6 +588,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 @@ -597,7 +598,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