Skip to content

Commit

Permalink
Expose max-sync-message-size in options (#419)
Browse files Browse the repository at this point in the history
* expose max-sync-message-size in options with default value 10MiB

* rename flag to MaxCallSendMsgSize

* more user friendly resourceExhausted error

* make format

* make error message more robust

* fix typo

* remove fmt prints

* Update pkg/object/statussynccontroller/statussynccontroller.go

Co-authored-by: Bomin Zhang <[email protected]>

* Update pkg/object/statussynccontroller/statussynccontroller.go

Co-authored-by: Bomin Zhang <[email protected]>

Co-authored-by: Bomin Zhang <[email protected]>
  • Loading branch information
samutamm and localvar authored Dec 21, 2021
1 parent 34cd169 commit 554efe7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ func (c *cluster) getClient() (*clientv3.Client, error) {
DialKeepAliveTime: dialKeepAliveTime,
DialKeepAliveTimeout: dialKeepAliveTimeout,
LogConfig: logger.EtcdClientLoggerConfig(c.opt, logger.EtcdClientFilename),
MaxCallSendMsgSize: c.opt.Cluster.MaxCallSendMsgSize,
})
if err != nil {
return nil, fmt.Errorf("create client failed: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/object/statussynccontroller/statussynccontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ func (ssc *StatusSyncController) syncStatusToCluster(statuses map[string]string)

for k, v := range statuses {
k = ssc.superSpec.Super().Cluster().Layout().StatusObjectKey(k)
value := v
kvs[k] = &value
kvs[k] = &v
}

err := ssc.superSpec.Super().Cluster().PutAndDeleteUnderLease(kvs)
if err != nil {
logger.Errorf("sync status failed: %v", err)
logger.Errorf("sync status failed. If the message size is too large, "+
"please increase the value of cluster.MaxCallSendMsgSize in configuration: %v", err)
}
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/option/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type ClusterOptions struct {
StateFlag string `yaml:"state-flag"`
// Secondary members define URLs to connect to cluster formed by primary members.
PrimaryListenPeerURLs []string `yaml:"primary-listen-peer-urls"`
MaxCallSendMsgSize int `yaml:"max-call-send-msg-size"`
}

// Options is the start-up options.
Expand Down Expand Up @@ -128,6 +129,7 @@ func addClusterVars(opt *Options) {
"primary-listen-peer-urls",
[]string{"http://localhost:2380"},
"List of peer URLs of primary members. Define this only, when cluster-role is secondary.")
opt.flags.IntVar(&opt.Cluster.MaxCallSendMsgSize, "max-call-send-msg-size", 10*1024*1024, "Maximum size in bytes for cluster synchronization messages.")
}

// New creates a default Options.
Expand Down

0 comments on commit 554efe7

Please sign in to comment.