Skip to content

Commit

Permalink
feat(server): support changing MaxGRPCMessageSize using env variable (#…
Browse files Browse the repository at this point in the history
…6420)

* add support changing MaxGRPCMessageSize using env variable: GRPC_MESSAGE_SIZE to argo-server

Signed-off-by: David Peer <david.peer@mobileye.com>

* fixed formatting

Signed-off-by: David Peer <david.peer@mobileye.com>

* updated check-env-doc.sh to cover ./server code as well

Signed-off-by: David Peer <david.peer@mobileye.com>

* fix linting in argoserver.go

Signed-off-by: David Peer <david.peer@mobileye.com>

* moved GRPC server start message logging

Signed-off-by: David Peer <david.peer@mobileye.com>

* updated logging for GRPC Max message size

Signed-off-by: David Peer <david.peer@mobileye.com>

Co-authored-by: David Peer <david.peer@mobileye.com>
  • Loading branch information
dpeer6 and David Peer authored Jul 28, 2021
1 parent 51c1576 commit dc043ce
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
31 changes: 31 additions & 0 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,37 @@ Note that these environment variables may be removed at any time.
| `WORKFLOW_GC_PERIOD` | `time.Duration` | `5m` | The periodicity for GC of workflows. |
| `BUBBLE_ENTRY_TEMPLATE_ERR` | `bool` | `true` | Whether to bubble up template errors to workflow. |
| `INFORMER_WRITE_BACK` | `bool` | `true` | Whether to write back to informer instead of catching up. |
| `GRPC_MESSAGE_SIZE` | `string` | Use different GRPC Max message size for Argo server deployment (supporting huge workflows) |

You can set environment variable for the argo-server deployment, for example:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: argo-server
spec:
selector:
matchLabels:
app: argo-server
template:
metadata:
labels:
app: argo-server
spec:
containers:
- args:
- server
image: argoproj/argocli:latest
name: argo-server
env:
- name: GRPC_MESSAGE_SIZE
value: "209715200"
ports:
..
...
....
```

You can set the environment variables for controller in controller's container spec like the following:

Expand Down
2 changes: 1 addition & 1 deletion hack/check-env-doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function check-used {
| while read -r x; do
var="${x%\`}";
var="${var#\`}";
if ! grep -qR --exclude="*_test.go" "$var" ./workflow ./persist ./util; then
if ! grep -qR --exclude="*_test.go" "$var" ./workflow ./persist ./util ./server; then
echo "Documented variable $var in docs/environment-variables.md is not used anywhere";
exit 1;
fi;
Expand Down
19 changes: 14 additions & 5 deletions server/apiserver/argoserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"google.golang.org/grpc/credentials"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/rest"
"k8s.io/utils/env"

"github.com/argoproj/argo-workflows/v3"
"github.com/argoproj/argo-workflows/v3/config"
Expand Down Expand Up @@ -57,10 +58,7 @@ import (
"github.com/argoproj/argo-workflows/v3/workflow/hydrator"
)

const (
// MaxGRPCMessageSize contains max grpc message size
MaxGRPCMessageSize = 100 * 1024 * 1024
)
var MaxGRPCMessageSize int

type argoServer struct {
baseHRef string
Expand Down Expand Up @@ -97,6 +95,14 @@ type ArgoServerOpts struct {
AccessControlAllowOrigin string
}

func init() {
var err error
MaxGRPCMessageSize, err = env.GetInt("GRPC_MESSAGE_SIZE", 100*1024*1024)
if err != nil {
log.Fatalf("GRPC_MESSAGE_SIZE environment variable must be set as an integer: %v", err)
}
}

func NewArgoServer(ctx context.Context, opts ArgoServerOpts) (*argoServer, error) {
configController := config.NewController(opts.Namespace, opts.ConfigName, opts.Clients.Kubernetes, emptyConfigFunc)
ssoIf := sso.NullSSO
Expand Down Expand Up @@ -210,6 +216,9 @@ func (as *argoServer) Run(ctx context.Context, port int, browserOpenFunc func(st
if as.tlsConfig != nil {
url = "https://localhost" + address
}
log.WithFields(log.Fields{
"GRPC_MESSAGE_SIZE": MaxGRPCMessageSize,
}).Info("GRPC Server Max Message Size, MaxGRPCMessageSize, is set")
log.Infof("Argo Server started successfully on %s", url)
browserOpenFunc(url)

Expand All @@ -223,7 +232,7 @@ func (as *argoServer) newGRPCServer(instanceIDService instanceid.Service, offloa
grpc_prometheus.EnableHandlingTimeHistogram()

sOpts := []grpc.ServerOption{
// Set both the send and receive the bytes limit to be 100MB
// Set both the send and receive the bytes limit to be 100MB or GRPC_MESSAGE_SIZE
// The proper way to achieve high performance is to have pagination
// while we work toward that, we can have high limit first
grpc.MaxRecvMsgSize(MaxGRPCMessageSize),
Expand Down

0 comments on commit dc043ce

Please sign in to comment.