Skip to content

Commit

Permalink
alertmanager: fixes panic after migration from previous versions
Browse files Browse the repository at this point in the history
Signed-off-by: f41gh7 <[email protected]>
  • Loading branch information
f41gh7 committed Sep 25, 2024
1 parent 1feab7d commit af9a88c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func makeStatefulSetSpec(cr *vmv1beta1.VMAlertmanager) (*appsv1.StatefulSetSpec,
amArgs = append(amArgs, fmt.Sprintf("--cluster.tls-config=%s/%s", tlsAssetsDir, gossipConfigKey))
}

if *cr.Spec.ReplicaCount == 1 {
if ptr.Deref(cr.Spec.ReplicaCount, 0) == 1 {
amArgs = append(amArgs, "--cluster.listen-address=")
} else {
amArgs = append(amArgs, "--cluster.listen-address=[$(POD_IP)]:9094")
Expand Down Expand Up @@ -207,7 +207,7 @@ func makeStatefulSetSpec(cr *vmv1beta1.VMAlertmanager) (*appsv1.StatefulSetSpec,
clusterPeerDomain = cr.PrefixedName()
}

for i := int32(0); i < *cr.Spec.ReplicaCount; i++ {
for i := int32(0); i < ptr.Deref(cr.Spec.ReplicaCount, 0); i++ {
amArgs = append(amArgs, fmt.Sprintf("--cluster.peer=%s-%d.%s:9094", cr.PrefixedName(), i, clusterPeerDomain))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ func makePodSpecForVMSelect(cr *vmv1beta1.VMCluster) (*corev1.PodTemplateSpec, e
}
// selectNode arg add for deployments without HPA
// HPA leads to rolling restart for vmselect statefulset in case of replicas count changes
if cr.Spec.VMSelect.HPA == nil {
if cr.Spec.VMSelect.HPA == nil && cr.Spec.VMSelect.ReplicaCount != nil {
selectArg := "-selectNode="
vmselectCount := *cr.Spec.VMSelect.ReplicaCount
for i := int32(0); i < vmselectCount; i++ {
Expand Down

0 comments on commit af9a88c

Please sign in to comment.