Skip to content

Commit

Permalink
[release-2.11] [ACM-13481] - Remove HA mode when AM has one replica (#…
Browse files Browse the repository at this point in the history
…1706)

* update

Signed-off-by: Coleen Iona Quadros <[email protected]>

* update

Signed-off-by: Coleen Iona Quadros <[email protected]>

* update

Signed-off-by: Coleen Iona Quadros <[email protected]>

---------

Signed-off-by: Coleen Iona Quadros <[email protected]>
  • Loading branch information
coleenquadros authored Dec 9, 2024
1 parent 806a096 commit 854a6e8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ spec:
containers:
- args:
- --config.file=/etc/alertmanager/config/alertmanager.yaml
- --cluster.listen-address=[$(POD_IP)]:9094
- --storage.path=/alertmanager
- --data.retention=120h
- --web.listen-address=127.0.0.1:9093
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,18 @@ func (r *MCORenderer) renderAlertManagerStatefulSet(res *resource.Resource,
args := spec.Containers[0].Args

if *dep.Spec.Replicas > 1 {
args = append(args, "--cluster.listen-address=[$(POD_IP)]:9094")
for i := int32(0); i < *dep.Spec.Replicas; i++ {
args = append(args, "--cluster.peer="+
mcoconfig.GetOperandName(mcoconfig.Alertmanager)+"-"+
strconv.Itoa(int(i))+".alertmanager-operated."+
mcoconfig.GetDefaultNamespace()+".svc:9094")
}
}
// ACM-13481 Disable HA mode for single replica
if *dep.Spec.Replicas == 1 {
args = append(args, "--cluster.listen-address=")
}

spec.Containers[0].Args = args
spec.Containers[0].Resources = mcoconfig.GetResources(mcoconfig.Alertmanager, r.cr.Spec.InstanceSize, r.cr.Spec.AdvancedConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,24 @@ func TestAlertManagerRendererMCOConfig(t *testing.T) {
assert.Equal(t, 3, count)
},
},
"one replica": {
mco: func() *mcov1beta2.MultiClusterObservability {
ret := makeBaseMco()
replicas := int32(1)
ret.Spec.AdvancedConfig = &mcov1beta2.AdvancedConfig{
Alertmanager: &mcov1beta2.CommonSpec{
Replicas: &replicas,
},
}
return ret
},
expect: func(t *testing.T, sts *appsv1.StatefulSet) {
assert.Equal(t, int32(1), *sts.Spec.Replicas)
args := sts.Spec.Template.Spec.Containers[0].Args
assert.NotContains(t, args, "--cluster.peer")
assert.Contains(t, args, "--cluster.listen-address=")
},
},
"resources": {
mco: func() *mcov1beta2.MultiClusterObservability {
ret := makeBaseMco()
Expand Down

0 comments on commit 854a6e8

Please sign in to comment.