Skip to content

Commit 290c80d

Browse files
committed
chore(manifests): disable --auto-gomemlimit for Prometheus on SNO until we can ensure it won't result in excessive CPU usage
1 parent 89b863e commit 290c80d

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

pkg/manifests/manifests.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ func (f *Factory) PrometheusK8s(grpcTLS *v1.Secret, telemetrySecret *v1.Secret)
14561456
}
14571457

14581458
setupAlerting(p, platformAlertmanagerService, f.namespace)
1459-
f.setupGoGC(p)
1459+
f.adjustGoGCRelatedConfig(p)
14601460

14611461
for i, container := range p.Spec.Containers {
14621462
switch container.Name {
@@ -1495,7 +1495,7 @@ func (f *Factory) PrometheusK8s(grpcTLS *v1.Secret, telemetrySecret *v1.Secret)
14951495
return p, nil
14961496
}
14971497

1498-
func (f *Factory) setupGoGC(p *monv1.Prometheus) {
1498+
func (f *Factory) adjustGoGCRelatedConfig(p *monv1.Prometheus) {
14991499
if f.infrastructure.HighlyAvailableInfrastructure() {
15001500
return
15011501
}
@@ -1513,6 +1513,11 @@ func (f *Factory) setupGoGC(p *monv1.Prometheus) {
15131513
// be savvy on CPU hence set GOGC=100 (Go runtime default) in this
15141514
// case.
15151515
p.Spec.Containers[i].Env = append(p.Spec.Containers[i].Env, v1.EnvVar{Name: "GOGC", Value: "100"})
1516+
1517+
// Until we're certain setting GOMEMLIMIT to 0.9 (default ratio) of detected maximum
1518+
// container or system memory won't result in excessive CPU usage, we're disabling the
1519+
// auto setting for SNO.
1520+
p.Spec.Containers[i].Args = append(p.Spec.Containers[i].Args, "--no-auto-gomemlimit")
15161521
}
15171522
}
15181523

@@ -1805,7 +1810,7 @@ func (f *Factory) PrometheusUserWorkload(grpcTLS *v1.Secret) (*monv1.Prometheus,
18051810
}
18061811
}
18071812

1808-
f.setupGoGC(p)
1813+
f.adjustGoGCRelatedConfig(p)
18091814

18101815
if f.config.UserWorkloadConfiguration.Alertmanager.Enabled {
18111816
setupAlerting(p, userWorkloadAlertmanagerService, f.namespaceUserWorkload)

pkg/manifests/manifests_test.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4288,44 +4288,47 @@ func TestThanosRulerRetentionConfig(t *testing.T) {
42884288
}
42894289
}
42904290

4291-
func TestPrometheusGoGC(t *testing.T) {
4291+
func TestPrometheusGoGCRelatedConfig(t *testing.T) {
42924292
for _, tc := range []struct {
42934293
ir InfrastructureReader
42944294
promf func(*Factory) (*monv1.Prometheus, error)
42954295

4296-
exp string
4296+
expectedGOGC string
4297+
autoGOMEMLIMITDisabled bool
42974298
}{
42984299
{
42994300
ir: &fakeInfrastructureReader{highlyAvailableInfrastructure: false},
43004301
promf: func(f *Factory) (*monv1.Prometheus, error) {
43014302
return f.PrometheusK8s(&v1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}, nil)
43024303
},
43034304

4304-
exp: "100",
4305+
expectedGOGC: "100",
4306+
autoGOMEMLIMITDisabled: true,
43054307
},
43064308
{
43074309
ir: &fakeInfrastructureReader{highlyAvailableInfrastructure: true},
43084310
promf: func(f *Factory) (*monv1.Prometheus, error) {
43094311
return f.PrometheusK8s(&v1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}, nil)
43104312
},
43114313

4312-
exp: "",
4314+
expectedGOGC: "",
43134315
},
43144316
{
43154317
ir: &fakeInfrastructureReader{highlyAvailableInfrastructure: false},
43164318
promf: func(f *Factory) (*monv1.Prometheus, error) {
43174319
return f.PrometheusUserWorkload(&v1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "foo"}})
43184320
},
43194321

4320-
exp: "100",
4322+
expectedGOGC: "100",
4323+
autoGOMEMLIMITDisabled: true,
43214324
},
43224325
{
43234326
ir: &fakeInfrastructureReader{highlyAvailableInfrastructure: true},
43244327
promf: func(f *Factory) (*monv1.Prometheus, error) {
43254328
return f.PrometheusUserWorkload(&v1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "foo"}})
43264329
},
43274330

4328-
exp: "",
4331+
expectedGOGC: "",
43294332
},
43304333
} {
43314334
t.Run("", func(t *testing.T) {
@@ -4341,14 +4344,16 @@ func TestPrometheusGoGC(t *testing.T) {
43414344
}
43424345
}
43434346
require.NotNil(t, c)
4344-
if tc.exp == "" {
4347+
if tc.expectedGOGC == "" {
43454348
for _, env := range c.Env {
43464349
require.NotEqual(t, env.Name, "GOGC")
43474350
}
43484351
return
43494352
}
43504353

4351-
require.Contains(t, c.Env, v1.EnvVar{Name: "GOGC", Value: tc.exp})
4354+
require.Contains(t, c.Env, v1.EnvVar{Name: "GOGC", Value: tc.expectedGOGC})
4355+
4356+
require.Equal(t, tc.autoGOMEMLIMITDisabled, argumentPresent(*c, "--no-auto-gomemlimit"))
43524357
})
43534358
}
43544359
}

0 commit comments

Comments
 (0)