Skip to content

Commit e4a04ee

Browse files
Merge pull request #2597 from openshift-cherrypick-robot/cherry-pick-2549-to-release-4.19
OCPBUGS-55737: [release-4.19] MON-4200: disable --auto-gomemlimit for Prometheus on SNO until we can ensure it won't result in excessive CPU usage
2 parents 3e27073 + 71e8db5 commit e4a04ee

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-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.AdditionalArgs = append(p.Spec.AdditionalArgs, monv1.Argument{Name: "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: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4293,44 +4293,47 @@ func TestThanosRulerRetentionConfig(t *testing.T) {
42934293
}
42944294
}
42954295

4296-
func TestPrometheusGoGC(t *testing.T) {
4296+
func TestPrometheusGoGCRelatedConfig(t *testing.T) {
42974297
for _, tc := range []struct {
42984298
ir InfrastructureReader
42994299
promf func(*Factory) (*monv1.Prometheus, error)
43004300

4301-
exp string
4301+
expectedGOGC string
4302+
autoGOMEMLIMITDisabled bool
43024303
}{
43034304
{
43044305
ir: &fakeInfrastructureReader{highlyAvailableInfrastructure: false},
43054306
promf: func(f *Factory) (*monv1.Prometheus, error) {
43064307
return f.PrometheusK8s(&v1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}, nil)
43074308
},
43084309

4309-
exp: "100",
4310+
expectedGOGC: "100",
4311+
autoGOMEMLIMITDisabled: true,
43104312
},
43114313
{
43124314
ir: &fakeInfrastructureReader{highlyAvailableInfrastructure: true},
43134315
promf: func(f *Factory) (*monv1.Prometheus, error) {
43144316
return f.PrometheusK8s(&v1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}, nil)
43154317
},
43164318

4317-
exp: "",
4319+
expectedGOGC: "",
43184320
},
43194321
{
43204322
ir: &fakeInfrastructureReader{highlyAvailableInfrastructure: false},
43214323
promf: func(f *Factory) (*monv1.Prometheus, error) {
43224324
return f.PrometheusUserWorkload(&v1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "foo"}})
43234325
},
43244326

4325-
exp: "100",
4327+
expectedGOGC: "100",
4328+
autoGOMEMLIMITDisabled: true,
43264329
},
43274330
{
43284331
ir: &fakeInfrastructureReader{highlyAvailableInfrastructure: true},
43294332
promf: func(f *Factory) (*monv1.Prometheus, error) {
43304333
return f.PrometheusUserWorkload(&v1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "foo"}})
43314334
},
43324335

4333-
exp: "",
4336+
expectedGOGC: "",
43344337
},
43354338
} {
43364339
t.Run("", func(t *testing.T) {
@@ -4346,14 +4349,17 @@ func TestPrometheusGoGC(t *testing.T) {
43464349
}
43474350
}
43484351
require.NotNil(t, c)
4349-
if tc.exp == "" {
4352+
if tc.expectedGOGC == "" {
43504353
for _, env := range c.Env {
43514354
require.NotEqual(t, env.Name, "GOGC")
43524355
}
43534356
return
43544357
}
43554358

4356-
require.Contains(t, c.Env, v1.EnvVar{Name: "GOGC", Value: tc.exp})
4359+
require.Contains(t, c.Env, v1.EnvVar{Name: "GOGC", Value: tc.expectedGOGC})
4360+
if tc.autoGOMEMLIMITDisabled {
4361+
require.Contains(t, p.Spec.AdditionalArgs, monv1.Argument{Name: "no-auto-gomemlimit"})
4362+
}
43574363
})
43584364
}
43594365
}

0 commit comments

Comments
 (0)