allow kb granularity for lua shared dicts (#6750)

Update internal/ingress/controller/template/configmap.go

Co-authored-by: Ricardo Katz <rikatz@users.noreply.github.com>

Co-authored-by: Ricardo Katz <rikatz@users.noreply.github.com>
This commit is contained in:
Matthew Silverman 2021-08-12 14:13:50 -04:00 committed by GitHub
parent b510b0e930
commit b591adac48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 140 additions and 34 deletions

View file

@ -60,8 +60,8 @@ const (
stateComment
)
// TemplateWriter is the interface to render a template
type TemplateWriter interface {
// Writer is the interface to render a template
type Writer interface {
Write(conf config.TemplateConfig) ([]byte, error)
}
@ -329,7 +329,8 @@ func buildLuaSharedDictionaries(c interface{}, s interface{}) string {
}
for name, size := range cfg.LuaSharedDicts {
out = append(out, fmt.Sprintf("lua_shared_dict %s %dM", name, size))
sizeStr := dictKbToStr(size)
out = append(out, fmt.Sprintf("lua_shared_dict %s %s", name, sizeStr))
}
sort.Strings(out)
@ -341,16 +342,16 @@ func luaConfigurationRequestBodySize(c interface{}) string {
cfg, ok := c.(config.Configuration)
if !ok {
klog.Errorf("expected a 'config.Configuration' type but %T was returned", c)
return "100" // just a default number
return "100M" // just a default number
}
size := cfg.LuaSharedDicts["configuration_data"]
if size < cfg.LuaSharedDicts["certificate_data"] {
size = cfg.LuaSharedDicts["certificate_data"]
}
size = size + 1
size = size + 1024
return fmt.Sprintf("%d", size)
return dictKbToStr(size)
}
// configForLua returns some general configuration as Lua table represented as string