Skip to content

Commit

Permalink
feat: support grpc message size as env
Browse files Browse the repository at this point in the history
Signed-off-by: pashakostohrys <[email protected]>
  • Loading branch information
pasha-codefresh committed Apr 4, 2024
1 parent 44da206 commit 73cdfa4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
7 changes: 5 additions & 2 deletions cmpserver/apiclient/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package apiclient

import (
"context"
"github.com/argoproj/argo-cd/v2/common"
"github.com/argoproj/argo-cd/v2/util/env"
"math"
"time"

grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
Expand All @@ -14,9 +17,9 @@ import (
"github.com/argoproj/argo-cd/v2/util/io"
)

const (
var (
// MaxGRPCMessageSize contains max grpc message size
MaxGRPCMessageSize = 100 * 1024 * 1024
MaxGRPCMessageSize = env.ParseNumFromEnv(common.EnvArgoCDgRPCMaxSizeMB, 100, 0, math.MaxInt32) * 1024 * 1024
)

// Clientset represents config management plugin server api clients
Expand Down
2 changes: 2 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ const (
// EnvServerSideDiff defines the env var used to enable ServerSide Diff feature.
// If defined, value must be "true" or "false".
EnvServerSideDiff = "ARGOCD_APPLICATION_CONTROLLER_SERVER_SIDE_DIFF"
// EnvArgoCDgRPCMaxSizeMB is the environment variable to look for a max gRPC message size
EnvArgoCDgRPCMaxSizeMB = "ARGOCD_GRPC_MAX_SIZE_MB"
)

// Config Management Plugin related constants
Expand Down
4 changes: 1 addition & 3 deletions pkg/apiclient/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,11 @@ const (
EnvArgoCDServer = "ARGOCD_SERVER"
// EnvArgoCDAuthToken is the environment variable to look for an Argo CD auth token
EnvArgoCDAuthToken = "ARGOCD_AUTH_TOKEN"
// EnvArgoCDgRPCMaxSizeMB is the environment variable to look for a max gRPC message size
EnvArgoCDgRPCMaxSizeMB = "ARGOCD_GRPC_MAX_SIZE_MB"
)

var (
// MaxGRPCMessageSize contains max grpc message size
MaxGRPCMessageSize = env.ParseNumFromEnv(EnvArgoCDgRPCMaxSizeMB, 200, 0, math.MaxInt32) * 1024 * 1024
MaxGRPCMessageSize = env.ParseNumFromEnv(common.EnvArgoCDgRPCMaxSizeMB, 200, 0, math.MaxInt32) * 1024 * 1024
)

// Client defines an interface for interaction with an Argo CD server.
Expand Down
7 changes: 5 additions & 2 deletions reposerver/apiclient/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"github.com/argoproj/argo-cd/v2/common"
"github.com/argoproj/argo-cd/v2/util/env"
"math"
"time"

grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
Expand All @@ -19,9 +22,9 @@ import (

//go:generate go run github.com/vektra/mockery/[email protected] --name=RepoServerServiceClient

const (
var (
// MaxGRPCMessageSize contains max grpc message size
MaxGRPCMessageSize = 100 * 1024 * 1024
MaxGRPCMessageSize = env.ParseNumFromEnv(common.EnvArgoCDgRPCMaxSizeMB, 100, 0, math.MaxInt32) * 1024 * 1024
)

// TLSConfiguration describes parameters for TLS configuration to be used by a repo server API client
Expand Down

0 comments on commit 73cdfa4

Please sign in to comment.