Expose etcd client MaxCallSendMsgSize config

The etcdv3 client has a default request send limit of 2.0 MiB. This change
exposes the configuration option to increase that limit enabling larger
state using the etcdv3 backend.

This also requires that the corresponding --max-request-bytes flag be
increased on the server side. The default there is 1.5 MiB.

Fixes https://github.com/hashicorp/terraform/issues/25745
This commit is contained in:
Jason Smith 2021-03-12 17:38:58 -06:00
parent 271352620b
commit d1608d7a7f

View File

@ -15,6 +15,7 @@ const (
usernameEnvVarName = "ETCDV3_USERNAME"
passwordKey = "password"
passwordEnvVarName = "ETCDV3_PASSWORD"
maxRequestBytesKey = "max_request_bytes"
prefixKey = "prefix"
lockKey = "lock"
cacertPathKey = "cacert_path"
@ -49,6 +50,13 @@ func New() backend.Backend {
DefaultFunc: schema.EnvDefaultFunc(passwordEnvVarName, ""),
},
maxRequestBytesKey: &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Description: "The max request size to send to etcd.",
Default: 0,
},
prefixKey: &schema.Schema{
Type: schema.TypeString,
Optional: true,
@ -128,6 +136,9 @@ func (b *Backend) rawClient() (*etcdv3.Client, error) {
if v, ok := b.data.GetOk(passwordKey); ok && v.(string) != "" {
config.Password = v.(string)
}
if v, ok := b.data.GetOk(maxRequestBytesKey); ok && v.(int) != 0 {
config.MaxCallSendMsgSize = v.(int)
}
if v, ok := b.data.GetOk(cacertPathKey); ok && v.(string) != "" {
tlsInfo.TrustedCAFile = v.(string)
}