Skip to content

Commit

Permalink
BUG: manage TuneOptions and SSL default dh param
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmatmati authored and oktalz committed Jan 24, 2024
1 parent 83dd6ec commit 7cebb7a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
68 changes: 67 additions & 1 deletion crs/converters/global-spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
package converters

import (
v3models "github.com/haproxytech/client-native/v3/models"
"github.com/haproxytech/client-native/v5/models"
corev1alpha2 "github.com/haproxytech/kubernetes-ingress/crs/api/core/v1alpha2"
v1 "github.com/haproxytech/kubernetes-ingress/crs/api/ingress/v1"
"github.com/haproxytech/kubernetes-ingress/pkg/utils"
)

func DeepConvertGlobalSpecA2toV1(o corev1alpha2.GlobalSpec) v1.GlobalSpec {
Expand Down Expand Up @@ -147,11 +149,11 @@ func DeepConvertGlobalSpecA2toV1(o corev1alpha2.GlobalSpec) v1.GlobalSpec {
cp.Config.SslModeAsync = o.Config.SslModeAsync
if o.Config.StatsTimeout != nil {
cp.Config.StatsTimeout = new(int64)

cp.Config.StatsTimeout = o.Config.StatsTimeout
}
cp.Config.TuneSslDefaultDhParam = o.Config.TuneSslDefaultDhParam
cp.Config.User = o.Config.User
cp.Config.TuneOptions = Convert(o.Config.TuneOptions)
}
if o.LogTargets != nil {
cp.LogTargets = make([]*models.LogTarget, len(o.LogTargets))
Expand All @@ -177,3 +179,67 @@ func DeepConvertGlobalSpecA2toV1(o corev1alpha2.GlobalSpec) v1.GlobalSpec {
}
return cp
}

func Convert(globalTuneOptions *v3models.GlobalTuneOptions) *models.GlobalTuneOptions {
if globalTuneOptions == nil {
return nil
}

globalTuneOptionsV5 := &models.GlobalTuneOptions{}

globalTuneOptionsV5.BuffersLimit = globalTuneOptions.BuffersLimit
globalTuneOptionsV5.BuffersReserve = globalTuneOptions.BuffersReserve
globalTuneOptionsV5.Bufsize = globalTuneOptions.Bufsize
globalTuneOptionsV5.CompMaxlevel = globalTuneOptions.CompMaxlevel
globalTuneOptionsV5.FailAlloc = globalTuneOptions.FailAlloc
globalTuneOptionsV5.H2FeMaxConcurrentStreams = globalTuneOptions.H2MaxConcurrentStreams
globalTuneOptionsV5.H2BeMaxConcurrentStreams = globalTuneOptions.H2MaxConcurrentStreams
globalTuneOptionsV5.H2FeInitialWindowSize = utils.PointerDefaultValueIfNil(globalTuneOptions.H2InitialWindowSize)
globalTuneOptionsV5.H2BeInitialWindowSize = utils.PointerDefaultValueIfNil(globalTuneOptions.H2InitialWindowSize)
globalTuneOptionsV5.H2HeaderTableSize = globalTuneOptions.H2HeaderTableSize
globalTuneOptionsV5.H2InitialWindowSize = globalTuneOptions.H2InitialWindowSize
globalTuneOptionsV5.H2MaxConcurrentStreams = globalTuneOptions.H2MaxConcurrentStreams
globalTuneOptionsV5.H2MaxFrameSize = globalTuneOptions.H2MaxFrameSize
globalTuneOptionsV5.HTTPCookielen = globalTuneOptions.HTTPCookielen
globalTuneOptionsV5.HTTPLogurilen = globalTuneOptions.HTTPLogurilen
globalTuneOptionsV5.HTTPMaxhdr = globalTuneOptions.HTTPMaxhdr
globalTuneOptionsV5.IdlePoolShared = globalTuneOptions.IdlePoolShared
globalTuneOptionsV5.Idletimer = globalTuneOptions.Idletimer
globalTuneOptionsV5.ListenerMultiQueue = globalTuneOptions.ListenerMultiQueue
globalTuneOptionsV5.LuaForcedYield = globalTuneOptions.LuaForcedYield
globalTuneOptionsV5.LuaMaxmem = globalTuneOptions.LuaMaxmem
globalTuneOptionsV5.LuaServiceTimeout = globalTuneOptions.LuaServiceTimeout
globalTuneOptionsV5.LuaSessionTimeout = globalTuneOptions.LuaSessionTimeout
globalTuneOptionsV5.LuaTaskTimeout = globalTuneOptions.LuaTaskTimeout
globalTuneOptionsV5.Maxaccept = globalTuneOptions.Maxaccept
globalTuneOptionsV5.Maxpollevents = globalTuneOptions.Maxpollevents
globalTuneOptionsV5.Maxrewrite = globalTuneOptions.Maxrewrite
globalTuneOptionsV5.PatternCacheSize = globalTuneOptions.PatternCacheSize
globalTuneOptionsV5.Pipesize = globalTuneOptions.Pipesize
globalTuneOptionsV5.PoolHighFdRatio = globalTuneOptions.PoolHighFdRatio
globalTuneOptionsV5.PoolLowFdRatio = globalTuneOptions.PoolLowFdRatio
globalTuneOptionsV5.RcvbufClient = globalTuneOptions.RcvbufClient
globalTuneOptionsV5.RcvbufServer = globalTuneOptions.RcvbufServer
globalTuneOptionsV5.RecvEnough = globalTuneOptions.RecvEnough
globalTuneOptionsV5.RunqueueDepth = globalTuneOptions.RunqueueDepth
globalTuneOptionsV5.SchedLowLatency = globalTuneOptions.SchedLowLatency
globalTuneOptionsV5.SndbufClient = globalTuneOptions.SndbufClient
globalTuneOptionsV5.SndbufServer = globalTuneOptions.SndbufServer
globalTuneOptionsV5.SslCachesize = globalTuneOptions.SslCachesize
globalTuneOptionsV5.SslCaptureBufferSize = globalTuneOptions.SslCaptureBufferSize
globalTuneOptionsV5.SslCtxCacheSize = globalTuneOptions.SslCtxCacheSize
globalTuneOptionsV5.SslDefaultDhParam = globalTuneOptions.SslDefaultDhParam
globalTuneOptionsV5.SslForcePrivateCache = globalTuneOptions.SslForcePrivateCache
globalTuneOptionsV5.SslKeylog = globalTuneOptions.SslKeylog
globalTuneOptionsV5.SslLifetime = globalTuneOptions.SslLifetime
globalTuneOptionsV5.SslMaxrecord = globalTuneOptions.SslMaxrecord
globalTuneOptionsV5.VarsGlobalMaxSize = globalTuneOptions.VarsGlobalMaxSize
globalTuneOptionsV5.VarsProcMaxSize = globalTuneOptions.VarsProcMaxSize
globalTuneOptionsV5.VarsReqresMaxSize = globalTuneOptions.VarsReqresMaxSize
globalTuneOptionsV5.VarsSessMaxSize = globalTuneOptions.VarsSessMaxSize
globalTuneOptionsV5.VarsTxnMaxSize = globalTuneOptions.VarsTxnMaxSize
globalTuneOptionsV5.ZlibMemlevel = globalTuneOptions.ZlibMemlevel
globalTuneOptionsV5.ZlibWindowsize = globalTuneOptions.ZlibWindowsize

return globalTuneOptionsV5
}
6 changes: 4 additions & 2 deletions pkg/controller/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ func (c *HAProxyController) globalCfg() {
}
}
if newGlobal.TuneOptions == nil {
newGlobal.TuneOptions = &models.GlobalTuneOptions{
SslDefaultDhParam: 2048,
newGlobal.TuneOptions = &models.GlobalTuneOptions{}

if newGlobal.TuneSslDefaultDhParam == 0 {
newGlobal.TuneOptions.SslDefaultDhParam = 2048
}
}
env.SetGlobal(newGlobal, &newLg, c.haproxy.Env)
Expand Down

0 comments on commit 7cebb7a

Please sign in to comment.