From 9648d7392363cc5d4622b28576c3f40c573fb47b Mon Sep 17 00:00:00 2001 From: Ratnakar Date: Wed, 29 Nov 2023 08:51:22 -0500 Subject: [PATCH] Change the probes from legacy endpoints to tcp ports (#155) https://github.com/hyperledger-labs/fabric-operator/issues/154 Signed-off-by: asararatnakar --- .../base/orderer/override/deployment.go | 21 +++++++++++++++++++ pkg/offering/base/peer/override/deployment.go | 19 +++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/pkg/offering/base/orderer/override/deployment.go b/pkg/offering/base/orderer/override/deployment.go index 8220fa5f..35a97a1b 100644 --- a/pkg/offering/base/orderer/override/deployment.go +++ b/pkg/offering/base/orderer/override/deployment.go @@ -39,6 +39,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/intstr" logf "sigs.k8s.io/controller-runtime/pkg/log" ) @@ -107,10 +108,30 @@ func (o *Override) CreateDeployment(instance *current.IBPOrderer, k8sDep *appsv1 if err != nil { return errors.New("orderer container not found in deployment spec") } + grpcWeb, err := deployment.GetContainer(PROXY) if err != nil { return errors.New("proxy container not found in deployment spec") } + + // Change the legacy LivenessProbe from /settings endpoint to tcp port 8080 + if grpcWeb.LivenessProbe.Handler.TCPSocket == nil { + grpcWeb.LivenessProbe.Handler = corev1.Handler{ + TCPSocket: &corev1.TCPSocketAction{ + Port: intstr.FromInt(8080), + }, + } + } + + // Change the legacy ReadinessProbe from /settings endpoint to tcp port 8080 + if grpcWeb.ReadinessProbe.Handler.TCPSocket == nil { + grpcWeb.ReadinessProbe.Handler = corev1.Handler{ + TCPSocket: &corev1.TCPSocketAction{ + Port: intstr.FromInt(8080), + }, + } + } + _, err = deployment.GetContainer(INIT) if err != nil { return errors.New("init container not found in deployment spec") diff --git a/pkg/offering/base/peer/override/deployment.go b/pkg/offering/base/peer/override/deployment.go index 159cbb45..9d735ae1 100644 --- a/pkg/offering/base/peer/override/deployment.go +++ b/pkg/offering/base/peer/override/deployment.go @@ -42,6 +42,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/intstr" ) // Container names @@ -190,6 +191,24 @@ func (o *Override) CreateDeployment(instance *current.IBPPeer, k8sDep *appsv1.De grpcwebContainer.AppendEnvIfMissingOverrideIfPresent("SERVER_TLS_CLIENT_CA_FILES", certsData) peerContainer.AppendEnvIfMissingOverrideIfPresent("CORE_PEER_TLS_ROOTCERT_FILE", certsData) + // Change the legacy LivenessProbe from /settings endpoint to tcp port 8080 + if grpcwebContainer.LivenessProbe.Handler.TCPSocket == nil { + grpcwebContainer.LivenessProbe.Handler = corev1.Handler{ + TCPSocket: &corev1.TCPSocketAction{ + Port: intstr.FromInt(8080), + }, + } + } + + // Change the legacy ReadinessProbe from /settings endpoint to tcp port 8080 + if grpcwebContainer.ReadinessProbe.Handler.TCPSocket == nil { + grpcwebContainer.ReadinessProbe.Handler = corev1.Handler{ + TCPSocket: &corev1.TCPSocketAction{ + Port: intstr.FromInt(8080), + }, + } + } + // Check if intermediate tlscerts exists if util.IntermediateSecretExists(o.Client, instance.Namespace, tlsintercertSecret) { secretName := fmt.Sprintf("tls-%s-intercerts", instance.Name)