Skip to content

Commit 024aebd

Browse files
Merge pull request #2072 from marioferh/topology_spread_constrains_UWM_prometheus-operator
OCPBUGS-17682: add topologySpreadConstraints to UWM prometheus operator
2 parents 110f598 + e72d105 commit 024aebd

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

pkg/manifests/manifests.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,6 +2274,10 @@ func (f *Factory) PrometheusOperatorUserWorkloadDeployment() (*appsv1.Deployment
22742274
d.Spec.Template.Spec.Tolerations = f.config.UserWorkloadConfiguration.PrometheusOperator.Tolerations
22752275
}
22762276

2277+
if len(f.config.UserWorkloadConfiguration.PrometheusOperator.TopologySpreadConstraints) > 0 {
2278+
d.Spec.Template.Spec.TopologySpreadConstraints = f.config.UserWorkloadConfiguration.PrometheusOperator.TopologySpreadConstraints
2279+
}
2280+
22772281
for i, container := range d.Spec.Template.Spec.Containers {
22782282
switch container.Name {
22792283
case "kube-rbac-proxy":

pkg/manifests/manifests_test.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4386,9 +4386,18 @@ func TestPodDisruptionBudget(t *testing.T) {
43864386
}
43874387

43884388
func TestPrometheusOperatorUserWorkloadConfiguration(t *testing.T) {
4389-
c, err := NewConfigFromString(`
4390-
enableUserWorkload: true
4391-
`, false)
4389+
c := NewDefaultConfig()
4390+
uwc, err := NewUserConfigFromString(`prometheusOperator:
4391+
topologySpreadConstraints:
4392+
- maxSkew: 1
4393+
topologyKey: type
4394+
whenUnsatisfiable: DoNotSchedule
4395+
labelSelector:
4396+
matchLabels:
4397+
foo: bar
4398+
`)
4399+
4400+
c.UserWorkloadConfiguration = uwc
43924401

43934402
c.SetImages(map[string]string{
43944403
"prometheus-operator": "docker.io/openshift/origin-prometheus-operator:latest",
@@ -4463,6 +4472,14 @@ enableUserWorkload: true
44634472
if !reflect.DeepEqual(d, d2) {
44644473
t.Fatal("expected PrometheusOperatorUserWorkloadDeployment to be an idempotent function")
44654474
}
4475+
4476+
if d.Spec.Template.Spec.TopologySpreadConstraints[0].MaxSkew != 1 {
4477+
t.Fatal("prometheus-operator UWM spread contraints MaxSkew not configured correctly")
4478+
}
4479+
4480+
if d.Spec.Template.Spec.TopologySpreadConstraints[0].WhenUnsatisfiable != "DoNotSchedule" {
4481+
t.Fatal("prometheus-operator UWM spread contraints WhenUnsatisfiable not configured correctly")
4482+
}
44664483
}
44674484

44684485
func TestPrometheusOperatorNodeSelector(t *testing.T) {

0 commit comments

Comments
 (0)