diff --git a/controllers/zero_controller.go b/controllers/zero_controller.go index bd53f63fc..6a31c1cb5 100644 --- a/controllers/zero_controller.go +++ b/controllers/zero_controller.go @@ -306,6 +306,7 @@ func (z *zeroCapacityController) isZeroPodReady(request reconcile.Request, ctx c } func (z *zeroCapacityController) zeroPodSpec(name, namespace string, podSecurityCtx *corev1.PodSecurityContext, ispn *v1.Infinispan, zeroSpec *zeroCapacitySpec) (*corev1.Pod, error) { + operand, _ := z.VersionManager.WithRef(ispn.Spec.Version) podResources, err := PodResources(zeroSpec.Container) if err != nil { return nil, err @@ -330,14 +331,14 @@ func (z *zeroCapacityController) zeroPodSpec(name, namespace string, podSecurity Name: InfinispanContainer, Env: PodEnv(ispn, &[]corev1.EnvVar{{Name: "IDENTITIES_BATCH", Value: consts.ServerOperatorSecurity + "/" + consts.ServerIdentitiesBatchFilename}}), Lifecycle: PodLifecycle(), - LivenessProbe: PodLivenessProbe(ispn), + LivenessProbe: PodLivenessProbe(ispn, operand), Ports: []corev1.ContainerPort{ {ContainerPort: consts.InfinispanAdminPort, Name: consts.InfinispanAdminPortName, Protocol: corev1.ProtocolTCP}, {ContainerPort: consts.InfinispanPingPort, Name: consts.InfinispanPingPortName, Protocol: corev1.ProtocolTCP}, }, - ReadinessProbe: PodReadinessProbe(ispn), + ReadinessProbe: PodReadinessProbe(ispn, operand), Resources: *podResources, - StartupProbe: PodStartupProbe(ispn), + StartupProbe: PodStartupProbe(ispn, operand), Args: []string{"-c", "operator/infinispan-zero.xml", "-l", OperatorConfMountPath + "/log4j.xml"}, VolumeMounts: []corev1.VolumeMount{ { diff --git a/pkg/reconcile/pipeline/infinispan/handler/manage/statefulset_updates.go b/pkg/reconcile/pipeline/infinispan/handler/manage/statefulset_updates.go index 30dc1bf3f..47c73a434 100644 --- a/pkg/reconcile/pipeline/infinispan/handler/manage/statefulset_updates.go +++ b/pkg/reconcile/pipeline/infinispan/handler/manage/statefulset_updates.go @@ -84,6 +84,7 @@ func StatefulSetRollingUpgrade(i *ispnv1.Infinispan, ctx pipeline.Context) { } } + requestedOperand := ctx.Operand() // Changes to probes probedChanged := func(current, new *corev1.Probe) bool { if reflect.DeepEqual(current, new) { @@ -92,12 +93,11 @@ func StatefulSetRollingUpgrade(i *ispnv1.Infinispan, ctx pipeline.Context) { *current = *new return true } - updateNeeded = probedChanged(container.LivenessProbe, provision.PodLivenessProbe(i)) || updateNeeded - updateNeeded = probedChanged(container.ReadinessProbe, provision.PodReadinessProbe(i)) || updateNeeded - updateNeeded = probedChanged(container.StartupProbe, provision.PodStartupProbe(i)) || updateNeeded + updateNeeded = probedChanged(container.LivenessProbe, provision.PodLivenessProbe(i, requestedOperand)) || updateNeeded + updateNeeded = probedChanged(container.ReadinessProbe, provision.PodReadinessProbe(i, requestedOperand)) || updateNeeded + updateNeeded = probedChanged(container.StartupProbe, provision.PodStartupProbe(i, requestedOperand)) || updateNeeded // Check if the base-image has been upgraded due to a CVE - requestedOperand := ctx.Operand() userProvidedImage := i.Spec.Image != nil if !userProvidedImage && requestedOperand.CVE && container.Image != requestedOperand.Image { ctx.Log().Info(fmt.Sprintf("CVE release '%s'. StatefulSet Rolling upgrade required", requestedOperand.Ref())) diff --git a/pkg/reconcile/pipeline/infinispan/handler/provision/pods.go b/pkg/reconcile/pipeline/infinispan/handler/provision/pods.go index 5ca6b5c51..a0c898b26 100644 --- a/pkg/reconcile/pipeline/infinispan/handler/provision/pods.go +++ b/pkg/reconcile/pipeline/infinispan/handler/provision/pods.go @@ -5,8 +5,10 @@ import ( "fmt" "os" + "github.com/blang/semver" ispnv1 "github.com/infinispan/infinispan-operator/api/v1" consts "github.com/infinispan/infinispan-operator/controllers/constants" + "github.com/infinispan/infinispan-operator/pkg/infinispan/version" kube "github.com/infinispan/infinispan-operator/pkg/kubernetes" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" @@ -48,24 +50,30 @@ func PodLifecycle() *corev1.Lifecycle { } } -func PodLivenessProbe(i *ispnv1.Infinispan) *corev1.Probe { - return probe(i.Spec.Service.Container.LivenessProbe) +func PodLivenessProbe(i *ispnv1.Infinispan, operand version.Operand) *corev1.Probe { + return probe(i.Spec.Service.Container.LivenessProbe, operand) } -func PodReadinessProbe(i *ispnv1.Infinispan) *corev1.Probe { - return probe(i.Spec.Service.Container.ReadinessProbe) +func PodReadinessProbe(i *ispnv1.Infinispan, operand version.Operand) *corev1.Probe { + return probe(i.Spec.Service.Container.ReadinessProbe, operand) } -func PodStartupProbe(i *ispnv1.Infinispan) *corev1.Probe { - return probe(i.Spec.Service.Container.StartupProbe) +func PodStartupProbe(i *ispnv1.Infinispan, operand version.Operand) *corev1.Probe { + return probe(i.Spec.Service.Container.StartupProbe, operand) } -func probe(p ispnv1.ContainerProbeSpec) *corev1.Probe { +func probe(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 &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ HTTPGet: &corev1.HTTPGetAction{ Scheme: corev1.URISchemeHTTP, - Path: "rest/v2/cache-managers/default/health/status", + Path: path, Port: intstr.FromInt(consts.InfinispanAdminPort)}, }, FailureThreshold: *p.FailureThreshold, diff --git a/pkg/reconcile/pipeline/infinispan/handler/provision/provision_test.go b/pkg/reconcile/pipeline/infinispan/handler/provision/provision_test.go index c1cfa1134..43079a9fe 100644 --- a/pkg/reconcile/pipeline/infinispan/handler/provision/provision_test.go +++ b/pkg/reconcile/pipeline/infinispan/handler/provision/provision_test.go @@ -3,8 +3,10 @@ package provision import ( "testing" + "github.com/blang/semver" "github.com/golang/mock/gomock" ispnv1 "github.com/infinispan/infinispan-operator/api/v1" + "github.com/infinispan/infinispan-operator/pkg/infinispan/version" "github.com/infinispan/infinispan-operator/pkg/reconcile/pipeline/infinispan" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -35,6 +37,7 @@ var _ = Describe("Provision", func() { }, ) ctx.EXPECT().Resources().Return(resources) + ctx.EXPECT().Operand().AnyTimes().Return(version.Operand{UpstreamVersion: &semver.Version{Major: 15, Minor: 0, Patch: 0}}) ispn := &ispnv1.Infinispan{ ObjectMeta: metav1.ObjectMeta{ diff --git a/pkg/reconcile/pipeline/infinispan/handler/provision/statefulsets.go b/pkg/reconcile/pipeline/infinispan/handler/provision/statefulsets.go index 7ee5f66ea..ee2759f0e 100644 --- a/pkg/reconcile/pipeline/infinispan/handler/provision/statefulsets.go +++ b/pkg/reconcile/pipeline/infinispan/handler/provision/statefulsets.go @@ -81,6 +81,7 @@ func ClusterStatefulSetSpec(statefulSetName string, i *ispnv1.Infinispan, ctx pi // We can ignore the err here as the validating webhook ensures that the resources are valid podResources, _ := PodResources(i.Spec.Container) + operand := ctx.Operand() statefulSet := &appsv1.StatefulSet{ TypeMeta: metav1.TypeMeta{ APIVersion: "apps/v1", @@ -111,10 +112,10 @@ func ClusterStatefulSetSpec(statefulSetName string, i *ispnv1.Infinispan, ctx pi Name: InfinispanContainer, Env: podEnvs, Lifecycle: PodLifecycle(), - LivenessProbe: PodLivenessProbe(i), + LivenessProbe: PodLivenessProbe(i, operand), Ports: PodPortsWithXsite(i), - ReadinessProbe: PodReadinessProbe(i), - StartupProbe: PodStartupProbe(i), + ReadinessProbe: PodReadinessProbe(i, operand), + StartupProbe: PodStartupProbe(i, operand), Resources: *podResources, VolumeMounts: []corev1.VolumeMount{{ Name: ConfigVolumeName,