Skip to content

Commit 615ad22

Browse files
authored
fix(solace): set ulimits for container (#3497)
1 parent 00f2020 commit 615ad22

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

modules/solace/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ toolchain go1.24.7
77
require (
88
github.com/docker/docker v28.5.1+incompatible
99
github.com/docker/go-connections v0.6.0
10+
github.com/docker/go-units v0.5.0
1011
github.com/stretchr/testify v1.11.1
1112
github.com/testcontainers/testcontainers-go v0.40.0
1213
solace.dev/go/messaging v1.10.0
@@ -24,7 +25,6 @@ require (
2425
github.com/cpuguy83/dockercfg v0.3.2 // indirect
2526
github.com/davecgh/go-spew v1.1.1 // indirect
2627
github.com/distribution/reference v0.6.0 // indirect
27-
github.com/docker/go-units v0.5.0 // indirect
2828
github.com/ebitengine/purego v0.8.4 // indirect
2929
github.com/felixge/httpsnoop v1.0.4 // indirect
3030
github.com/go-logr/logr v1.4.3 // indirect

modules/solace/solace.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/docker/docker/api/types/container"
1313
"github.com/docker/go-connections/nat"
14+
"github.com/docker/go-units"
1415

1516
"github.com/testcontainers/testcontainers-go"
1617
"github.com/testcontainers/testcontainers-go/wait"
@@ -26,6 +27,15 @@ type Container struct {
2627
}
2728

2829
// Run starts a Solace container with the provided image and options
30+
//
31+
// The container requires specific ulimits to start successfully:
32+
// - nofile: 1048576 (number of open files)
33+
// - core: -1 (for core dumps)
34+
// - memlock: -1 (for memory locking)
35+
//
36+
// See https://docs.solace.com for more information.
37+
// - https://docs.solace.com/Software-Broker/Managing-Core-Files.htm
38+
// - https://docs.solace.com/Software-Broker/Container-Tasks/Config-Container-Storage.htm?Highlight=ulimit
2939
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error) {
3040
// Override default options with provided ones
3141
settings := defaultOptions()
@@ -57,6 +67,24 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
5767
testcontainers.WithExposedPorts(exposedPorts...),
5868
testcontainers.WithHostConfigModifier(func(hc *container.HostConfig) {
5969
hc.ShmSize = settings.shmSize
70+
// Where disk space permits, Solace docs recommends the core file size "rlimit" for event brokers to be "unlimited".
71+
hc.Ulimits = []*units.Ulimit{
72+
{
73+
Name: "nofile",
74+
Soft: 1048576,
75+
Hard: 1048576,
76+
},
77+
{
78+
Name: "core",
79+
Soft: -1,
80+
Hard: -1,
81+
},
82+
{
83+
Name: "memlock",
84+
Soft: -1,
85+
Hard: -1,
86+
},
87+
}
6088
}),
6189
testcontainers.WithWaitStrategy(waitStrategies...),
6290
}

0 commit comments

Comments
 (0)