From b2b0e120614dd94bae3e04926bf596733a48df0c Mon Sep 17 00:00:00 2001 From: Venkatreddy KP Date: Sat, 2 Mar 2024 19:38:11 +0530 Subject: [PATCH] set grpc client keep alive timeout --- capten/common-pkg/vault-cred/vault_cred_client.go | 11 ++++++++++- capten/go.mod | 1 + capten/go.sum | 2 ++ charts/kad/Chart.yaml | 4 ++-- .../kad/templates/deployment-worker-deployment.yaml | 2 ++ charts/server/Chart.yaml | 4 ++-- server/pkg/agent/client.go | 6 ++++++ 7 files changed, 25 insertions(+), 5 deletions(-) diff --git a/capten/common-pkg/vault-cred/vault_cred_client.go b/capten/common-pkg/vault-cred/vault_cred_client.go index b0c42f1a..195da333 100644 --- a/capten/common-pkg/vault-cred/vault_cred_client.go +++ b/capten/common-pkg/vault-cred/vault_cred_client.go @@ -3,12 +3,15 @@ package vaultcred import ( "context" "fmt" + "time" + "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/timeout" "github.com/kelseyhightower/envconfig" managedcluster "github.com/kube-tarian/kad/capten/common-pkg/managed-cluster" "github.com/kube-tarian/kad/capten/common-pkg/vault-cred/vaultcredpb" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/keepalive" v1 "k8s.io/api/core/v1" ) @@ -22,7 +25,13 @@ func GetAppRoleToken(appRoleName string, credentialPaths []string) (string, erro return "", fmt.Errorf("vault cred config read failed, %v", err) } - vc, err := grpc.Dial(conf.VaultCredAddress, grpc.WithTransportCredentials(insecure.NewCredentials())) + vc, err := grpc.Dial(conf.VaultCredAddress, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithUnaryInterceptor(timeout.UnaryClientInterceptor(60*time.Second)), + grpc.WithKeepaliveParams(keepalive.ClientParameters{ + Time: 30, // seconds + Timeout: 10, // seconds + })) if err != nil { return "", fmt.Errorf("failed to connect vauld-cred server, %v", err) } diff --git a/capten/go.mod b/capten/go.mod index 3fb59a3a..efcba15b 100644 --- a/capten/go.mod +++ b/capten/go.mod @@ -8,6 +8,7 @@ require ( github.com/gogo/status v1.1.1 github.com/golang-migrate/migrate/v4 v4.15.2 github.com/google/uuid v1.3.1 + github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0 github.com/hashicorp/go-multierror v1.1.1 github.com/intelops/go-common v1.0.22 github.com/kelseyhightower/envconfig v1.4.0 diff --git a/capten/go.sum b/capten/go.sum index 402a0df1..e572e3f0 100644 --- a/capten/go.sum +++ b/capten/go.sum @@ -1172,6 +1172,8 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmg github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= +github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0 h1:2cz5kSrxzMYHiWOBbKj8itQm+nRykkB8aMv4ThcHYHA= +github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0/go.mod h1:w9Y7gY31krpLmrVU5ZPG9H7l9fZuRu5/3R3S3FMtVQ4= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= diff --git a/charts/kad/Chart.yaml b/charts/kad/Chart.yaml index 97be3fc4..18f48147 100644 --- a/charts/kad/Chart.yaml +++ b/charts/kad/Chart.yaml @@ -15,10 +15,10 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.2.15 +version: 0.2.16 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "1.25.0" +appVersion: "1.25.1" diff --git a/charts/kad/templates/deployment-worker-deployment.yaml b/charts/kad/templates/deployment-worker-deployment.yaml index 0034ef84..991deb41 100644 --- a/charts/kad/templates/deployment-worker-deployment.yaml +++ b/charts/kad/templates/deployment-worker-deployment.yaml @@ -47,6 +47,8 @@ spec: value: "{{ .Values.temporal.temporalServiceURL }}.{{ .Release.Namespace }}.svc.cluster.local:7233" - name: PORT value: "{{ .Values.service.port }}" + - name: HOME + value: /tmp - name: CASSANDRA_SERVICE_URL value: "{{ .Values.cassandra.serviceURL }}" - name: CASSANDRA_KEYSPACE_NAME diff --git a/charts/server/Chart.yaml b/charts/server/Chart.yaml index b6bfc812..79ad70e0 100644 --- a/charts/server/Chart.yaml +++ b/charts/server/Chart.yaml @@ -15,10 +15,10 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.26 +version: 0.1.27 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "1.26.0" +appVersion: "1.26.1" diff --git a/server/pkg/agent/client.go b/server/pkg/agent/client.go index f0cff663..23cd69b4 100644 --- a/server/pkg/agent/client.go +++ b/server/pkg/agent/client.go @@ -19,6 +19,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/keepalive" "google.golang.org/grpc/metadata" ) @@ -78,6 +79,11 @@ func getConnection(cfg *Config, oryClient oryclient.OryClient) (*grpc.ClientConn dialOptions := []grpc.DialOption{ grpc.WithUnaryInterceptor(timeout.UnaryClientInterceptor(60 * time.Second)), + grpc.WithKeepaliveParams(keepalive.ClientParameters{ + Time: 30, // seconds + Timeout: 10, // seconds + PermitWithoutStream: true, + }), } if cfg.AuthEnabled {